From bruno.cardoso at gmail.com Mon Jul 6 00:09:34 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 06 Jul 2009 05:09:34 -0000 Subject: [llvm-commits] [llvm] r74813 - in /llvm/trunk: include/llvm/CodeGen/ include/llvm/Target/ lib/CodeGen/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/PowerPC/ lib/Target/X86/ tools/llc/ tools/lto/ Message-ID: <200907060509.n6659Zbt026565@zion.cs.uiuc.edu> Author: bruno Date: Mon Jul 6 00:09:34 2009 New Revision: 74813 URL: http://llvm.org/viewvc/llvm-project?rev=74813&view=rev Log: Add the Object Code Emitter class. Original patch by Aaron Gray, I did some cleanup, removed some #includes and moved Object Code Emitter out-of-line. Modified: llvm/trunk/include/llvm/CodeGen/BinaryObject.h llvm/trunk/include/llvm/CodeGen/FileWriters.h llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h llvm/trunk/include/llvm/Target/TargetMachine.h llvm/trunk/lib/CodeGen/ELFWriter.cpp llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/lib/CodeGen/MachO.h llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp llvm/trunk/lib/CodeGen/MachOCodeEmitter.h llvm/trunk/lib/CodeGen/MachOWriter.cpp llvm/trunk/lib/CodeGen/MachOWriter.h llvm/trunk/lib/Target/ARM/ARM.h llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/lib/Target/ARM/ARMTargetMachine.h llvm/trunk/lib/Target/Alpha/Alpha.h llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h llvm/trunk/lib/Target/PowerPC/PPC.h llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h llvm/trunk/lib/Target/X86/X86.h llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.h llvm/trunk/tools/llc/llc.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp Modified: llvm/trunk/include/llvm/CodeGen/BinaryObject.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/BinaryObject.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/BinaryObject.h (original) +++ llvm/trunk/include/llvm/CodeGen/BinaryObject.h Mon Jul 6 00:09:34 2009 @@ -146,27 +146,27 @@ /// emitDWordLE - This callback is invoked when a 64-bit word needs to be /// written to the data stream in little-endian format. inline void emitDWordLE(uint64_t W) { - Data.push_back(unsigned(W >> 0) & 255); - Data.push_back(unsigned(W >> 8) & 255); - Data.push_back(unsigned(W >> 16) & 255); - Data.push_back(unsigned(W >> 24) & 255); - Data.push_back(unsigned(W >> 32) & 255); - Data.push_back(unsigned(W >> 40) & 255); - Data.push_back(unsigned(W >> 48) & 255); - Data.push_back(unsigned(W >> 56) & 255); + Data.push_back((W >> 0) & 255); + Data.push_back((W >> 8) & 255); + Data.push_back((W >> 16) & 255); + Data.push_back((W >> 24) & 255); + Data.push_back((W >> 32) & 255); + Data.push_back((W >> 40) & 255); + Data.push_back((W >> 48) & 255); + Data.push_back((W >> 56) & 255); } /// emitDWordBE - This callback is invoked when a 64-bit word needs to be /// written to the data stream in big-endian format. inline void emitDWordBE(uint64_t W) { - Data.push_back(unsigned(W >> 56) & 255); - Data.push_back(unsigned(W >> 48) & 255); - Data.push_back(unsigned(W >> 40) & 255); - Data.push_back(unsigned(W >> 32) & 255); - Data.push_back(unsigned(W >> 24) & 255); - Data.push_back(unsigned(W >> 16) & 255); - Data.push_back(unsigned(W >> 8) & 255); - Data.push_back(unsigned(W >> 0) & 255); + Data.push_back((W >> 56) & 255); + Data.push_back((W >> 48) & 255); + Data.push_back((W >> 40) & 255); + Data.push_back((W >> 32) & 255); + Data.push_back((W >> 24) & 255); + Data.push_back((W >> 16) & 255); + Data.push_back((W >> 8) & 255); + Data.push_back((W >> 0) & 255); } /// fixByte - This callback is invoked when a byte needs to be @@ -270,11 +270,11 @@ } /// emitAlignment - Pad the data to the specified alignment. - void emitAlignment(unsigned Alignment) { + void emitAlignment(unsigned Alignment, uint8_t fill = 0) { if (Alignment <= 1) return; unsigned PadSize = -Data.size() & (Alignment-1); for (unsigned i = 0; igetMachineCodeEmitter(); + return (ObjectCodeEmitter*) &EW->getMachineCodeEmitter(); } //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Mon Jul 6 00:09:34 2009 @@ -126,6 +126,23 @@ return false; // success! } +/// addPassesToEmitFileFinish - If the passes to emit the specified file had to +/// be split up (e.g., to add an object writer pass), this method can be used to +/// finish up adding passes to emit the file, if necessary. +bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM, + ObjectCodeEmitter *OCE, + CodeGenOpt::Level OptLevel) { + if (OCE) + addSimpleCodeEmitter(PM, OptLevel, PrintEmittedAsm, *OCE); + + PM.add(createGCInfoDeleter()); + + // Delete machine code for this function + PM.add(createMachineCodeDeleter()); + + return false; // success! +} + /// addPassesToEmitMachineCode - Add passes to the specified pass manager to /// get machine code emitted. This uses a MachineCodeEmitter object to handle /// actually outputting the machine code and resolving things like the address Modified: llvm/trunk/lib/CodeGen/MachO.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachO.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachO.h (original) +++ llvm/trunk/lib/CodeGen/MachO.h Mon Jul 6 00:09:34 2009 @@ -17,6 +17,7 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/CodeGen/MachineRelocation.h" +#include "llvm/CodeGen/BinaryObject.h" #include "llvm/Target/TargetAsmInfo.h" #include #include @@ -272,11 +273,10 @@ /// turned into the SectionCommand in the load command for a particlar /// segment. -struct MachOSection { +struct MachOSection : public BinaryObject { std::string sectname; // name of this section, std::string segname; // segment this section goes in uint64_t addr; // memory address of this section - uint64_t size; // size in bytes of this section uint32_t offset; // file offset of this section uint32_t align; // section alignment (power of 2) uint32_t reloff; // file offset of relocation entries @@ -290,19 +290,10 @@ /// to the correct section. uint32_t Index; - /// SectionData - The actual data for this section which we are building - /// up for emission to the file. - DataBuffer SectionData; - /// RelocBuffer - A buffer to hold the mach-o relocations before we write /// them out at the appropriate location in the file. DataBuffer RelocBuffer; - /// Relocations - The relocations that we have encountered so far in this - /// section that we will need to convert to MachORelocation entries when - /// the file is written. - std::vector Relocations; - // Constants for the section types (low 8 bits of flags field) // see enum { S_REGULAR = 0, @@ -374,48 +365,49 @@ } MachOSection(const std::string &seg, const std::string §) - : sectname(sect), segname(seg), addr(0), size(0), offset(0), align(2), - reloff(0), nreloc(0), flags(0), reserved1(0), reserved2(0), + : BinaryObject(), sectname(sect), segname(seg), addr(0), offset(0), + align(2), reloff(0), nreloc(0), flags(0), reserved1(0), reserved2(0), reserved3(0) { } }; // end struct MachOSection - /// MachOSymTab - This struct contains information about the offsets and - /// size of symbol table information. - /// segment. - struct MachODySymTab { - uint32_t cmd; // LC_DYSYMTAB - uint32_t cmdsize; // sizeof( MachODySymTab ) - uint32_t ilocalsym; // index to local symbols - uint32_t nlocalsym; // number of local symbols - uint32_t iextdefsym; // index to externally defined symbols - uint32_t nextdefsym; // number of externally defined symbols - uint32_t iundefsym; // index to undefined symbols - uint32_t nundefsym; // number of undefined symbols - uint32_t tocoff; // file offset to table of contents - uint32_t ntoc; // number of entries in table of contents - uint32_t modtaboff; // file offset to module table - uint32_t nmodtab; // number of module table entries - uint32_t extrefsymoff; // offset to referenced symbol table - uint32_t nextrefsyms; // number of referenced symbol table entries - uint32_t indirectsymoff; // file offset to the indirect symbol table - uint32_t nindirectsyms; // number of indirect symbol table entries - uint32_t extreloff; // offset to external relocation entries - uint32_t nextrel; // number of external relocation entries - uint32_t locreloff; // offset to local relocation entries - uint32_t nlocrel; // number of local relocation entries - - // Constants for the cmd field - // see - enum { LC_DYSYMTAB = 0x0B // dynamic link-edit symbol table info - }; - - MachODySymTab() : cmd(LC_DYSYMTAB), cmdsize(20 * sizeof(uint32_t)), - ilocalsym(0), nlocalsym(0), iextdefsym(0), nextdefsym(0), - iundefsym(0), nundefsym(0), tocoff(0), ntoc(0), modtaboff(0), - nmodtab(0), extrefsymoff(0), nextrefsyms(0), indirectsymoff(0), - nindirectsyms(0), extreloff(0), nextrel(0), locreloff(0), nlocrel(0) { } - }; +/// MachOSymTab - This struct contains information about the offsets and +/// size of symbol table information. +/// segment. +struct MachODySymTab { + uint32_t cmd; // LC_DYSYMTAB + uint32_t cmdsize; // sizeof(MachODySymTab) + uint32_t ilocalsym; // index to local symbols + uint32_t nlocalsym; // number of local symbols + uint32_t iextdefsym; // index to externally defined symbols + uint32_t nextdefsym; // number of externally defined symbols + uint32_t iundefsym; // index to undefined symbols + uint32_t nundefsym; // number of undefined symbols + uint32_t tocoff; // file offset to table of contents + uint32_t ntoc; // number of entries in table of contents + uint32_t modtaboff; // file offset to module table + uint32_t nmodtab; // number of module table entries + uint32_t extrefsymoff; // offset to referenced symbol table + uint32_t nextrefsyms; // number of referenced symbol table entries + uint32_t indirectsymoff; // file offset to the indirect symbol table + uint32_t nindirectsyms; // number of indirect symbol table entries + uint32_t extreloff; // offset to external relocation entries + uint32_t nextrel; // number of external relocation entries + uint32_t locreloff; // offset to local relocation entries + uint32_t nlocrel; // number of local relocation entries + + // Constants for the cmd field + // see + enum { LC_DYSYMTAB = 0x0B // dynamic link-edit symbol table info + }; + + MachODySymTab() : cmd(LC_DYSYMTAB), cmdsize(20 * sizeof(uint32_t)), + ilocalsym(0), nlocalsym(0), iextdefsym(0), nextdefsym(0), + iundefsym(0), nundefsym(0), tocoff(0), ntoc(0), modtaboff(0), + nmodtab(0), extrefsymoff(0), nextrefsyms(0), indirectsymoff(0), + nindirectsyms(0), extreloff(0), nextrel(0), locreloff(0), nlocrel(0) { } + +}; // end struct MachODySymTab } // end namespace llvm Modified: llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp Mon Jul 6 00:09:34 2009 @@ -16,6 +16,7 @@ #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/OutputBuffer.h" +#include //===----------------------------------------------------------------------===// // MachOCodeEmitter Implementation @@ -39,28 +40,18 @@ // Get the Mach-O Section that this function belongs in. MachOSection *MOS = MOW.getTextSection(); - // FIXME: better memory management - MOS->SectionData.reserve(4096); - BufferBegin = &MOS->SectionData[0]; - BufferEnd = BufferBegin + MOS->SectionData.capacity(); - // Upgrade the section alignment if required. if (MOS->align < Align) MOS->align = Align; - // Round the size up to the correct alignment for starting the new function. - if ((MOS->size & ((1 << Align) - 1)) != 0) { - MOS->size += (1 << Align); - MOS->size &= ~((1 << Align) - 1); - } + MOS->emitAlignment(Align); - // FIXME: Using MOS->size directly here instead of calculating it from the - // output buffer size (impossible because the code emitter deals only in raw - // bytes) forces us to manually synchronize size and write padding zero bytes - // to the output buffer for all non-text sections. For text sections, we do - // not synchonize the output buffer, and we just blow up if anyone tries to - // write non-code to it. An assert should probably be added to - // AddSymbolToSection to prevent calling it on the text section. - CurBufferPtr = BufferBegin + MOS->size; + // Create symbol for function entry + const GlobalValue *FuncV = MF.getFunction(); + MachOSym FnSym(FuncV, MOW.Mang->getValueName(FuncV), MOS->Index, TAI); + FnSym.n_value = getCurrentPCOffset(); + + // add it to the symtab. + MOW.SymbolTable.push_back(FnSym); } /// finishFunction - This callback is invoked after the function is completely @@ -71,15 +62,6 @@ // Get the Mach-O Section that this function belongs in. MachOSection *MOS = MOW.getTextSection(); - // Get a symbol for the function to add to the symbol table - // FIXME: it seems like we should call something like AddSymbolToSection - // in startFunction rather than changing the section size and symbol n_value - // here. - const GlobalValue *FuncV = MF.getFunction(); - MachOSym FnSym(FuncV, MOW.Mang->getValueName(FuncV), MOS->Index, TAI); - FnSym.n_value = MOS->size; - MOS->size = CurBufferPtr - BufferBegin; - // Emit constant pool to appropriate section(s) emitConstantPool(MF.getConstantPool()); @@ -112,12 +94,9 @@ } else { assert(0 && "Unhandled relocation type"); } - MOS->Relocations.push_back(MR); + MOS->addRelocation(MR); } Relocations.clear(); - - // Finally, add it to the symtab. - MOW.SymbolTable.push_back(FnSym); // Clear per-function data structures. CPLocations.clear(); @@ -151,13 +130,10 @@ unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); MachOSection *Sec = MOW.getConstSection(CP[i].Val.ConstVal); - OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); + OutputBuffer SecDataOut(Sec->getData(), is64Bit, isLittleEndian); - CPLocations.push_back(Sec->SectionData.size()); + CPLocations.push_back(Sec->size()); CPSections.push_back(Sec->Index); - - // FIXME: remove when we have unified size + output buffer - Sec->size += Size; // Allocate space in the section for the global. // FIXME: need alignment? @@ -165,14 +141,12 @@ for (unsigned j = 0; j < Size; ++j) SecDataOut.outbyte(0); - MOW.InitMem(CP[i].Val.ConstVal, &Sec->SectionData[0], CPLocations[i], - TM.getTargetData(), Sec->Relocations); + MachOWriter::InitMem(CP[i].Val.ConstVal, CPLocations[i], TM.getTargetData(), Sec); } } /// emitJumpTables - Emit all the jump tables for a given jump table info /// record to the appropriate section. - void MachOCodeEmitter::emitJumpTables(MachineJumpTableInfo *MJTI) { const std::vector &JT = MJTI->getJumpTables(); if (JT.empty()) return; @@ -183,24 +157,21 @@ MachOSection *Sec = MOW.getJumpTableSection(); unsigned TextSecIndex = MOW.getTextSection()->Index; - OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); + OutputBuffer SecDataOut(Sec->getData(), is64Bit, isLittleEndian); for (unsigned i = 0, e = JT.size(); i != e; ++i) { // For each jump table, record its offset from the start of the section, // reserve space for the relocations to the MBBs, and add the relocations. const std::vector &MBBs = JT[i].MBBs; - JTLocations.push_back(Sec->SectionData.size()); + JTLocations.push_back(Sec->size()); for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi) { - MachineRelocation MR(MOW.GetJTRelocation(Sec->SectionData.size(), - MBBs[mi])); + MachineRelocation MR(MOW.GetJTRelocation(Sec->size(), MBBs[mi])); MR.setResultPointer((void *)JTLocations[i]); MR.setConstantVal(TextSecIndex); - Sec->Relocations.push_back(MR); + Sec->addRelocation(MR); SecDataOut.outaddr(0); } } - // FIXME: remove when we have unified size + output buffer - Sec->size = Sec->SectionData.size(); } } // end namespace llvm Modified: llvm/trunk/lib/CodeGen/MachOCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOCodeEmitter.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOCodeEmitter.h (original) +++ llvm/trunk/lib/CodeGen/MachOCodeEmitter.h Mon Jul 6 00:09:34 2009 @@ -11,15 +11,13 @@ #define MACHOCODEEMITTER_H #include "MachOWriter.h" -#include "llvm/CodeGen/MachineCodeEmitter.h" -#include namespace llvm { /// MachOCodeEmitter - This class is used by the MachOWriter to emit the code /// for functions to the Mach-O file. -class MachOCodeEmitter : public MachineCodeEmitter { +class MachOCodeEmitter : public ObjectCodeEmitter { MachOWriter &MOW; /// Target machine description. @@ -34,27 +32,12 @@ /// Relocations - These are the relocations that the function needs, as /// emitted. std::vector Relocations; - - /// CPLocations - This is a map of constant pool indices to offsets from the - /// start of the section for that constant pool index. - std::vector CPLocations; - - /// CPSections - This is a map of constant pool indices to the MachOSection - /// containing the constant pool entry for that index. - std::vector CPSections; - - /// JTLocations - This is a map of jump table indices to offsets from the - /// start of the section for that jump table index. - std::vector JTLocations; - - /// MBBLocations - This vector is a mapping from MBB ID's to their address. - /// It is filled in by the StartMachineBasicBlock callback and queried by - /// the getMachineBasicBlockAddress callback. - std::vector MBBLocations; - + + std::map Labels; + public: - MachOCodeEmitter(MachOWriter &mow) : MOW(mow), TM(MOW.TM) - { + MachOCodeEmitter(MachOWriter &mow, MachOSection &mos) : + ObjectCodeEmitter(&mos), MOW(mow), TM(MOW.TM) { is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; isLittleEndian = TM.getTargetData()->isLittleEndian(); TAI = TM.getTargetAsmInfo(); @@ -69,58 +52,17 @@ void emitConstantPool(MachineConstantPool *MCP); void emitJumpTables(MachineJumpTableInfo *MJTI); - - virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const { - assert(CPLocations.size() > Index && "CP not emitted!"); - return CPLocations[Index]; - } - virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const { - assert(JTLocations.size() > Index && "JT not emitted!"); - return JTLocations[Index]; - } - - virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { - if (MBBLocations.size() <= (unsigned)MBB->getNumber()) - MBBLocations.resize((MBB->getNumber()+1)*2); - MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); - } - virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const { - assert(MBBLocations.size() > (unsigned)MBB->getNumber() && - MBBLocations[MBB->getNumber()] && "MBB not emitted!"); - return MBBLocations[MBB->getNumber()]; + virtual void emitLabel(uint64_t LabelID) { + Labels[LabelID] = getCurrentPCOffset(); } virtual uintptr_t getLabelAddress(uint64_t Label) const { - assert(0 && "get Label not implemented"); - abort(); - return 0; - } - - virtual void emitLabel(uint64_t LabelID) { - assert(0 && "emit Label not implemented"); - abort(); + return Labels.find(Label)->second; } virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) { } - /// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE! - virtual void startGVStub(const GlobalValue* F, unsigned StubSize, - unsigned Alignment = 1) { - assert(0 && "JIT specific function called!"); - abort(); - } - virtual void startGVStub(const GlobalValue* F, void *Buffer, - unsigned StubSize) { - assert(0 && "JIT specific function called!"); - abort(); - } - virtual void *finishGVStub(const GlobalValue* F) { - assert(0 && "JIT specific function called!"); - abort(); - return 0; - } - }; // end class MachOCodeEmitter } // end namespace llvm Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Mon Jul 6 00:09:34 2009 @@ -46,12 +46,12 @@ /// AddMachOWriter - Concrete function to add the Mach-O writer to the function /// pass manager. -MachineCodeEmitter *AddMachOWriter(PassManagerBase &PM, +ObjectCodeEmitter *AddMachOWriter(PassManagerBase &PM, raw_ostream &O, TargetMachine &TM) { MachOWriter *MOW = new MachOWriter(O, TM); PM.add(MOW); - return &MOW->getMachineCodeEmitter(); + return MOW->getObjectCodeEmitter(); } //===----------------------------------------------------------------------===// @@ -60,8 +60,9 @@ char MachOWriter::ID = 0; -MachOWriter::MachOWriter(raw_ostream &o, TargetMachine &tm) - : MachineFunctionPass(&ID), O(o), TM(tm) { +MachOWriter::MachOWriter(raw_ostream &o, TargetMachine &tm) + : MachineFunctionPass(&ID), O(o), TM(tm) + { is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; isLittleEndian = TM.getTargetData()->isLittleEndian(); @@ -69,11 +70,11 @@ // Create the machine code emitter object for this target. - MCE = new MachOCodeEmitter(*this); + MachOCE = new MachOCodeEmitter(*this, *getTextSection(true)); } MachOWriter::~MachOWriter() { - delete MCE; + delete MachOCE; } bool MachOWriter::doInitialization(Module &M) { @@ -97,13 +98,13 @@ /// the Mach-O file to 'O'. bool MachOWriter::doFinalization(Module &M) { // FIXME: we don't handle debug info yet, we should probably do that. - - // Okay, the.text section has been completed, build the .data, .bss, and + // Okay, the.text section has been completed, build the .data, .bss, and // "common" sections next. + for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) EmitGlobal(I); - + // Emit the header and load commands. EmitHeaderAndLoadCommands(); @@ -133,38 +134,32 @@ // Reserve space in the .bss section for this symbol while maintaining the // desired section alignment, which must be at least as much as required by // this symbol. - OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); + OutputBuffer SecDataOut(Sec->getData(), is64Bit, isLittleEndian); if (Align) { - uint64_t OrigSize = Sec->size; Align = Log2_32(Align); Sec->align = std::max(unsigned(Sec->align), Align); - Sec->size = (Sec->size + Align - 1) & ~(Align-1); - // Add alignment padding to buffer as well. - // FIXME: remove when we have unified size + output buffer - unsigned AlignedSize = Sec->size - OrigSize; - for (unsigned i = 0; i < AlignedSize; ++i) - SecDataOut.outbyte(0); + Sec->emitAlignment(Sec->align); } // Globals without external linkage apparently do not go in the symbol table. if (!GV->hasLocalLinkage()) { MachOSym Sym(GV, Mang->getValueName(GV), Sec->Index, TAI); - Sym.n_value = Sec->size; + Sym.n_value = Sec->size(); SymbolTable.push_back(Sym); } // Record the offset of the symbol, and then allocate space for it. // FIXME: remove when we have unified size + output buffer - Sec->size += Size; - - // Now that we know what section the GlovalVariable is going to be emitted + + // Now that we know what section the GlovalVariable is going to be emitted // into, update our mappings. // FIXME: We may also need to update this when outputting non-GlobalVariable // GlobalValues such as functions. - GVSection[GV] = Sec; - GVOffset[GV] = Sec->SectionData.size(); + GVSection[GV] = Sec; + GVOffset[GV] = Sec->size(); + // Allocate space in the section for the global. for (unsigned i = 0; i < Size; ++i) SecDataOut.outbyte(0); @@ -174,7 +169,7 @@ const Type *Ty = GV->getType()->getElementType(); unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); bool NoInit = !GV->hasInitializer(); - + // If this global has a zero initializer, it is part of the .bss or common // section. if (NoInit || GV->getInitializer()->isNullValue()) { @@ -183,8 +178,7 @@ // merged with other symbols. if (NoInit || GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() || GV->hasCommonLinkage()) { - MachOSym ExtOrCommonSym(GV, Mang->getValueName(GV), - MachOSym::NO_SECT, TAI); + MachOSym ExtOrCommonSym(GV, Mang->getValueName(GV), MachOSym::NO_SECT, TAI); // For undefined (N_UNDF) external (N_EXT) types, n_value is the size in // bytes of the symbol. ExtOrCommonSym.n_value = Size; @@ -198,15 +192,14 @@ AddSymbolToSection(BSS, GV); return; } - + // Scalar read-only data goes in a literal section if the scalar is 4, 8, or // 16 bytes, or a cstring. Other read only data goes into a regular const // section. Read-write data goes in the data section. - MachOSection *Sec = GV->isConstant() ? getConstSection(GV->getInitializer()) : + MachOSection *Sec = GV->isConstant() ? getConstSection(GV->getInitializer()) : getDataSection(); AddSymbolToSection(Sec, GV); - InitMem(GV->getInitializer(), &Sec->SectionData[0], GVOffset[GV], - TM.getTargetData(), Sec->Relocations); + InitMem(GV->getInitializer(), GVOffset[GV], TM.getTargetData(), Sec); } @@ -214,21 +207,22 @@ void MachOWriter::EmitHeaderAndLoadCommands() { // Step #0: Fill in the segment load command size, since we need it to figure // out the rest of the header fields + MachOSegment SEG("", is64Bit); SEG.nsects = SectionList.size(); - SEG.cmdsize = SEG.cmdSize(is64Bit) + + SEG.cmdsize = SEG.cmdSize(is64Bit) + SEG.nsects * SectionList[0]->cmdSize(is64Bit); - + // Step #1: calculate the number of load commands. We always have at least // one, for the LC_SEGMENT load command, plus two for the normal // and dynamic symbol tables, if there are any symbols. Header.ncmds = SymbolTable.empty() ? 1 : 3; - + // Step #2: calculate the size of the load commands Header.sizeofcmds = SEG.cmdsize; if (!SymbolTable.empty()) Header.sizeofcmds += SymTab.cmdsize + DySymTab.cmdsize; - + // Step #3: write the header to the file // Local alias to shortenify coming code. DataBuffer &FH = Header.HeaderData; @@ -243,15 +237,15 @@ FHOut.outword(Header.flags); if (is64Bit) FHOut.outword(Header.reserved); - + // Step #4: Finish filling in the segment load command and write it out for (std::vector::iterator I = SectionList.begin(), E = SectionList.end(); I != E; ++I) - SEG.filesize += (*I)->size; + SEG.filesize += (*I)->size(); SEG.vmsize = SEG.filesize; SEG.fileoff = Header.cmdSize(is64Bit) + Header.sizeofcmds; - + FHOut.outword(SEG.cmd); FHOut.outword(SEG.cmdsize); FHOut.outstring(SEG.segname, 16); @@ -263,42 +257,42 @@ FHOut.outword(SEG.initprot); FHOut.outword(SEG.nsects); FHOut.outword(SEG.flags); - - // Step #5: Finish filling in the fields of the MachOSections + + // Step #5: Finish filling in the fields of the MachOSections uint64_t currentAddr = 0; for (std::vector::iterator I = SectionList.begin(), E = SectionList.end(); I != E; ++I) { MachOSection *MOS = *I; MOS->addr = currentAddr; MOS->offset = currentAddr + SEG.fileoff; - // FIXME: do we need to do something with alignment here? - currentAddr += MOS->size; + currentAddr += MOS->size(); } - + // Step #6: Emit the symbol table to temporary buffers, so that we know the // size of the string table when we write the next load command. This also // sorts and assigns indices to each of the symbols, which is necessary for // emitting relocations to externally-defined objects. BufferSymbolAndStringTable(); - + // Step #7: Calculate the number of relocations for each section and write out // the section commands for each section currentAddr += SEG.fileoff; for (std::vector::iterator I = SectionList.begin(), E = SectionList.end(); I != E; ++I) { MachOSection *MOS = *I; + // Convert the relocations to target-specific relocations, and fill in the // relocation offset for this section. CalculateRelocations(*MOS); MOS->reloff = MOS->nreloc ? currentAddr : 0; currentAddr += MOS->nreloc * 8; - + // write the finalized section command to the output buffer FHOut.outstring(MOS->sectname, 16); FHOut.outstring(MOS->segname, 16); FHOut.outaddr(MOS->addr); - FHOut.outaddr(MOS->size); + FHOut.outaddr(MOS->size()); FHOut.outword(MOS->offset); FHOut.outword(MOS->align); FHOut.outword(MOS->reloff); @@ -309,7 +303,7 @@ if (is64Bit) FHOut.outword(MOS->reserved3); } - + // Step #8: Emit LC_SYMTAB/LC_DYSYMTAB load commands SymTab.symoff = currentAddr; SymTab.nsyms = SymbolTable.size(); @@ -345,39 +339,40 @@ FHOut.outword(DySymTab.nextrel); FHOut.outword(DySymTab.locreloff); FHOut.outword(DySymTab.nlocrel); - + O.write((char*)&FH[0], FH.size()); } /// EmitSections - Now that we have constructed the file header and load /// commands, emit the data for each section to the file. - void MachOWriter::EmitSections() { for (std::vector::iterator I = SectionList.begin(), E = SectionList.end(); I != E; ++I) // Emit the contents of each section - O.write((char*)&(*I)->SectionData[0], (*I)->size); + if ((*I)->size()) + O.write((char*)&(*I)->getData()[0], (*I)->size()); } + +/// EmitRelocations - emit relocation data from buffer. void MachOWriter::EmitRelocations() { for (std::vector::iterator I = SectionList.begin(), E = SectionList.end(); I != E; ++I) // Emit the relocation entry data for each section. - O.write((char*)&(*I)->RelocBuffer[0], (*I)->RelocBuffer.size()); + if ((*I)->RelocBuffer.size()) + O.write((char*)&(*I)->RelocBuffer[0], (*I)->RelocBuffer.size()); } /// BufferSymbolAndStringTable - Sort the symbols we encountered and assign them /// each a string table index so that they appear in the correct order in the /// output file. - void MachOWriter::BufferSymbolAndStringTable() { // The order of the symbol table is: // 1. local symbols // 2. defined external symbols (sorted by name) // 3. undefined external symbols (sorted by name) - + // Before sorting the symbols, check the PendingGlobals for any undefined // globals that need to be put in the symbol table. - for (std::vector::iterator I = PendingGlobals.begin(), E = PendingGlobals.end(); I != E; ++I) { if (GVOffset[*I] == 0 && GVSection[*I] == 0) { @@ -389,19 +384,15 @@ // Sort the symbols by name, so that when we partition the symbols by scope // of definition, we won't have to sort by name within each partition. - std::sort(SymbolTable.begin(), SymbolTable.end(), MachOSym::SymCmp()); - // Parition the symbol table entries so that all local symbols come before + // Parition the symbol table entries so that all local symbols come before // all symbols with external linkage. { 1 | 2 3 } - - std::partition(SymbolTable.begin(), SymbolTable.end(), - MachOSym::PartitionByLocal); - + std::partition(SymbolTable.begin(), SymbolTable.end(), MachOSym::PartitionByLocal); + // Advance iterator to beginning of external symbols and partition so that // all external symbols defined in this module come before all external // symbols defined elsewhere. { 1 | 2 | 3 } - for (std::vector::iterator I = SymbolTable.begin(), E = SymbolTable.end(); I != E; ++I) { if (!MachOSym::PartitionByLocal(*I)) { @@ -410,10 +401,9 @@ } } - // Calculate the starting index for each of the local, extern defined, and + // Calculate the starting index for each of the local, extern defined, and // undefined symbols, as well as the number of each to put in the LC_DYSYMTAB // load command. - for (std::vector::iterator I = SymbolTable.begin(), E = SymbolTable.end(); I != E; ++I) { if (MachOSym::PartitionByLocal(*I)) { @@ -427,10 +417,9 @@ ++DySymTab.nundefsym; } } - + // Write out a leading zero byte when emitting string table, for n_strx == 0 // which means an empty string. - OutputBuffer StrTOut(StrT, is64Bit, isLittleEndian); StrTOut.outbyte(0); @@ -439,7 +428,6 @@ // 2. strings for local symbols // Since this is the opposite order from the symbol table, which we have just // sorted, we can walk the symbol table backwards to output the string table. - for (std::vector::reverse_iterator I = SymbolTable.rbegin(), E = SymbolTable.rend(); I != E; ++I) { if (I->GVName == "") { @@ -463,7 +451,7 @@ I->n_value += GVSection[GV]->addr; if (GV && (GVOffset[GV] == -1)) GVOffset[GV] = index; - + // Emit nlist to buffer SymTOut.outword(I->n_strx); SymTOut.outbyte(I->n_type); @@ -478,32 +466,29 @@ /// and the offset into that section. From this information, create the /// appropriate target-specific MachORelocation type and add buffer it to be /// written out after we are finished writing out sections. - void MachOWriter::CalculateRelocations(MachOSection &MOS) { - for (unsigned i = 0, e = MOS.Relocations.size(); i != e; ++i) { - MachineRelocation &MR = MOS.Relocations[i]; + std::vector Relocations = MOS.getRelocations(); + for (unsigned i = 0, e = Relocations.size(); i != e; ++i) { + MachineRelocation &MR = Relocations[i]; unsigned TargetSection = MR.getConstantVal(); unsigned TargetAddr = 0; unsigned TargetIndex = 0; // This is a scattered relocation entry if it points to a global value with // a non-zero offset. - bool Scattered = false; bool Extern = false; // Since we may not have seen the GlobalValue we were interested in yet at // the time we emitted the relocation for it, fix it up now so that it // points to the offset into the correct section. - if (MR.isGlobalValue()) { GlobalValue *GV = MR.getGlobalValue(); MachOSection *MOSPtr = GVSection[GV]; intptr_t Offset = GVOffset[GV]; - + // If we have never seen the global before, it must be to a symbol // defined in another module (N_UNDF). - if (!MOSPtr) { // FIXME: need to append stub suffix Extern = true; @@ -515,10 +500,9 @@ } MR.setResultPointer((void*)Offset); } - + // If the symbol is locally defined, pass in the address of the section and // the section index to the code which will generate the target relocation. - if (!Extern) { MachOSection &To = *SectionList[TargetSection - 1]; TargetAddr = To.addr; @@ -526,7 +510,7 @@ } OutputBuffer RelocOut(MOS.RelocBuffer, is64Bit, isLittleEndian); - OutputBuffer SecOut(MOS.SectionData, is64Bit, isLittleEndian); + OutputBuffer SecOut(MOS.getData(), is64Bit, isLittleEndian); MOS.nreloc += GetTargetRelocation(MR, MOS.Index, TargetAddr, TargetIndex, RelocOut, SecOut, Scattered, Extern); @@ -535,22 +519,21 @@ // InitMem - Write the value of a Constant to the specified memory location, // converting it into bytes and relocations. - -void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, - const TargetData *TD, - std::vector &MRs) { +void MachOWriter::InitMem(const Constant *C, uintptr_t Offset, + const TargetData *TD, MachOSection* mos) { typedef std::pair CPair; std::vector WorkList; - + uint8_t *Addr = &mos->getData()[0]; + WorkList.push_back(CPair(C,(intptr_t)Addr + Offset)); - + intptr_t ScatteredOffset = 0; - + while (!WorkList.empty()) { const Constant *PC = WorkList.back().first; intptr_t PA = WorkList.back().second; WorkList.pop_back(); - + if (isa(PC)) { continue; } else if (const ConstantVector *CP = dyn_cast(PC)) { @@ -643,7 +626,7 @@ memset(ptr, 0, TD->getPointerSize()); else if (const GlobalValue* GV = dyn_cast(PC)) { // FIXME: what about function stubs? - MRs.push_back(MachineRelocation::getGV(PA-(intptr_t)Addr, + mos->addRelocation(MachineRelocation::getGV(PA-(intptr_t)Addr, MachineRelocation::VANILLA, const_cast(GV), ScatteredOffset)); Modified: llvm/trunk/lib/CodeGen/MachOWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.h (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.h Mon Jul 6 00:09:34 2009 @@ -15,17 +15,24 @@ #define MACHOWRITER_H #include "MachO.h" +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/ObjectCodeEmitter.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachOWriterInfo.h" +#include #include namespace llvm { class GlobalVariable; class Mangler; - class MachineCodeEmitter; + class MachineRelocation; + class ObjectCodeEmitter; class MachOCodeEmitter; + class TargetData; + class TargetMachine; class OutputBuffer; class raw_ostream; @@ -38,8 +45,9 @@ friend class MachOCodeEmitter; public: static char ID; - MachineCodeEmitter &getMachineCodeEmitter() const { - return *(MachineCodeEmitter*)MCE; + + ObjectCodeEmitter *getObjectCodeEmitter() { + return reinterpret_cast(MachOCE); } MachOWriter(raw_ostream &O, TargetMachine &TM); @@ -62,10 +70,10 @@ /// Mangler *Mang; - /// MCE - The MachineCodeEmitter object that we are exposing to emit machine + /// MachOCE - The MachineCodeEmitter object that we are exposing to emit machine /// code for functions to the .o file. - MachOCodeEmitter *MCE; + MachOCodeEmitter *MachOCE; /// is64Bit/isLittleEndian - This information is inferred from the target /// machine directly, indicating what header values and flags to set. @@ -225,9 +233,10 @@ /// SymbolTable to aid in emitting the DYSYMTAB load command. std::vector DynamicSymbolTable; - static void InitMem(const Constant *C, void *Addr, intptr_t Offset, + static void InitMem(const Constant *C, + uintptr_t Offset, const TargetData *TD, - std::vector &MRs); + MachOSection* mos); private: void AddSymbolToSection(MachOSection *MOS, GlobalVariable *GV); Modified: llvm/trunk/lib/Target/ARM/ARM.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.h (original) +++ llvm/trunk/lib/Target/ARM/ARM.h Mon Jul 6 00:09:34 2009 @@ -24,6 +24,7 @@ class FunctionPass; class MachineCodeEmitter; class JITCodeEmitter; +class ObjectCodeEmitter; class raw_ostream; // Enums corresponding to ARM condition codes @@ -101,6 +102,8 @@ MachineCodeEmitter &MCE); FunctionPass *createARMJITCodeEmitterPass(ARMBaseTargetMachine &TM, JITCodeEmitter &JCE); +FunctionPass *createARMObjectCodeEmitterPass(ARMBaseTargetMachine &TM, + ObjectCodeEmitter &OCE); FunctionPass *createARMLoadStoreOptimizationPass(bool PreAlloc = false); FunctionPass *createARMConstantIslandPass(); Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Mon Jul 6 00:09:34 2009 @@ -26,6 +26,7 @@ #include "llvm/PassManager.h" #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/CodeGen/JITCodeEmitter.h" +#include "llvm/CodeGen/ObjectCodeEmitter.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" @@ -174,18 +175,18 @@ /// createARMCodeEmitterPass - Return a pass that emits the collected ARM code /// to the specified MCE object. -namespace llvm { - -FunctionPass *createARMCodeEmitterPass(ARMBaseTargetMachine &TM, - MachineCodeEmitter &MCE) { +FunctionPass *llvm::createARMCodeEmitterPass(ARMBaseTargetMachine &TM, + MachineCodeEmitter &MCE) { return new Emitter(TM, MCE); } -FunctionPass *createARMJITCodeEmitterPass(ARMBaseTargetMachine &TM, - JITCodeEmitter &JCE) { +FunctionPass *llvm::createARMJITCodeEmitterPass(ARMBaseTargetMachine &TM, + JITCodeEmitter &JCE) { return new Emitter(TM, JCE); } - -} // end namespace llvm +FunctionPass *llvm::createARMObjectCodeEmitterPass(ARMBaseTargetMachine &TM, + ObjectCodeEmitter &OCE) { + return new Emitter(TM, OCE); +} template bool Emitter::runOnMachineFunction(MachineFunction &MF) { Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Mon Jul 6 00:09:34 2009 @@ -228,6 +228,25 @@ return false; } +bool ARMBaseTargetMachine::addCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, + ObjectCodeEmitter &OCE) { + // FIXME: Move this to TargetJITInfo! + if (DefRelocModel == Reloc::Default) + setRelocationModel(Reloc::Static); + + // Machine code emitter pass for ARM. + PM.add(createARMObjectCodeEmitterPass(*this, OCE)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(errs(), *this, true)); + } + + return false; +} + bool ARMBaseTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, @@ -258,4 +277,18 @@ return false; } +bool ARMBaseTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, + ObjectCodeEmitter &OCE) { + // Machine code emitter pass for ARM. + PM.add(createARMObjectCodeEmitterPass(*this, OCE)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(errs(), *this, true)); + } + + return false; +} Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.h (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.h Mon Jul 6 00:09:34 2009 @@ -77,6 +77,8 @@ bool DumpAsm, MachineCodeEmitter &MCE); virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &MCE); + virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, + bool DumpAsm, ObjectCodeEmitter &OCE); virtual bool addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, @@ -85,6 +87,10 @@ CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &MCE); + virtual bool addSimpleCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, + ObjectCodeEmitter &OCE); }; /// ARMTargetMachine - ARM target machine. Modified: llvm/trunk/lib/Target/Alpha/Alpha.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/Alpha.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/Alpha.h (original) +++ llvm/trunk/lib/Target/Alpha/Alpha.h Mon Jul 6 00:09:34 2009 @@ -22,6 +22,7 @@ class AlphaTargetMachine; class FunctionPass; class MachineCodeEmitter; + class ObjectCodeEmitter; class raw_ostream; FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM); @@ -32,7 +33,9 @@ FunctionPass *createAlphaCodeEmitterPass(AlphaTargetMachine &TM, MachineCodeEmitter &MCE); FunctionPass *createAlphaJITCodeEmitterPass(AlphaTargetMachine &TM, - JITCodeEmitter &JCE); + JITCodeEmitter &JCE); + FunctionPass *createAlphaObjectCodeEmitterPass(AlphaTargetMachine &TM, + ObjectCodeEmitter &OCE); FunctionPass *createAlphaLLRPPass(AlphaTargetMachine &tm); FunctionPass *createAlphaBranchSelectionPass(); Modified: llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp Mon Jul 6 00:09:34 2009 @@ -19,6 +19,7 @@ #include "llvm/PassManager.h" #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/CodeGen/JITCodeEmitter.h" +#include "llvm/CodeGen/ObjectCodeEmitter.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/Passes.h" @@ -91,6 +92,10 @@ JITCodeEmitter &JCE) { return new Emitter(TM, JCE); } +FunctionPass *llvm::createAlphaObjectCodeEmitterPass(AlphaTargetMachine &TM, + ObjectCodeEmitter &OCE) { + return new Emitter(TM, OCE); +} template bool Emitter::runOnMachineFunction(MachineFunction &MF) { Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp Mon Jul 6 00:09:34 2009 @@ -119,6 +119,17 @@ } return false; } +bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, ObjectCodeEmitter &OCE) { + PM.add(createAlphaObjectCodeEmitterPass(*this, OCE)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(errs(), *this, true)); + } + return false; +} bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, @@ -131,4 +142,10 @@ JITCodeEmitter &JCE) { return addCodeEmitter(PM, OptLevel, DumpAsm, JCE); } +bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, + ObjectCodeEmitter &OCE) { + return addCodeEmitter(PM, OptLevel, DumpAsm, OCE); +} Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h (original) +++ llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h Mon Jul 6 00:09:34 2009 @@ -74,6 +74,8 @@ bool DumpAsm, MachineCodeEmitter &MCE); virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &JCE); + virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, + bool DumpAsm, ObjectCodeEmitter &JCE); virtual bool addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, @@ -82,6 +84,10 @@ CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &JCE); + virtual bool addSimpleCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, + ObjectCodeEmitter &OCE); static void registerAsmPrinter(AsmPrinterCtorFn F) { AsmPrinterCtor = F; Modified: llvm/trunk/lib/Target/PowerPC/PPC.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPC.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPC.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPC.h Mon Jul 6 00:09:34 2009 @@ -24,6 +24,7 @@ class PPCTargetMachine; class FunctionPass; class MachineCodeEmitter; + class ObjectCodeEmitter; class raw_ostream; FunctionPass *createPPCBranchSelectionPass(); @@ -33,7 +34,9 @@ FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM, MachineCodeEmitter &MCE); FunctionPass *createPPCJITCodeEmitterPass(PPCTargetMachine &TM, - JITCodeEmitter &MCE); + JITCodeEmitter &MCE); +FunctionPass *createPPCObjectCodeEmitterPass(PPCTargetMachine &TM, + ObjectCodeEmitter &OCE); } // end namespace llvm; // Defines symbolic names for PowerPC registers. This defines a mapping from Modified: llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp Mon Jul 6 00:09:34 2009 @@ -19,6 +19,7 @@ #include "llvm/PassManager.h" #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/CodeGen/JITCodeEmitter.h" +#include "llvm/CodeGen/ObjectCodeEmitter.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineModuleInfo.h" @@ -91,6 +92,7 @@ /// createPPCCodeEmitterPass - Return a pass that emits the collected PPC code /// to the specified MCE object. + FunctionPass *llvm::createPPCCodeEmitterPass(PPCTargetMachine &TM, MachineCodeEmitter &MCE) { return new Emitter(TM, MCE); @@ -101,6 +103,11 @@ return new Emitter(TM, JCE); } +FunctionPass *llvm::createPPCObjectCodeEmitterPass(PPCTargetMachine &TM, + ObjectCodeEmitter &OCE) { + return new Emitter(TM, OCE); +} + template bool Emitter::runOnMachineFunction(MachineFunction &MF) { assert((MF.getTarget().getRelocationModel() != Reloc::Default || @@ -252,6 +259,7 @@ Reloc = PPC::reloc_pcrel_bx; else // BCC instruction Reloc = PPC::reloc_pcrel_bcx; + MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(), Reloc, MO.getMBB())); } else { Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp Mon Jul 6 00:09:34 2009 @@ -221,6 +221,38 @@ return false; } +bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, ObjectCodeEmitter &OCE) { + // The JIT should use the static relocation model in ppc32 mode, PIC in ppc64. + // FIXME: This should be moved to TargetJITInfo!! + if (Subtarget.isPPC64()) { + // We use PIC codegen in ppc64 mode, because otherwise we'd have to use many + // instructions to materialize arbitrary global variable + function + + // constant pool addresses. + setRelocationModel(Reloc::PIC_); + // Temporary workaround for the inability of PPC64 JIT to handle jump + // tables. + DisableJumpTables = true; + } else { + setRelocationModel(Reloc::Static); + } + + // Inform the subtarget that we are in JIT mode. FIXME: does this break macho + // writing? + Subtarget.SetJITMode(); + + // Machine code emitter pass for PowerPC. + PM.add(createPPCObjectCodeEmitterPass(*this, OCE)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(errs(), *this, true)); + } + + return false; +} + bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, @@ -251,3 +283,19 @@ return false; } +bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, + ObjectCodeEmitter &OCE) { + // Machine code emitter pass for PowerPC. + PM.add(createPPCObjectCodeEmitterPass(*this, OCE)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(errs(), *this, true)); + } + + return false; +} + + Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h Mon Jul 6 00:09:34 2009 @@ -85,12 +85,17 @@ bool DumpAsm, MachineCodeEmitter &MCE); virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &JCE); + virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, + bool DumpAsm, ObjectCodeEmitter &OCE); virtual bool addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, MachineCodeEmitter &MCE); virtual bool addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &JCE); + virtual bool addSimpleCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, ObjectCodeEmitter &OCE); virtual bool getEnableTailMergeDefault() const; }; Modified: llvm/trunk/lib/Target/X86/X86.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86.h (original) +++ llvm/trunk/lib/Target/X86/X86.h Mon Jul 6 00:09:34 2009 @@ -56,6 +56,8 @@ MachineCodeEmitter &MCE); FunctionPass *createX86JITCodeEmitterPass(X86TargetMachine &TM, JITCodeEmitter &JCE); +FunctionPass *createX86ObjectCodeEmitterPass(X86TargetMachine &TM, + ObjectCodeEmitter &OCE); /// createX86EmitCodeToMemory - Returns a pass that converts a register /// allocated function into raw machine code in a dynamically Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Mon Jul 6 00:09:34 2009 @@ -22,6 +22,7 @@ #include "llvm/PassManager.h" #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/CodeGen/JITCodeEmitter.h" +#include "llvm/CodeGen/ObjectCodeEmitter.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineModuleInfo.h" @@ -106,18 +107,18 @@ /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code /// to the specified templated MachineCodeEmitter object. -namespace llvm { - -FunctionPass *createX86CodeEmitterPass(X86TargetMachine &TM, - MachineCodeEmitter &MCE) { +FunctionPass *llvm::createX86CodeEmitterPass(X86TargetMachine &TM, + MachineCodeEmitter &MCE) { return new Emitter(TM, MCE); } -FunctionPass *createX86JITCodeEmitterPass(X86TargetMachine &TM, - JITCodeEmitter &JCE) { +FunctionPass *llvm::createX86JITCodeEmitterPass(X86TargetMachine &TM, + JITCodeEmitter &JCE) { return new Emitter(TM, JCE); } - -} // end namespace llvm +FunctionPass *llvm::createX86ObjectCodeEmitterPass(X86TargetMachine &TM, + ObjectCodeEmitter &OCE) { + return new Emitter(TM, OCE); +} template bool Emitter::runOnMachineFunction(MachineFunction &MF) { Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Mon Jul 6 00:09:34 2009 @@ -290,6 +290,36 @@ return false; } +bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, + ObjectCodeEmitter &OCE) { + // FIXME: Move this to TargetJITInfo! + // On Darwin, do not override 64-bit setting made in X86TargetMachine(). + if (DefRelocModel == Reloc::Default && + (!Subtarget.isTargetDarwin() || !Subtarget.is64Bit())) + setRelocationModel(Reloc::Static); + + // 64-bit JIT places everything in the same buffer except external functions. + // On Darwin, use small code model but hack the call instruction for + // externals. Elsewhere, do not assume globals are in the lower 4G. + if (Subtarget.is64Bit()) { + if (Subtarget.isTargetDarwin()) + setCodeModel(CodeModel::Small); + else + setCodeModel(CodeModel::Large); + } + + PM.add(createX86ObjectCodeEmitterPass(*this, OCE)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(errs(), *this, true)); + } + + return false; +} + bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, @@ -318,3 +348,16 @@ return false; } +bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, + ObjectCodeEmitter &OCE) { + PM.add(createX86ObjectCodeEmitterPass(*this, OCE)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(errs(), *this, true)); + } + + return false; +} Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.h?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.h Mon Jul 6 00:09:34 2009 @@ -84,12 +84,17 @@ bool DumpAsm, MachineCodeEmitter &MCE); virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &JCE); + virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, + bool DumpAsm, ObjectCodeEmitter &OCE); virtual bool addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, MachineCodeEmitter &MCE); virtual bool addSimpleCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &JCE); + virtual bool addSimpleCodeEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + bool DumpAsm, ObjectCodeEmitter &OCE); }; /// X86_32TargetMachine - X86 32-bit target machine. Modified: llvm/trunk/tools/llc/llc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/tools/llc/llc.cpp (original) +++ llvm/trunk/tools/llc/llc.cpp Mon Jul 6 00:09:34 2009 @@ -17,6 +17,7 @@ #include "llvm/CodeGen/FileWriters.h" #include "llvm/CodeGen/LinkAllCodegenComponents.h" #include "llvm/CodeGen/LinkAllAsmWriterComponents.h" +#include "llvm/CodeGen/ObjectCodeEmitter.h" #include "llvm/Target/SubtargetFeature.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" @@ -312,7 +313,7 @@ #endif // Ask the target to add backend passes as necessary. - MachineCodeEmitter *MCE = 0; + ObjectCodeEmitter *OCE = 0; // Override default to generate verbose assembly. Target.setAsmVerbosityDefault(true); @@ -331,14 +332,14 @@ case FileModel::AsmFile: break; case FileModel::MachOFile: - MCE = AddMachOWriter(Passes, *Out, Target); + OCE = AddMachOWriter(Passes, *Out, Target); break; case FileModel::ElfFile: - MCE = AddELFWriter(Passes, *Out, Target); + OCE = AddELFWriter(Passes, *Out, Target); break; } - if (Target.addPassesToEmitFileFinish(Passes, MCE, OLvl)) { + if (Target.addPassesToEmitFileFinish(Passes, OCE, OLvl)) { std::cerr << argv[0] << ": target does not support generation of this" << " file type!\n"; if (Out != &outs()) delete Out; Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=74813&r1=74812&r2=74813&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon Jul 6 00:09:34 2009 @@ -430,16 +430,16 @@ codeGenPasses->add(new TargetData(*_target->getTargetData())); - MachineCodeEmitter* mce = NULL; + ObjectCodeEmitter* oce = NULL; switch (_target->addPassesToEmitFile(*codeGenPasses, out, TargetMachine::AssemblyFile, CodeGenOpt::Aggressive)) { case FileModel::MachOFile: - mce = AddMachOWriter(*codeGenPasses, out, *_target); + oce = AddMachOWriter(*codeGenPasses, out, *_target); break; case FileModel::ElfFile: - mce = AddELFWriter(*codeGenPasses, out, *_target); + oce = AddELFWriter(*codeGenPasses, out, *_target); break; case FileModel::AsmFile: break; @@ -449,7 +449,7 @@ return true; } - if (_target->addPassesToEmitFileFinish(*codeGenPasses, mce, + if (_target->addPassesToEmitFileFinish(*codeGenPasses, oce, CodeGenOpt::Aggressive)) { errMsg = "target does not support generation of this file type"; return true; From bruno.cardoso at gmail.com Mon Jul 6 00:14:39 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 6 Jul 2009 02:14:39 -0300 Subject: [llvm-commits] [llvm] r74813 - in /llvm/trunk: include/llvm/CodeGen/ include/llvm/Target/ lib/CodeGen/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/PowerPC/ lib/Target/X86/ tools/llc/ tools/lto/ In-Reply-To: <200907060509.n6659Zbt026565@zion.cs.uiuc.edu> References: <200907060509.n6659Zbt026565@zion.cs.uiuc.edu> Message-ID: <275e64e40907052214r45b51489i1631eaa19f92b834@mail.gmail.com> Aaron asked me to include the original patch documentation, attached now. On Mon, Jul 6, 2009 at 2:09 AM, Bruno Cardoso Lopes wrote: > Author: bruno > Date: Mon Jul ?6 00:09:34 2009 > New Revision: 74813 > > URL: http://llvm.org/viewvc/llvm-project?rev=74813&view=rev > Log: > Add the Object Code Emitter class. Original patch by Aaron Gray, I did some > cleanup, removed some #includes and moved Object Code Emitter out-of-line. > > > Modified: > ? ?llvm/trunk/include/llvm/CodeGen/BinaryObject.h > ? ?llvm/trunk/include/llvm/CodeGen/FileWriters.h > ? ?llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h > ? ?llvm/trunk/include/llvm/Target/TargetMachine.h > ? ?llvm/trunk/lib/CodeGen/ELFWriter.cpp > ? ?llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp > ? ?llvm/trunk/lib/CodeGen/MachO.h > ? ?llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp > ? ?llvm/trunk/lib/CodeGen/MachOCodeEmitter.h > ? ?llvm/trunk/lib/CodeGen/MachOWriter.cpp > ? ?llvm/trunk/lib/CodeGen/MachOWriter.h > ? ?llvm/trunk/lib/Target/ARM/ARM.h > ? ?llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp > ? ?llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp > ? ?llvm/trunk/lib/Target/ARM/ARMTargetMachine.h > ? ?llvm/trunk/lib/Target/Alpha/Alpha.h > ? ?llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp > ? ?llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp > ? ?llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h > ? ?llvm/trunk/lib/Target/PowerPC/PPC.h > ? ?llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp > ? ?llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp > ? ?llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h > ? ?llvm/trunk/lib/Target/X86/X86.h > ? ?llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp > ? ?llvm/trunk/lib/Target/X86/X86TargetMachine.cpp > ? ?llvm/trunk/lib/Target/X86/X86TargetMachine.h > ? ?llvm/trunk/tools/llc/llc.cpp > ? ?llvm/trunk/tools/lto/LTOCodeGenerator.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/BinaryObject.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/BinaryObject.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/BinaryObject.h (original) > +++ llvm/trunk/include/llvm/CodeGen/BinaryObject.h Mon Jul ?6 00:09:34 2009 > @@ -146,27 +146,27 @@ > ? /// emitDWordLE - This callback is invoked when a 64-bit word needs to be > ? /// written to the data stream in little-endian format. > ? inline void emitDWordLE(uint64_t W) { > - ? ?Data.push_back(unsigned(W >> ?0) & 255); > - ? ?Data.push_back(unsigned(W >> ?8) & 255); > - ? ?Data.push_back(unsigned(W >> 16) & 255); > - ? ?Data.push_back(unsigned(W >> 24) & 255); > - ? ?Data.push_back(unsigned(W >> 32) & 255); > - ? ?Data.push_back(unsigned(W >> 40) & 255); > - ? ?Data.push_back(unsigned(W >> 48) & 255); > - ? ?Data.push_back(unsigned(W >> 56) & 255); > + ? ?Data.push_back((W >> ?0) & 255); > + ? ?Data.push_back((W >> ?8) & 255); > + ? ?Data.push_back((W >> 16) & 255); > + ? ?Data.push_back((W >> 24) & 255); > + ? ?Data.push_back((W >> 32) & 255); > + ? ?Data.push_back((W >> 40) & 255); > + ? ?Data.push_back((W >> 48) & 255); > + ? ?Data.push_back((W >> 56) & 255); > ? } > > ? /// emitDWordBE - This callback is invoked when a 64-bit word needs to be > ? /// written to the data stream in big-endian format. > ? inline void emitDWordBE(uint64_t W) { > - ? ?Data.push_back(unsigned(W >> 56) & 255); > - ? ?Data.push_back(unsigned(W >> 48) & 255); > - ? ?Data.push_back(unsigned(W >> 40) & 255); > - ? ?Data.push_back(unsigned(W >> 32) & 255); > - ? ?Data.push_back(unsigned(W >> 24) & 255); > - ? ?Data.push_back(unsigned(W >> 16) & 255); > - ? ?Data.push_back(unsigned(W >> ?8) & 255); > - ? ?Data.push_back(unsigned(W >> ?0) & 255); > + ? ?Data.push_back((W >> 56) & 255); > + ? ?Data.push_back((W >> 48) & 255); > + ? ?Data.push_back((W >> 40) & 255); > + ? ?Data.push_back((W >> 32) & 255); > + ? ?Data.push_back((W >> 24) & 255); > + ? ?Data.push_back((W >> 16) & 255); > + ? ?Data.push_back((W >> ?8) & 255); > + ? ?Data.push_back((W >> ?0) & 255); > ? } > > ? /// fixByte - This callback is invoked when a byte needs to be > @@ -270,11 +270,11 @@ > ? } > > ? /// emitAlignment - Pad the data to the specified alignment. > - ?void emitAlignment(unsigned Alignment) { > + ?void emitAlignment(unsigned Alignment, uint8_t fill = 0) { > ? ? if (Alignment <= 1) return; > ? ? unsigned PadSize = -Data.size() & (Alignment-1); > ? ? for (unsigned i = 0; i - ? ? ?Data.push_back(0); > + ? ? ?Data.push_back(fill); > ? } > > ? /// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be > > Modified: llvm/trunk/include/llvm/CodeGen/FileWriters.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FileWriters.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/FileWriters.h (original) > +++ llvm/trunk/include/llvm/CodeGen/FileWriters.h Mon Jul ?6 00:09:34 2009 > @@ -17,14 +17,14 @@ > ?namespace llvm { > > ? class PassManagerBase; > - ?class MachineCodeEmitter; > + ?class ObjectCodeEmitter; > ? class TargetMachine; > ? class raw_ostream; > > - ?MachineCodeEmitter *AddELFWriter(PassManagerBase &FPM, raw_ostream &O, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TargetMachine &TM); > - ?MachineCodeEmitter *AddMachOWriter(PassManagerBase &FPM, raw_ostream &O, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TargetMachine &TM); > + ?ObjectCodeEmitter *AddELFWriter(PassManagerBase &FPM, raw_ostream &O, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?TargetMachine &TM); > + ?ObjectCodeEmitter *AddMachOWriter(PassManagerBase &FPM, raw_ostream &O, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?TargetMachine &TM); > > ?} // end llvm namespace > > > Modified: llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h (original) > +++ llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h Mon Jul ?6 00:09:34 2009 > @@ -74,24 +74,6 @@ > ? /// false. > ? /// > ? virtual bool finishFunction(MachineFunction &F) = 0; > - > - ?/// startGVStub - This callback is invoked when the JIT needs the > - ?/// address of a GV (e.g. function) that has not been code generated yet. > - ?/// The StubSize specifies the total size required by the stub. > - ?/// > - ?virtual void startGVStub(const GlobalValue* GV, unsigned StubSize, > - ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Alignment = 1) = 0; > - > - ?/// startGVStub - This callback is invoked when the JIT needs the address of a > - ?/// GV (e.g. function) that has not been code generated yet. ?Buffer points to > - ?/// memory already allocated for this stub. > - ?/// > - ?virtual void startGVStub(const GlobalValue* GV, void *Buffer, > - ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned StubSize) = 0; > - > - ?/// finishGVStub - This callback is invoked to terminate a GV stub. > - ?/// > - ?virtual void *finishGVStub(const GlobalValue* F) = 0; > > ? /// emitByte - This callback is invoked when a byte needs to be written to the > ? /// output stream. > @@ -288,14 +270,13 @@ > > ? /// getCurrentPCOffset - Return the offset from the start of the emitted > ? /// buffer that we are currently writing to. > - ?uintptr_t getCurrentPCOffset() const { > + ?virtual uintptr_t getCurrentPCOffset() const { > ? ? return CurBufferPtr-BufferBegin; > ? } > > ? /// addRelocation - Whenever a relocatable address is needed, it should be > ? /// noted with this interface. > ? virtual void addRelocation(const MachineRelocation &MR) = 0; > - > > ? /// FIXME: These should all be handled with relocations! > > > Modified: llvm/trunk/include/llvm/Target/TargetMachine.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) > +++ llvm/trunk/include/llvm/Target/TargetMachine.h Mon Jul ?6 00:09:34 2009 > @@ -29,6 +29,7 @@ > ?class TargetFrameInfo; > ?class MachineCodeEmitter; > ?class JITCodeEmitter; > +class ObjectCodeEmitter; > ?class TargetRegisterInfo; > ?class Module; > ?class PassManagerBase; > @@ -257,6 +258,16 @@ > ? ? return true; > ? } > > + ?/// addPassesToEmitFileFinish - If the passes to emit the specified file had > + ?/// to be split up (e.g., to add an object writer pass), this method can be > + ?/// used to finish up adding passes to emit the file, if necessary. > + ?/// > + ?virtual bool addPassesToEmitFileFinish(PassManagerBase &, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter *, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level) { > + ? ?return true; > + ?} > + > ? /// addPassesToEmitMachineCode - Add passes to the specified pass manager to > ? /// get machine code emitted. ?This uses a MachineCodeEmitter object to handle > ? /// actually outputting the machine code and resolving things like the address > @@ -335,7 +346,15 @@ > ? /// used to finish up adding passes to emit the file, if necessary. > ? /// > ? virtual bool addPassesToEmitFileFinish(PassManagerBase &PM, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter *MCE, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter *JCE, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level); > + > + ?/// addPassesToEmitFileFinish - If the passes to emit the specified file had > + ?/// to be split up (e.g., to add an object writer pass), this method can be > + ?/// used to finish up adding passes to emit the file, if necessary. > + ?/// > + ?virtual bool addPassesToEmitFileFinish(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter *OCE, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level); > > ? /// addPassesToEmitMachineCode - Add passes to the specified pass manager to > @@ -432,6 +451,15 @@ > ? ? return true; > ? } > > + ?/// addSimpleCodeEmitter - This pass should be overridden by the target to add > + ?/// a code emitter (without setting flags), if supported. ?If this is not > + ?/// supported, 'true' should be returned. ?If DumpAsm is true, the generated > + ?/// assembly is printed to cerr. > + ?virtual bool addSimpleCodeEmitter(PassManagerBase &, CodeGenOpt::Level, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool /*DumpAsm*/, ObjectCodeEmitter &) { > + ? ?return true; > + ?} > + > ? /// getEnableTailMergeDefault - the default setting for -enable-tail-merge > ? /// on this target. ?User flag overrides. > ? virtual bool getEnableTailMergeDefault() const { return true; } > > Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/ELFWriter.cpp (original) > +++ llvm/trunk/lib/CodeGen/ELFWriter.cpp Mon Jul ?6 00:09:34 2009 > @@ -40,6 +40,8 @@ > ?#include "llvm/CodeGen/BinaryObject.h" > ?#include "llvm/CodeGen/FileWriters.h" > ?#include "llvm/CodeGen/MachineCodeEmitter.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > +#include "llvm/CodeGen/MachineCodeEmitter.h" > ?#include "llvm/CodeGen/MachineConstantPool.h" > ?#include "llvm/Target/TargetAsmInfo.h" > ?#include "llvm/Target/TargetData.h" > @@ -54,12 +56,12 @@ > ?char ELFWriter::ID = 0; > ?/// AddELFWriter - Concrete function to add the ELF writer to the function pass > ?/// manager. > -MachineCodeEmitter *llvm::AddELFWriter(PassManagerBase &PM, > +ObjectCodeEmitter *llvm::AddELFWriter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?raw_ostream &O, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?TargetMachine &TM) { > ? ELFWriter *EW = new ELFWriter(O, TM); > ? PM.add(EW); > - ?return &EW->getMachineCodeEmitter(); > + ?return (ObjectCodeEmitter*) &EW->getMachineCodeEmitter(); > ?} > > ?//===----------------------------------------------------------------------===// > > Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) > +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Mon Jul ?6 00:09:34 2009 > @@ -126,6 +126,23 @@ > ? return false; // success! > ?} > > +/// addPassesToEmitFileFinish - If the passes to emit the specified file had to > +/// be split up (e.g., to add an object writer pass), this method can be used to > +/// finish up adding passes to emit the file, if necessary. > +bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ObjectCodeEmitter *OCE, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel) { > + ?if (OCE) > + ? ?addSimpleCodeEmitter(PM, OptLevel, PrintEmittedAsm, *OCE); > + > + ?PM.add(createGCInfoDeleter()); > + > + ?// Delete machine code for this function > + ?PM.add(createMachineCodeDeleter()); > + > + ?return false; // success! > +} > + > ?/// addPassesToEmitMachineCode - Add passes to the specified pass manager to > ?/// get machine code emitted. ?This uses a MachineCodeEmitter object to handle > ?/// actually outputting the machine code and resolving things like the address > > Modified: llvm/trunk/lib/CodeGen/MachO.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachO.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachO.h (original) > +++ llvm/trunk/lib/CodeGen/MachO.h Mon Jul ?6 00:09:34 2009 > @@ -17,6 +17,7 @@ > ?#include "llvm/Constants.h" > ?#include "llvm/DerivedTypes.h" > ?#include "llvm/CodeGen/MachineRelocation.h" > +#include "llvm/CodeGen/BinaryObject.h" > ?#include "llvm/Target/TargetAsmInfo.h" > ?#include > ?#include > @@ -272,11 +273,10 @@ > ?/// turned into the SectionCommand in the load command for a particlar > ?/// segment. > > -struct MachOSection { > +struct MachOSection : public BinaryObject { > ? std::string ?sectname; // name of this section, > ? std::string ?segname; ?// segment this section goes in > ? uint64_t ?addr; ? ? ? ?// memory address of this section > - ?uint64_t ?size; ? ? ? ?// size in bytes of this section > ? uint32_t ?offset; ? ? ?// file offset of this section > ? uint32_t ?align; ? ? ? // section alignment (power of 2) > ? uint32_t ?reloff; ? ? ?// file offset of relocation entries > @@ -290,19 +290,10 @@ > ? /// to the correct section. > ? uint32_t Index; > > - ?/// SectionData - The actual data for this section which we are building > - ?/// up for emission to the file. > - ?DataBuffer SectionData; > - > ? /// RelocBuffer - A buffer to hold the mach-o relocations before we write > ? /// them out at the appropriate location in the file. > ? DataBuffer RelocBuffer; > > - ?/// Relocations - The relocations that we have encountered so far in this > - ?/// section that we will need to convert to MachORelocation entries when > - ?/// the file is written. > - ?std::vector Relocations; > - > ? // Constants for the section types (low 8 bits of flags field) > ? // see > ? enum { S_REGULAR = 0, > @@ -374,48 +365,49 @@ > ? } > > ? MachOSection(const std::string &seg, const std::string §) > - ? ?: sectname(sect), segname(seg), addr(0), size(0), offset(0), align(2), > - ? ? ?reloff(0), nreloc(0), flags(0), reserved1(0), reserved2(0), > + ? ?: BinaryObject(), sectname(sect), segname(seg), addr(0), offset(0), > + ? ? ?align(2), reloff(0), nreloc(0), flags(0), reserved1(0), reserved2(0), > ? ? ? reserved3(0) { } > > ?}; // end struct MachOSection > > - ? ?/// MachOSymTab - This struct contains information about the offsets and > - ? ?/// size of symbol table information. > - ? ?/// segment. > - ? ?struct MachODySymTab { > - ? ? ?uint32_t cmd; ? ? ? ? ? ? // LC_DYSYMTAB > - ? ? ?uint32_t cmdsize; ? ? ? ? // sizeof( MachODySymTab ) > - ? ? ?uint32_t ilocalsym; ? ? ? // index to local symbols > - ? ? ?uint32_t nlocalsym; ? ? ? // number of local symbols > - ? ? ?uint32_t iextdefsym; ? ? ?// index to externally defined symbols > - ? ? ?uint32_t nextdefsym; ? ? ?// number of externally defined symbols > - ? ? ?uint32_t iundefsym; ? ? ? // index to undefined symbols > - ? ? ?uint32_t nundefsym; ? ? ? // number of undefined symbols > - ? ? ?uint32_t tocoff; ? ? ? ? ?// file offset to table of contents > - ? ? ?uint32_t ntoc; ? ? ? ? ? ?// number of entries in table of contents > - ? ? ?uint32_t modtaboff; ? ? ? // file offset to module table > - ? ? ?uint32_t nmodtab; ? ? ? ? // number of module table entries > - ? ? ?uint32_t extrefsymoff; ? ?// offset to referenced symbol table > - ? ? ?uint32_t nextrefsyms; ? ? // number of referenced symbol table entries > - ? ? ?uint32_t indirectsymoff; ?// file offset to the indirect symbol table > - ? ? ?uint32_t nindirectsyms; ? // number of indirect symbol table entries > - ? ? ?uint32_t extreloff; ? ? ? // offset to external relocation entries > - ? ? ?uint32_t nextrel; ? ? ? ? // number of external relocation entries > - ? ? ?uint32_t locreloff; ? ? ? // offset to local relocation entries > - ? ? ?uint32_t nlocrel; ? ? ? ? // number of local relocation entries > - > - ? ? ?// Constants for the cmd field > - ? ? ?// see > - ? ? ?enum { LC_DYSYMTAB = 0x0B ?// dynamic link-edit symbol table info > - ? ? ?}; > - > - ? ? ?MachODySymTab() : cmd(LC_DYSYMTAB), cmdsize(20 * sizeof(uint32_t)), > - ? ? ? ?ilocalsym(0), nlocalsym(0), iextdefsym(0), nextdefsym(0), > - ? ? ? ?iundefsym(0), nundefsym(0), tocoff(0), ntoc(0), modtaboff(0), > - ? ? ? ?nmodtab(0), extrefsymoff(0), nextrefsyms(0), indirectsymoff(0), > - ? ? ? ?nindirectsyms(0), extreloff(0), nextrel(0), locreloff(0), nlocrel(0) { } > - ? ?}; > +/// MachOSymTab - This struct contains information about the offsets and > +/// size of symbol table information. > +/// segment. > +struct MachODySymTab { > + ?uint32_t cmd; ? ? ? ? ? ? // LC_DYSYMTAB > + ?uint32_t cmdsize; ? ? ? ? // sizeof(MachODySymTab) > + ?uint32_t ilocalsym; ? ? ? // index to local symbols > + ?uint32_t nlocalsym; ? ? ? // number of local symbols > + ?uint32_t iextdefsym; ? ? ?// index to externally defined symbols > + ?uint32_t nextdefsym; ? ? ?// number of externally defined symbols > + ?uint32_t iundefsym; ? ? ? // index to undefined symbols > + ?uint32_t nundefsym; ? ? ? // number of undefined symbols > + ?uint32_t tocoff; ? ? ? ? ?// file offset to table of contents > + ?uint32_t ntoc; ? ? ? ? ? ?// number of entries in table of contents > + ?uint32_t modtaboff; ? ? ? // file offset to module table > + ?uint32_t nmodtab; ? ? ? ? // number of module table entries > + ?uint32_t extrefsymoff; ? ?// offset to referenced symbol table > + ?uint32_t nextrefsyms; ? ? // number of referenced symbol table entries > + ?uint32_t indirectsymoff; ?// file offset to the indirect symbol table > + ?uint32_t nindirectsyms; ? // number of indirect symbol table entries > + ?uint32_t extreloff; ? ? ? // offset to external relocation entries > + ?uint32_t nextrel; ? ? ? ? // number of external relocation entries > + ?uint32_t locreloff; ? ? ? // offset to local relocation entries > + ?uint32_t nlocrel; ? ? ? ? // number of local relocation entries > + > + ?// Constants for the cmd field > + ?// see > + ?enum { LC_DYSYMTAB = 0x0B ?// dynamic link-edit symbol table info > + ?}; > + > + ?MachODySymTab() : cmd(LC_DYSYMTAB), cmdsize(20 * sizeof(uint32_t)), > + ? ?ilocalsym(0), nlocalsym(0), iextdefsym(0), nextdefsym(0), > + ? ?iundefsym(0), nundefsym(0), tocoff(0), ntoc(0), modtaboff(0), > + ? ?nmodtab(0), extrefsymoff(0), nextrefsyms(0), indirectsymoff(0), > + ? ?nindirectsyms(0), extreloff(0), nextrel(0), locreloff(0), nlocrel(0) { } > + > +}; // end struct MachODySymTab > > ?} // end namespace llvm > > > Modified: llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp Mon Jul ?6 00:09:34 2009 > @@ -16,6 +16,7 @@ > ?#include "llvm/Target/TargetAsmInfo.h" > ?#include "llvm/Support/Mangler.h" > ?#include "llvm/Support/OutputBuffer.h" > +#include > > ?//===----------------------------------------------------------------------===// > ?// ? ? ? ? ? ? ? ? ? ? ? MachOCodeEmitter Implementation > @@ -39,28 +40,18 @@ > ? // Get the Mach-O Section that this function belongs in. > ? MachOSection *MOS = MOW.getTextSection(); > > - ?// FIXME: better memory management > - ?MOS->SectionData.reserve(4096); > - ?BufferBegin = &MOS->SectionData[0]; > - ?BufferEnd = BufferBegin + MOS->SectionData.capacity(); > - > ? // Upgrade the section alignment if required. > ? if (MOS->align < Align) MOS->align = Align; > > - ?// Round the size up to the correct alignment for starting the new function. > - ?if ((MOS->size & ((1 << Align) - 1)) != 0) { > - ? ?MOS->size += (1 << Align); > - ? ?MOS->size &= ~((1 << Align) - 1); > - ?} > + ?MOS->emitAlignment(Align); > > - ?// FIXME: Using MOS->size directly here instead of calculating it from the > - ?// output buffer size (impossible because the code emitter deals only in raw > - ?// bytes) forces us to manually synchronize size and write padding zero bytes > - ?// to the output buffer for all non-text sections. ?For text sections, we do > - ?// not synchonize the output buffer, and we just blow up if anyone tries to > - ?// write non-code to it. ?An assert should probably be added to > - ?// AddSymbolToSection to prevent calling it on the text section. > - ?CurBufferPtr = BufferBegin + MOS->size; > + ?// Create symbol for function entry > + ?const GlobalValue *FuncV = MF.getFunction(); > + ?MachOSym FnSym(FuncV, MOW.Mang->getValueName(FuncV), MOS->Index, TAI); > + ?FnSym.n_value = getCurrentPCOffset(); > + > + ?// add it to the symtab. > + ?MOW.SymbolTable.push_back(FnSym); > ?} > > ?/// finishFunction - This callback is invoked after the function is completely > @@ -71,15 +62,6 @@ > ? // Get the Mach-O Section that this function belongs in. > ? MachOSection *MOS = MOW.getTextSection(); > > - ?// Get a symbol for the function to add to the symbol table > - ?// FIXME: it seems like we should call something like AddSymbolToSection > - ?// in startFunction rather than changing the section size and symbol n_value > - ?// here. > - ?const GlobalValue *FuncV = MF.getFunction(); > - ?MachOSym FnSym(FuncV, MOW.Mang->getValueName(FuncV), MOS->Index, TAI); > - ?FnSym.n_value = MOS->size; > - ?MOS->size = CurBufferPtr - BufferBegin; > - > ? // Emit constant pool to appropriate section(s) > ? emitConstantPool(MF.getConstantPool()); > > @@ -112,12 +94,9 @@ > ? ? } else { > ? ? ? assert(0 && "Unhandled relocation type"); > ? ? } > - ? ?MOS->Relocations.push_back(MR); > + ? ?MOS->addRelocation(MR); > ? } > ? Relocations.clear(); > - > - ?// Finally, add it to the symtab. > - ?MOW.SymbolTable.push_back(FnSym); > > ? // Clear per-function data structures. > ? CPLocations.clear(); > @@ -151,13 +130,10 @@ > ? ? unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); > > ? ? MachOSection *Sec = MOW.getConstSection(CP[i].Val.ConstVal); > - ? ?OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); > + ? ?OutputBuffer SecDataOut(Sec->getData(), is64Bit, isLittleEndian); > > - ? ?CPLocations.push_back(Sec->SectionData.size()); > + ? ?CPLocations.push_back(Sec->size()); > ? ? CPSections.push_back(Sec->Index); > - > - ? ?// FIXME: remove when we have unified size + output buffer > - ? ?Sec->size += Size; > > ? ? // Allocate space in the section for the global. > ? ? // FIXME: need alignment? > @@ -165,14 +141,12 @@ > ? ? for (unsigned j = 0; j < Size; ++j) > ? ? ? SecDataOut.outbyte(0); > > - ? ?MOW.InitMem(CP[i].Val.ConstVal, &Sec->SectionData[0], CPLocations[i], > - ? ? ? ? ? ? ? ?TM.getTargetData(), Sec->Relocations); > + ? ?MachOWriter::InitMem(CP[i].Val.ConstVal, CPLocations[i], TM.getTargetData(), Sec); > ? } > ?} > > ?/// emitJumpTables - Emit all the jump tables for a given jump table info > ?/// record to the appropriate section. > - > ?void MachOCodeEmitter::emitJumpTables(MachineJumpTableInfo *MJTI) { > ? const std::vector &JT = MJTI->getJumpTables(); > ? if (JT.empty()) return; > @@ -183,24 +157,21 @@ > > ? MachOSection *Sec = MOW.getJumpTableSection(); > ? unsigned TextSecIndex = MOW.getTextSection()->Index; > - ?OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); > + ?OutputBuffer SecDataOut(Sec->getData(), is64Bit, isLittleEndian); > > ? for (unsigned i = 0, e = JT.size(); i != e; ++i) { > ? ? // For each jump table, record its offset from the start of the section, > ? ? // reserve space for the relocations to the MBBs, and add the relocations. > ? ? const std::vector &MBBs = JT[i].MBBs; > - ? ?JTLocations.push_back(Sec->SectionData.size()); > + ? ?JTLocations.push_back(Sec->size()); > ? ? for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi) { > - ? ? ?MachineRelocation MR(MOW.GetJTRelocation(Sec->SectionData.size(), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MBBs[mi])); > + ? ? ?MachineRelocation MR(MOW.GetJTRelocation(Sec->size(), MBBs[mi])); > ? ? ? MR.setResultPointer((void *)JTLocations[i]); > ? ? ? MR.setConstantVal(TextSecIndex); > - ? ? ?Sec->Relocations.push_back(MR); > + ? ? ?Sec->addRelocation(MR); > ? ? ? SecDataOut.outaddr(0); > ? ? } > ? } > - ?// FIXME: remove when we have unified size + output buffer > - ?Sec->size = Sec->SectionData.size(); > ?} > > ?} // end namespace llvm > > Modified: llvm/trunk/lib/CodeGen/MachOCodeEmitter.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOCodeEmitter.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachOCodeEmitter.h (original) > +++ llvm/trunk/lib/CodeGen/MachOCodeEmitter.h Mon Jul ?6 00:09:34 2009 > @@ -11,15 +11,13 @@ > ?#define MACHOCODEEMITTER_H > > ?#include "MachOWriter.h" > -#include "llvm/CodeGen/MachineCodeEmitter.h" > -#include > > ?namespace llvm { > > ?/// MachOCodeEmitter - This class is used by the MachOWriter to emit the code > ?/// for functions to the Mach-O file. > > -class MachOCodeEmitter : public MachineCodeEmitter { > +class MachOCodeEmitter : public ObjectCodeEmitter { > ? MachOWriter &MOW; > > ? /// Target machine description. > @@ -34,27 +32,12 @@ > ? /// Relocations - These are the relocations that the function needs, as > ? /// emitted. > ? std::vector Relocations; > - > - ?/// CPLocations - This is a map of constant pool indices to offsets from the > - ?/// start of the section for that constant pool index. > - ?std::vector CPLocations; > - > - ?/// CPSections - This is a map of constant pool indices to the MachOSection > - ?/// containing the constant pool entry for that index. > - ?std::vector CPSections; > - > - ?/// JTLocations - This is a map of jump table indices to offsets from the > - ?/// start of the section for that jump table index. > - ?std::vector JTLocations; > - > - ?/// MBBLocations - This vector is a mapping from MBB ID's to their address. > - ?/// It is filled in by the StartMachineBasicBlock callback and queried by > - ?/// the getMachineBasicBlockAddress callback. > - ?std::vector MBBLocations; > - > + > + ?std::map Labels; > + > ?public: > - ?MachOCodeEmitter(MachOWriter &mow) : MOW(mow), TM(MOW.TM) > - ?{ > + ?MachOCodeEmitter(MachOWriter &mow, MachOSection &mos) : > + ? ? ? ?ObjectCodeEmitter(&mos), MOW(mow), TM(MOW.TM) { > ? ? is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; > ? ? isLittleEndian = TM.getTargetData()->isLittleEndian(); > ? ? TAI = TM.getTargetAsmInfo(); > @@ -69,58 +52,17 @@ > > ? void emitConstantPool(MachineConstantPool *MCP); > ? void emitJumpTables(MachineJumpTableInfo *MJTI); > - > - ?virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const { > - ? ?assert(CPLocations.size() > Index && "CP not emitted!"); > - ? ?return CPLocations[Index]; > - ?} > - ?virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const { > - ? ?assert(JTLocations.size() > Index && "JT not emitted!"); > - ? ?return JTLocations[Index]; > - ?} > - > - ?virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { > - ? ?if (MBBLocations.size() <= (unsigned)MBB->getNumber()) > - ? ? ?MBBLocations.resize((MBB->getNumber()+1)*2); > - ? ?MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); > - ?} > > - ?virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const { > - ? ?assert(MBBLocations.size() > (unsigned)MBB->getNumber() && > - ? ? ? ? ? MBBLocations[MBB->getNumber()] && "MBB not emitted!"); > - ? ?return MBBLocations[MBB->getNumber()]; > + ?virtual void emitLabel(uint64_t LabelID) { > + ? ?Labels[LabelID] = getCurrentPCOffset(); > ? } > > ? virtual uintptr_t getLabelAddress(uint64_t Label) const { > - ? ?assert(0 && "get Label not implemented"); > - ? ?abort(); > - ? ?return 0; > - ?} > - > - ?virtual void emitLabel(uint64_t LabelID) { > - ? ?assert(0 && "emit Label not implemented"); > - ? ?abort(); > + ? ?return Labels.find(Label)->second; > ? } > > ? virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) { } > > - ?/// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE! > - ?virtual void startGVStub(const GlobalValue* F, unsigned StubSize, > - ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Alignment = 1) { > - ? ?assert(0 && "JIT specific function called!"); > - ? ?abort(); > - ?} > - ?virtual void startGVStub(const GlobalValue* F, void *Buffer, > - ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned StubSize) { > - ? ?assert(0 && "JIT specific function called!"); > - ? ?abort(); > - ?} > - ?virtual void *finishGVStub(const GlobalValue* F) { > - ? ?assert(0 && "JIT specific function called!"); > - ? ?abort(); > - ? ?return 0; > - ?} > - > ?}; // end class MachOCodeEmitter > > ?} // end namespace llvm > > Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Mon Jul ?6 00:09:34 2009 > @@ -46,12 +46,12 @@ > > ?/// AddMachOWriter - Concrete function to add the Mach-O writer to the function > ?/// pass manager. > -MachineCodeEmitter *AddMachOWriter(PassManagerBase &PM, > +ObjectCodeEmitter *AddMachOWriter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?raw_ostream &O, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?TargetMachine &TM) { > ? MachOWriter *MOW = new MachOWriter(O, TM); > ? PM.add(MOW); > - ?return &MOW->getMachineCodeEmitter(); > + ?return MOW->getObjectCodeEmitter(); > ?} > > ?//===----------------------------------------------------------------------===// > @@ -60,8 +60,9 @@ > > ?char MachOWriter::ID = 0; > > -MachOWriter::MachOWriter(raw_ostream &o, TargetMachine &tm) > - ?: MachineFunctionPass(&ID), O(o), TM(tm) { > +MachOWriter::MachOWriter(raw_ostream &o, TargetMachine &tm) > + ?: MachineFunctionPass(&ID), O(o), TM(tm) > + ?{ > ? is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; > ? isLittleEndian = TM.getTargetData()->isLittleEndian(); > > @@ -69,11 +70,11 @@ > > ? // Create the machine code emitter object for this target. > > - ?MCE = new MachOCodeEmitter(*this); > + ?MachOCE = new MachOCodeEmitter(*this, *getTextSection(true)); > ?} > > ?MachOWriter::~MachOWriter() { > - ?delete MCE; > + ?delete MachOCE; > ?} > > ?bool MachOWriter::doInitialization(Module &M) { > @@ -97,13 +98,13 @@ > ?/// the Mach-O file to 'O'. > ?bool MachOWriter::doFinalization(Module &M) { > ? // FIXME: we don't handle debug info yet, we should probably do that. > - > - ?// Okay, the.text section has been completed, build the .data, .bss, and > + ?// Okay, the.text section has been completed, build the .data, .bss, and > ? // "common" sections next. > + > ? for (Module::global_iterator I = M.global_begin(), E = M.global_end(); > ? ? ? ?I != E; ++I) > ? ? EmitGlobal(I); > - > + > ? // Emit the header and load commands. > ? EmitHeaderAndLoadCommands(); > > @@ -133,38 +134,32 @@ > ? // Reserve space in the .bss section for this symbol while maintaining the > ? // desired section alignment, which must be at least as much as required by > ? // this symbol. > - ?OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); > + ?OutputBuffer SecDataOut(Sec->getData(), is64Bit, isLittleEndian); > > ? if (Align) { > - ? ?uint64_t OrigSize = Sec->size; > ? ? Align = Log2_32(Align); > ? ? Sec->align = std::max(unsigned(Sec->align), Align); > - ? ?Sec->size = (Sec->size + Align - 1) & ~(Align-1); > > - ? ?// Add alignment padding to buffer as well. > - ? ?// FIXME: remove when we have unified size + output buffer > - ? ?unsigned AlignedSize = Sec->size - OrigSize; > - ? ?for (unsigned i = 0; i < AlignedSize; ++i) > - ? ? ?SecDataOut.outbyte(0); > + ? ?Sec->emitAlignment(Sec->align); > ? } > ? // Globals without external linkage apparently do not go in the symbol table. > ? if (!GV->hasLocalLinkage()) { > ? ? MachOSym Sym(GV, Mang->getValueName(GV), Sec->Index, TAI); > - ? ?Sym.n_value = Sec->size; > + ? ?Sym.n_value = Sec->size(); > ? ? SymbolTable.push_back(Sym); > ? } > > ? // Record the offset of the symbol, and then allocate space for it. > ? // FIXME: remove when we have unified size + output buffer > - ?Sec->size += Size; > - > - ?// Now that we know what section the GlovalVariable is going to be emitted > + > + ?// Now that we know what section the GlovalVariable is going to be emitted > ? // into, update our mappings. > ? // FIXME: We may also need to update this when outputting non-GlobalVariable > ? // GlobalValues such as functions. > - ?GVSection[GV] = Sec; > - ?GVOffset[GV] = Sec->SectionData.size(); > > + ?GVSection[GV] = Sec; > + ?GVOffset[GV] = Sec->size(); > + > ? // Allocate space in the section for the global. > ? for (unsigned i = 0; i < Size; ++i) > ? ? SecDataOut.outbyte(0); > @@ -174,7 +169,7 @@ > ? const Type *Ty = GV->getType()->getElementType(); > ? unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); > ? bool NoInit = !GV->hasInitializer(); > - > + > ? // If this global has a zero initializer, it is part of the .bss or common > ? // section. > ? if (NoInit || GV->getInitializer()->isNullValue()) { > @@ -183,8 +178,7 @@ > ? ? // merged with other symbols. > ? ? if (NoInit || GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() || > ? ? ? ? GV->hasCommonLinkage()) { > - ? ? ?MachOSym ExtOrCommonSym(GV, Mang->getValueName(GV), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MachOSym::NO_SECT, TAI); > + ? ? ?MachOSym ExtOrCommonSym(GV, Mang->getValueName(GV), MachOSym::NO_SECT, TAI); > ? ? ? // For undefined (N_UNDF) external (N_EXT) types, n_value is the size in > ? ? ? // bytes of the symbol. > ? ? ? ExtOrCommonSym.n_value = Size; > @@ -198,15 +192,14 @@ > ? ? AddSymbolToSection(BSS, GV); > ? ? return; > ? } > - > + > ? // Scalar read-only data goes in a literal section if the scalar is 4, 8, or > ? // 16 bytes, or a cstring. ?Other read only data goes into a regular const > ? // section. ?Read-write data goes in the data section. > - ?MachOSection *Sec = GV->isConstant() ? getConstSection(GV->getInitializer()) : > + ?MachOSection *Sec = GV->isConstant() ? getConstSection(GV->getInitializer()) : > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?getDataSection(); > ? AddSymbolToSection(Sec, GV); > - ?InitMem(GV->getInitializer(), &Sec->SectionData[0], GVOffset[GV], > - ? ? ? ? ?TM.getTargetData(), Sec->Relocations); > + ?InitMem(GV->getInitializer(), GVOffset[GV], TM.getTargetData(), Sec); > ?} > > > @@ -214,21 +207,22 @@ > ?void MachOWriter::EmitHeaderAndLoadCommands() { > ? // Step #0: Fill in the segment load command size, since we need it to figure > ? // ? ? ? ? ?out the rest of the header fields > + > ? MachOSegment SEG("", is64Bit); > ? SEG.nsects ?= SectionList.size(); > - ?SEG.cmdsize = SEG.cmdSize(is64Bit) + > + ?SEG.cmdsize = SEG.cmdSize(is64Bit) + > ? ? ? ? ? ? ? ? SEG.nsects * SectionList[0]->cmdSize(is64Bit); > - > + > ? // Step #1: calculate the number of load commands. ?We always have at least > ? // ? ? ? ? ?one, for the LC_SEGMENT load command, plus two for the normal > ? // ? ? ? ? ?and dynamic symbol tables, if there are any symbols. > ? Header.ncmds = SymbolTable.empty() ? 1 : 3; > - > + > ? // Step #2: calculate the size of the load commands > ? Header.sizeofcmds = SEG.cmdsize; > ? if (!SymbolTable.empty()) > ? ? Header.sizeofcmds += SymTab.cmdsize + DySymTab.cmdsize; > - > + > ? // Step #3: write the header to the file > ? // Local alias to shortenify coming code. > ? DataBuffer &FH = Header.HeaderData; > @@ -243,15 +237,15 @@ > ? FHOut.outword(Header.flags); > ? if (is64Bit) > ? ? FHOut.outword(Header.reserved); > - > + > ? // Step #4: Finish filling in the segment load command and write it out > ? for (std::vector::iterator I = SectionList.begin(), > ? ? ? ? ?E = SectionList.end(); I != E; ++I) > - ? ?SEG.filesize += (*I)->size; > + ? ?SEG.filesize += (*I)->size(); > > ? SEG.vmsize = SEG.filesize; > ? SEG.fileoff = Header.cmdSize(is64Bit) + Header.sizeofcmds; > - > + > ? FHOut.outword(SEG.cmd); > ? FHOut.outword(SEG.cmdsize); > ? FHOut.outstring(SEG.segname, 16); > @@ -263,42 +257,42 @@ > ? FHOut.outword(SEG.initprot); > ? FHOut.outword(SEG.nsects); > ? FHOut.outword(SEG.flags); > - > - ?// Step #5: Finish filling in the fields of the MachOSections > + > + ?// Step #5: Finish filling in the fields of the MachOSections > ? uint64_t currentAddr = 0; > ? for (std::vector::iterator I = SectionList.begin(), > ? ? ? ? ?E = SectionList.end(); I != E; ++I) { > ? ? MachOSection *MOS = *I; > ? ? MOS->addr = currentAddr; > ? ? MOS->offset = currentAddr + SEG.fileoff; > - > ? ? // FIXME: do we need to do something with alignment here? > - ? ?currentAddr += MOS->size; > + ? ?currentAddr += MOS->size(); > ? } > - > + > ? // Step #6: Emit the symbol table to temporary buffers, so that we know the > ? // size of the string table when we write the next load command. ?This also > ? // sorts and assigns indices to each of the symbols, which is necessary for > ? // emitting relocations to externally-defined objects. > ? BufferSymbolAndStringTable(); > - > + > ? // Step #7: Calculate the number of relocations for each section and write out > ? // the section commands for each section > ? currentAddr += SEG.fileoff; > ? for (std::vector::iterator I = SectionList.begin(), > ? ? ? ? ?E = SectionList.end(); I != E; ++I) { > ? ? MachOSection *MOS = *I; > + > ? ? // Convert the relocations to target-specific relocations, and fill in the > ? ? // relocation offset for this section. > ? ? CalculateRelocations(*MOS); > ? ? MOS->reloff = MOS->nreloc ? currentAddr : 0; > ? ? currentAddr += MOS->nreloc * 8; > - > + > ? ? // write the finalized section command to the output buffer > ? ? FHOut.outstring(MOS->sectname, 16); > ? ? FHOut.outstring(MOS->segname, 16); > ? ? FHOut.outaddr(MOS->addr); > - ? ?FHOut.outaddr(MOS->size); > + ? ?FHOut.outaddr(MOS->size()); > ? ? FHOut.outword(MOS->offset); > ? ? FHOut.outword(MOS->align); > ? ? FHOut.outword(MOS->reloff); > @@ -309,7 +303,7 @@ > ? ? if (is64Bit) > ? ? ? FHOut.outword(MOS->reserved3); > ? } > - > + > ? // Step #8: Emit LC_SYMTAB/LC_DYSYMTAB load commands > ? SymTab.symoff ?= currentAddr; > ? SymTab.nsyms ? = SymbolTable.size(); > @@ -345,39 +339,40 @@ > ? FHOut.outword(DySymTab.nextrel); > ? FHOut.outword(DySymTab.locreloff); > ? FHOut.outword(DySymTab.nlocrel); > - > + > ? O.write((char*)&FH[0], FH.size()); > ?} > > ?/// EmitSections - Now that we have constructed the file header and load > ?/// commands, emit the data for each section to the file. > - > ?void MachOWriter::EmitSections() { > ? for (std::vector::iterator I = SectionList.begin(), > ? ? ? ? ?E = SectionList.end(); I != E; ++I) > ? ? // Emit the contents of each section > - ? ?O.write((char*)&(*I)->SectionData[0], (*I)->size); > + ? ?if ((*I)->size()) > + ? ? ?O.write((char*)&(*I)->getData()[0], (*I)->size()); > ?} > + > +/// EmitRelocations - emit relocation data from buffer. > ?void MachOWriter::EmitRelocations() { > ? for (std::vector::iterator I = SectionList.begin(), > ? ? ? ? ?E = SectionList.end(); I != E; ++I) > ? ? // Emit the relocation entry data for each section. > - ? ?O.write((char*)&(*I)->RelocBuffer[0], (*I)->RelocBuffer.size()); > + ? ?if ((*I)->RelocBuffer.size()) > + ? ? ?O.write((char*)&(*I)->RelocBuffer[0], (*I)->RelocBuffer.size()); > ?} > > ?/// BufferSymbolAndStringTable - Sort the symbols we encountered and assign them > ?/// each a string table index so that they appear in the correct order in the > ?/// output file. > - > ?void MachOWriter::BufferSymbolAndStringTable() { > ? // The order of the symbol table is: > ? // 1. local symbols > ? // 2. defined external symbols (sorted by name) > ? // 3. undefined external symbols (sorted by name) > - > + > ? // Before sorting the symbols, check the PendingGlobals for any undefined > ? // globals that need to be put in the symbol table. > - > ? for (std::vector::iterator I = PendingGlobals.begin(), > ? ? ? ? ?E = PendingGlobals.end(); I != E; ++I) { > ? ? if (GVOffset[*I] == 0 && GVSection[*I] == 0) { > @@ -389,19 +384,15 @@ > > ? // Sort the symbols by name, so that when we partition the symbols by scope > ? // of definition, we won't have to sort by name within each partition. > - > ? std::sort(SymbolTable.begin(), SymbolTable.end(), MachOSym::SymCmp()); > > - ?// Parition the symbol table entries so that all local symbols come before > + ?// Parition the symbol table entries so that all local symbols come before > ? // all symbols with external linkage. { 1 | 2 3 } > - > - ?std::partition(SymbolTable.begin(), SymbolTable.end(), > - ? ? ? ? ? ? ? ? MachOSym::PartitionByLocal); > - > + ?std::partition(SymbolTable.begin(), SymbolTable.end(), MachOSym::PartitionByLocal); > + > ? // Advance iterator to beginning of external symbols and partition so that > ? // all external symbols defined in this module come before all external > ? // symbols defined elsewhere. { 1 | 2 | 3 } > - > ? for (std::vector::iterator I = SymbolTable.begin(), > ? ? ? ? ?E = SymbolTable.end(); I != E; ++I) { > ? ? if (!MachOSym::PartitionByLocal(*I)) { > @@ -410,10 +401,9 @@ > ? ? } > ? } > > - ?// Calculate the starting index for each of the local, extern defined, and > + ?// Calculate the starting index for each of the local, extern defined, and > ? // undefined symbols, as well as the number of each to put in the LC_DYSYMTAB > ? // load command. > - > ? for (std::vector::iterator I = SymbolTable.begin(), > ? ? ? ? ?E = SymbolTable.end(); I != E; ++I) { > ? ? if (MachOSym::PartitionByLocal(*I)) { > @@ -427,10 +417,9 @@ > ? ? ? ++DySymTab.nundefsym; > ? ? } > ? } > - > + > ? // Write out a leading zero byte when emitting string table, for n_strx == 0 > ? // which means an empty string. > - > ? OutputBuffer StrTOut(StrT, is64Bit, isLittleEndian); > ? StrTOut.outbyte(0); > > @@ -439,7 +428,6 @@ > ? // 2. strings for local symbols > ? // Since this is the opposite order from the symbol table, which we have just > ? // sorted, we can walk the symbol table backwards to output the string table. > - > ? for (std::vector::reverse_iterator I = SymbolTable.rbegin(), > ? ? ? ? E = SymbolTable.rend(); I != E; ++I) { > ? ? if (I->GVName == "") { > @@ -463,7 +451,7 @@ > ? ? ? I->n_value += GVSection[GV]->addr; > ? ? if (GV && (GVOffset[GV] == -1)) > ? ? ? GVOffset[GV] = index; > - > + > ? ? // Emit nlist to buffer > ? ? SymTOut.outword(I->n_strx); > ? ? SymTOut.outbyte(I->n_type); > @@ -478,32 +466,29 @@ > ?/// and the offset into that section. ?From this information, create the > ?/// appropriate target-specific MachORelocation type and add buffer it to be > ?/// written out after we are finished writing out sections. > - > ?void MachOWriter::CalculateRelocations(MachOSection &MOS) { > - ?for (unsigned i = 0, e = MOS.Relocations.size(); i != e; ++i) { > - ? ?MachineRelocation &MR = MOS.Relocations[i]; > + ?std::vector Relocations = ?MOS.getRelocations(); > + ?for (unsigned i = 0, e = Relocations.size(); i != e; ++i) { > + ? ?MachineRelocation &MR = Relocations[i]; > ? ? unsigned TargetSection = MR.getConstantVal(); > ? ? unsigned TargetAddr = 0; > ? ? unsigned TargetIndex = 0; > > ? ? // This is a scattered relocation entry if it points to a global value with > ? ? // a non-zero offset. > - > ? ? bool Scattered = false; > ? ? bool Extern = false; > > ? ? // Since we may not have seen the GlobalValue we were interested in yet at > ? ? // the time we emitted the relocation for it, fix it up now so that it > ? ? // points to the offset into the correct section. > - > ? ? if (MR.isGlobalValue()) { > ? ? ? GlobalValue *GV = MR.getGlobalValue(); > ? ? ? MachOSection *MOSPtr = GVSection[GV]; > ? ? ? intptr_t Offset = GVOffset[GV]; > - > + > ? ? ? // If we have never seen the global before, it must be to a symbol > ? ? ? // defined in another module (N_UNDF). > - > ? ? ? if (!MOSPtr) { > ? ? ? ? // FIXME: need to append stub suffix > ? ? ? ? Extern = true; > @@ -515,10 +500,9 @@ > ? ? ? } > ? ? ? MR.setResultPointer((void*)Offset); > ? ? } > - > + > ? ? // If the symbol is locally defined, pass in the address of the section and > ? ? // the section index to the code which will generate the target relocation. > - > ? ? if (!Extern) { > ? ? ? ? MachOSection &To = *SectionList[TargetSection - 1]; > ? ? ? ? TargetAddr = To.addr; > @@ -526,7 +510,7 @@ > ? ? } > > ? ? OutputBuffer RelocOut(MOS.RelocBuffer, is64Bit, isLittleEndian); > - ? ?OutputBuffer SecOut(MOS.SectionData, is64Bit, isLittleEndian); > + ? ?OutputBuffer SecOut(MOS.getData(), is64Bit, isLittleEndian); > > ? ? MOS.nreloc += GetTargetRelocation(MR, MOS.Index, TargetAddr, TargetIndex, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? RelocOut, SecOut, Scattered, Extern); > @@ -535,22 +519,21 @@ > > ?// InitMem - Write the value of a Constant to the specified memory location, > ?// converting it into bytes and relocations. > - > -void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, > - ? ? ? ? ? ? ? ? ? ? ? ? ?const TargetData *TD, > - ? ? ? ? ? ? ? ? ? ? ? ? ?std::vector &MRs) { > +void MachOWriter::InitMem(const Constant *C, uintptr_t Offset, > + ? ? ? ? ? ? ? ? ? ? ? ? ?const TargetData *TD, MachOSection* mos) { > ? typedef std::pair CPair; > ? std::vector WorkList; > - > + ?uint8_t *Addr = &mos->getData()[0]; > + > ? WorkList.push_back(CPair(C,(intptr_t)Addr + Offset)); > - > + > ? intptr_t ScatteredOffset = 0; > - > + > ? while (!WorkList.empty()) { > ? ? const Constant *PC = WorkList.back().first; > ? ? intptr_t PA = WorkList.back().second; > ? ? WorkList.pop_back(); > - > + > ? ? if (isa(PC)) { > ? ? ? continue; > ? ? } else if (const ConstantVector *CP = dyn_cast(PC)) { > @@ -643,7 +626,7 @@ > ? ? ? ? ? memset(ptr, 0, TD->getPointerSize()); > ? ? ? ? else if (const GlobalValue* GV = dyn_cast(PC)) { > ? ? ? ? ? // FIXME: what about function stubs? > - ? ? ? ? ?MRs.push_back(MachineRelocation::getGV(PA-(intptr_t)Addr, > + ? ? ? ? ?mos->addRelocation(MachineRelocation::getGV(PA-(intptr_t)Addr, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MachineRelocation::VANILLA, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const_cast(GV), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ScatteredOffset)); > > Modified: llvm/trunk/lib/CodeGen/MachOWriter.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachOWriter.h (original) > +++ llvm/trunk/lib/CodeGen/MachOWriter.h Mon Jul ?6 00:09:34 2009 > @@ -15,17 +15,24 @@ > ?#define MACHOWRITER_H > > ?#include "MachO.h" > +#include "llvm/Constants.h" > +#include "llvm/DerivedTypes.h" > ?#include "llvm/CodeGen/MachineFunctionPass.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > ?#include "llvm/Target/TargetData.h" > ?#include "llvm/Target/TargetMachine.h" > ?#include "llvm/Target/TargetMachOWriterInfo.h" > +#include > ?#include > > ?namespace llvm { > ? class GlobalVariable; > ? class Mangler; > - ?class MachineCodeEmitter; > + ?class MachineRelocation; > + ?class ObjectCodeEmitter; > ? class MachOCodeEmitter; > + ?class TargetData; > + ?class TargetMachine; > ? class OutputBuffer; > ? class raw_ostream; > > @@ -38,8 +45,9 @@ > ? ? friend class MachOCodeEmitter; > ? public: > ? ? static char ID; > - ? ?MachineCodeEmitter &getMachineCodeEmitter() const { > - ? ? ?return *(MachineCodeEmitter*)MCE; > + > + ? ?ObjectCodeEmitter *getObjectCodeEmitter() { > + ? ? ?return reinterpret_cast(MachOCE); > ? ? } > > ? ? MachOWriter(raw_ostream &O, TargetMachine &TM); > @@ -62,10 +70,10 @@ > ? ? /// > ? ? Mangler *Mang; > > - ? ?/// MCE - The MachineCodeEmitter object that we are exposing to emit machine > + ? ?/// MachOCE - The MachineCodeEmitter object that we are exposing to emit machine > ? ? /// code for functions to the .o file. > > - ? ?MachOCodeEmitter *MCE; > + ? ?MachOCodeEmitter *MachOCE; > > ? ? /// is64Bit/isLittleEndian - This information is inferred from the target > ? ? /// machine directly, indicating what header values and flags to set. > @@ -225,9 +233,10 @@ > ? ? /// SymbolTable to aid in emitting the DYSYMTAB load command. > ? ? std::vector DynamicSymbolTable; > > - ? ?static void InitMem(const Constant *C, void *Addr, intptr_t Offset, > + ? ?static void InitMem(const Constant *C, > + ? ? ? ? ? ? ? ? ? ? ? ?uintptr_t Offset, > ? ? ? ? ? ? ? ? ? ? ? ? const TargetData *TD, > - ? ? ? ? ? ? ? ? ? ? ? ?std::vector &MRs); > + ? ? ? ? ? ? ? ? ? ? ? ?MachOSection* mos); > > ? private: > ? ? void AddSymbolToSection(MachOSection *MOS, GlobalVariable *GV); > > Modified: llvm/trunk/lib/Target/ARM/ARM.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARM.h (original) > +++ llvm/trunk/lib/Target/ARM/ARM.h Mon Jul ?6 00:09:34 2009 > @@ -24,6 +24,7 @@ > ?class FunctionPass; > ?class MachineCodeEmitter; > ?class JITCodeEmitter; > +class ObjectCodeEmitter; > ?class raw_ostream; > > ?// Enums corresponding to ARM condition codes > @@ -101,6 +102,8 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MachineCodeEmitter &MCE); > ?FunctionPass *createARMJITCodeEmitterPass(ARMBaseTargetMachine &TM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter &JCE); > +FunctionPass *createARMObjectCodeEmitterPass(ARMBaseTargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter &OCE); > > ?FunctionPass *createARMLoadStoreOptimizationPass(bool PreAlloc = false); > ?FunctionPass *createARMConstantIslandPass(); > > Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Mon Jul ?6 00:09:34 2009 > @@ -26,6 +26,7 @@ > ?#include "llvm/PassManager.h" > ?#include "llvm/CodeGen/MachineCodeEmitter.h" > ?#include "llvm/CodeGen/JITCodeEmitter.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > ?#include "llvm/CodeGen/MachineConstantPool.h" > ?#include "llvm/CodeGen/MachineFunctionPass.h" > ?#include "llvm/CodeGen/MachineInstr.h" > @@ -174,18 +175,18 @@ > ?/// createARMCodeEmitterPass - Return a pass that emits the collected ARM code > ?/// to the specified MCE object. > > -namespace llvm { > - > -FunctionPass *createARMCodeEmitterPass(ARMBaseTargetMachine &TM, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MachineCodeEmitter &MCE) { > +FunctionPass *llvm::createARMCodeEmitterPass(ARMBaseTargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MachineCodeEmitter &MCE) { > ? return new Emitter(TM, MCE); > ?} > -FunctionPass *createARMJITCodeEmitterPass(ARMBaseTargetMachine &TM, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?JITCodeEmitter &JCE) { > +FunctionPass *llvm::createARMJITCodeEmitterPass(ARMBaseTargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?JITCodeEmitter &JCE) { > ? return new Emitter(TM, JCE); > ?} > - > -} // end namespace llvm > +FunctionPass *llvm::createARMObjectCodeEmitterPass(ARMBaseTargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter &OCE) { > + ?return new Emitter(TM, OCE); > +} > > ?template > ?bool Emitter::runOnMachineFunction(MachineFunction &MF) { > > Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Mon Jul ?6 00:09:34 2009 > @@ -228,6 +228,25 @@ > ? return false; > ?} > > +bool ARMBaseTargetMachine::addCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ObjectCodeEmitter &OCE) { > + ?// FIXME: Move this to TargetJITInfo! > + ?if (DefRelocModel == Reloc::Default) > + ? ?setRelocationModel(Reloc::Static); > + > + ?// Machine code emitter pass for ARM. > + ?PM.add(createARMObjectCodeEmitterPass(*this, OCE)); > + ?if (DumpAsm) { > + ? ?assert(AsmPrinterCtor && "AsmPrinter was not linked in"); > + ? ?if (AsmPrinterCtor) > + ? ? ?PM.add(AsmPrinterCtor(errs(), *this, true)); > + ?} > + > + ?return false; > +} > + > ?bool ARMBaseTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, > @@ -258,4 +277,18 @@ > ? return false; > ?} > > +bool ARMBaseTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ObjectCodeEmitter &OCE) { > + ?// Machine code emitter pass for ARM. > + ?PM.add(createARMObjectCodeEmitterPass(*this, OCE)); > + ?if (DumpAsm) { > + ? ?assert(AsmPrinterCtor && "AsmPrinter was not linked in"); > + ? ?if (AsmPrinterCtor) > + ? ? ?PM.add(AsmPrinterCtor(errs(), *this, true)); > + ?} > + > + ?return false; > +} > > > Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.h (original) > +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.h Mon Jul ?6 00:09:34 2009 > @@ -77,6 +77,8 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, MachineCodeEmitter &MCE); > ? virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, JITCodeEmitter &MCE); > + ?virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, ObjectCodeEmitter &OCE); > ? virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, > @@ -85,6 +87,10 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter &MCE); > + ?virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ObjectCodeEmitter &OCE); > ?}; > > ?/// ARMTargetMachine - ARM target machine. > > Modified: llvm/trunk/lib/Target/Alpha/Alpha.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/Alpha.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/Alpha/Alpha.h (original) > +++ llvm/trunk/lib/Target/Alpha/Alpha.h Mon Jul ?6 00:09:34 2009 > @@ -22,6 +22,7 @@ > ? class AlphaTargetMachine; > ? class FunctionPass; > ? class MachineCodeEmitter; > + ?class ObjectCodeEmitter; > ? class raw_ostream; > > ? FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM); > @@ -32,7 +33,9 @@ > ? FunctionPass *createAlphaCodeEmitterPass(AlphaTargetMachine &TM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MachineCodeEmitter &MCE); > ? FunctionPass *createAlphaJITCodeEmitterPass(AlphaTargetMachine &TM, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter &JCE); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?JITCodeEmitter &JCE); > + ?FunctionPass *createAlphaObjectCodeEmitterPass(AlphaTargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter &OCE); > ? FunctionPass *createAlphaLLRPPass(AlphaTargetMachine &tm); > ? FunctionPass *createAlphaBranchSelectionPass(); > > > Modified: llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp (original) > +++ llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp Mon Jul ?6 00:09:34 2009 > @@ -19,6 +19,7 @@ > ?#include "llvm/PassManager.h" > ?#include "llvm/CodeGen/MachineCodeEmitter.h" > ?#include "llvm/CodeGen/JITCodeEmitter.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > ?#include "llvm/CodeGen/MachineFunctionPass.h" > ?#include "llvm/CodeGen/MachineInstr.h" > ?#include "llvm/CodeGen/Passes.h" > @@ -91,6 +92,10 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter &JCE) { > ? return new Emitter(TM, JCE); > ?} > +FunctionPass *llvm::createAlphaObjectCodeEmitterPass(AlphaTargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter &OCE) { > + ?return new Emitter(TM, OCE); > +} > > ?template > ?bool Emitter::runOnMachineFunction(MachineFunction &MF) { > > Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp (original) > +++ llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp Mon Jul ?6 00:09:34 2009 > @@ -119,6 +119,17 @@ > ? } > ? return false; > ?} > +bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, ObjectCodeEmitter &OCE) { > + ?PM.add(createAlphaObjectCodeEmitterPass(*this, OCE)); > + ?if (DumpAsm) { > + ? ?assert(AsmPrinterCtor && "AsmPrinter was not linked in"); > + ? ?if (AsmPrinterCtor) > + ? ? ?PM.add(AsmPrinterCtor(errs(), *this, true)); > + ?} > + ?return false; > +} > ?bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, > @@ -131,4 +142,10 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter &JCE) { > ? return addCodeEmitter(PM, OptLevel, DumpAsm, JCE); > ?} > +bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ObjectCodeEmitter &OCE) { > + ?return addCodeEmitter(PM, OptLevel, DumpAsm, OCE); > +} > > > Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h (original) > +++ llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h Mon Jul ?6 00:09:34 2009 > @@ -74,6 +74,8 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, MachineCodeEmitter &MCE); > ? virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, JITCodeEmitter &JCE); > + ?virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, ObjectCodeEmitter &JCE); > ? virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, > @@ -82,6 +84,10 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter &JCE); > + ?virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ObjectCodeEmitter &OCE); > > ? static void registerAsmPrinter(AsmPrinterCtorFn F) { > ? ? AsmPrinterCtor = F; > > Modified: llvm/trunk/lib/Target/PowerPC/PPC.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPC.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PowerPC/PPC.h (original) > +++ llvm/trunk/lib/Target/PowerPC/PPC.h Mon Jul ?6 00:09:34 2009 > @@ -24,6 +24,7 @@ > ? class PPCTargetMachine; > ? class FunctionPass; > ? class MachineCodeEmitter; > + ?class ObjectCodeEmitter; > ? class raw_ostream; > > ?FunctionPass *createPPCBranchSelectionPass(); > @@ -33,7 +34,9 @@ > ?FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MachineCodeEmitter &MCE); > ?FunctionPass *createPPCJITCodeEmitterPass(PPCTargetMachine &TM, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter &MCE); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?JITCodeEmitter &MCE); > +FunctionPass *createPPCObjectCodeEmitterPass(PPCTargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter &OCE); > ?} // end namespace llvm; > > ?// Defines symbolic names for PowerPC registers. ?This defines a mapping from > > Modified: llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp (original) > +++ llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp Mon Jul ?6 00:09:34 2009 > @@ -19,6 +19,7 @@ > ?#include "llvm/PassManager.h" > ?#include "llvm/CodeGen/MachineCodeEmitter.h" > ?#include "llvm/CodeGen/JITCodeEmitter.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > ?#include "llvm/CodeGen/MachineFunctionPass.h" > ?#include "llvm/CodeGen/MachineInstrBuilder.h" > ?#include "llvm/CodeGen/MachineModuleInfo.h" > @@ -91,6 +92,7 @@ > > ?/// createPPCCodeEmitterPass - Return a pass that emits the collected PPC code > ?/// to the specified MCE object. > + > ?FunctionPass *llvm::createPPCCodeEmitterPass(PPCTargetMachine &TM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MachineCodeEmitter &MCE) { > ? return new Emitter(TM, MCE); > @@ -101,6 +103,11 @@ > ? return new Emitter(TM, JCE); > ?} > > +FunctionPass *llvm::createPPCObjectCodeEmitterPass(PPCTargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter &OCE) { > + ?return new Emitter(TM, OCE); > +} > + > ?template > ?bool Emitter::runOnMachineFunction(MachineFunction &MF) { > ? assert((MF.getTarget().getRelocationModel() != Reloc::Default || > @@ -252,6 +259,7 @@ > ? ? ? Reloc = PPC::reloc_pcrel_bx; > ? ? else // BCC instruction > ? ? ? Reloc = PPC::reloc_pcrel_bcx; > + > ? ? MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Reloc, MO.getMBB())); > ? } else { > > Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp (original) > +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp Mon Jul ?6 00:09:34 2009 > @@ -221,6 +221,38 @@ > ? return false; > ?} > > +bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, ObjectCodeEmitter &OCE) { > + ?// The JIT should use the static relocation model in ppc32 mode, PIC in ppc64. > + ?// FIXME: This should be moved to TargetJITInfo!! > + ?if (Subtarget.isPPC64()) { > + ? ?// We use PIC codegen in ppc64 mode, because otherwise we'd have to use many > + ? ?// instructions to materialize arbitrary global variable + function + > + ? ?// constant pool addresses. > + ? ?setRelocationModel(Reloc::PIC_); > + ? ?// Temporary workaround for the inability of PPC64 JIT to handle jump > + ? ?// tables. > + ? ?DisableJumpTables = true; > + ?} else { > + ? ?setRelocationModel(Reloc::Static); > + ?} > + > + ?// Inform the subtarget that we are in JIT mode. ?FIXME: does this break macho > + ?// writing? > + ?Subtarget.SetJITMode(); > + > + ?// Machine code emitter pass for PowerPC. > + ?PM.add(createPPCObjectCodeEmitterPass(*this, OCE)); > + ?if (DumpAsm) { > + ? ?assert(AsmPrinterCtor && "AsmPrinter was not linked in"); > + ? ?if (AsmPrinterCtor) > + ? ? ?PM.add(AsmPrinterCtor(errs(), *this, true)); > + ?} > + > + ?return false; > +} > + > ?bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, > @@ -251,3 +283,19 @@ > ? return false; > ?} > > +bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ObjectCodeEmitter &OCE) { > + ?// Machine code emitter pass for PowerPC. > + ?PM.add(createPPCObjectCodeEmitterPass(*this, OCE)); > + ?if (DumpAsm) { > + ? ?assert(AsmPrinterCtor && "AsmPrinter was not linked in"); > + ? ?if (AsmPrinterCtor) > + ? ? ?PM.add(AsmPrinterCtor(errs(), *this, true)); > + ?} > + > + ?return false; > +} > + > + > > Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h (original) > +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h Mon Jul ?6 00:09:34 2009 > @@ -85,12 +85,17 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, MachineCodeEmitter &MCE); > ? virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, JITCodeEmitter &JCE); > + ?virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, ObjectCodeEmitter &OCE); > ? virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, MachineCodeEmitter &MCE); > ? virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, JITCodeEmitter &JCE); > + ?virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, ObjectCodeEmitter &OCE); > ? virtual bool getEnableTailMergeDefault() const; > ?}; > > > Modified: llvm/trunk/lib/Target/X86/X86.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86.h (original) > +++ llvm/trunk/lib/Target/X86/X86.h Mon Jul ?6 00:09:34 2009 > @@ -56,6 +56,8 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MachineCodeEmitter &MCE); > ?FunctionPass *createX86JITCodeEmitterPass(X86TargetMachine &TM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JITCodeEmitter &JCE); > +FunctionPass *createX86ObjectCodeEmitterPass(X86TargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter &OCE); > > ?/// createX86EmitCodeToMemory - Returns a pass that converts a register > ?/// allocated function into raw machine code in a dynamically > > Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Mon Jul ?6 00:09:34 2009 > @@ -22,6 +22,7 @@ > ?#include "llvm/PassManager.h" > ?#include "llvm/CodeGen/MachineCodeEmitter.h" > ?#include "llvm/CodeGen/JITCodeEmitter.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > ?#include "llvm/CodeGen/MachineFunctionPass.h" > ?#include "llvm/CodeGen/MachineInstr.h" > ?#include "llvm/CodeGen/MachineModuleInfo.h" > @@ -106,18 +107,18 @@ > ?/// createX86CodeEmitterPass - Return a pass that emits the collected X86 code > ?/// to the specified templated MachineCodeEmitter object. > > -namespace llvm { > - > -FunctionPass *createX86CodeEmitterPass(X86TargetMachine &TM, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MachineCodeEmitter &MCE) { > +FunctionPass *llvm::createX86CodeEmitterPass(X86TargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MachineCodeEmitter &MCE) { > ? return new Emitter(TM, MCE); > ?} > -FunctionPass *createX86JITCodeEmitterPass(X86TargetMachine &TM, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?JITCodeEmitter &JCE) { > +FunctionPass *llvm::createX86JITCodeEmitterPass(X86TargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?JITCodeEmitter &JCE) { > ? return new Emitter(TM, JCE); > ?} > - > -} // end namespace llvm > +FunctionPass *llvm::createX86ObjectCodeEmitterPass(X86TargetMachine &TM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter &OCE) { > + ?return new Emitter(TM, OCE); > +} > > ?template > ?bool Emitter::runOnMachineFunction(MachineFunction &MF) { > > Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Mon Jul ?6 00:09:34 2009 > @@ -290,6 +290,36 @@ > ? return false; > ?} > > +bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ObjectCodeEmitter &OCE) { > + ?// FIXME: Move this to TargetJITInfo! > + ?// On Darwin, do not override 64-bit setting made in X86TargetMachine(). > + ?if (DefRelocModel == Reloc::Default && > + ? ? ? ?(!Subtarget.isTargetDarwin() || !Subtarget.is64Bit())) > + ? ?setRelocationModel(Reloc::Static); > + > + ?// 64-bit JIT places everything in the same buffer except external functions. > + ?// On Darwin, use small code model but hack the call instruction for > + ?// externals. ?Elsewhere, do not assume globals are in the lower 4G. > + ?if (Subtarget.is64Bit()) { > + ? ?if (Subtarget.isTargetDarwin()) > + ? ? ?setCodeModel(CodeModel::Small); > + ? ?else > + ? ? ?setCodeModel(CodeModel::Large); > + ?} > + > + ?PM.add(createX86ObjectCodeEmitterPass(*this, OCE)); > + ?if (DumpAsm) { > + ? ?assert(AsmPrinterCtor && "AsmPrinter was not linked in"); > + ? ?if (AsmPrinterCtor) > + ? ? ?PM.add(AsmPrinterCtor(errs(), *this, true)); > + ?} > + > + ?return false; > +} > + > ?bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, > @@ -318,3 +348,16 @@ > ? return false; > ?} > > +bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ObjectCodeEmitter &OCE) { > + ?PM.add(createX86ObjectCodeEmitterPass(*this, OCE)); > + ?if (DumpAsm) { > + ? ?assert(AsmPrinterCtor && "AsmPrinter was not linked in"); > + ? ?if (AsmPrinterCtor) > + ? ? ?PM.add(AsmPrinterCtor(errs(), *this, true)); > + ?} > + > + ?return false; > +} > > Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.h?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86TargetMachine.h (original) > +++ llvm/trunk/lib/Target/X86/X86TargetMachine.h Mon Jul ?6 00:09:34 2009 > @@ -84,12 +84,17 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, MachineCodeEmitter &MCE); > ? virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, JITCodeEmitter &JCE); > + ?virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, ObjectCodeEmitter &OCE); > ? virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, MachineCodeEmitter &MCE); > ? virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CodeGenOpt::Level OptLevel, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool DumpAsm, JITCodeEmitter &JCE); > + ?virtual bool addSimpleCodeEmitter(PassManagerBase &PM, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Level OptLevel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool DumpAsm, ObjectCodeEmitter &OCE); > ?}; > > ?/// X86_32TargetMachine - X86 32-bit target machine. > > Modified: llvm/trunk/tools/llc/llc.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/tools/llc/llc.cpp (original) > +++ llvm/trunk/tools/llc/llc.cpp Mon Jul ?6 00:09:34 2009 > @@ -17,6 +17,7 @@ > ?#include "llvm/CodeGen/FileWriters.h" > ?#include "llvm/CodeGen/LinkAllCodegenComponents.h" > ?#include "llvm/CodeGen/LinkAllAsmWriterComponents.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > ?#include "llvm/Target/SubtargetFeature.h" > ?#include "llvm/Target/TargetData.h" > ?#include "llvm/Target/TargetMachine.h" > @@ -312,7 +313,7 @@ > ?#endif > > ? ? // Ask the target to add backend passes as necessary. > - ? ?MachineCodeEmitter *MCE = 0; > + ? ?ObjectCodeEmitter *OCE = 0; > > ? ? // Override default to generate verbose assembly. > ? ? Target.setAsmVerbosityDefault(true); > @@ -331,14 +332,14 @@ > ? ? case FileModel::AsmFile: > ? ? ? break; > ? ? case FileModel::MachOFile: > - ? ? ?MCE = AddMachOWriter(Passes, *Out, Target); > + ? ? ?OCE = AddMachOWriter(Passes, *Out, Target); > ? ? ? break; > ? ? case FileModel::ElfFile: > - ? ? ?MCE = AddELFWriter(Passes, *Out, Target); > + ? ? ?OCE = AddELFWriter(Passes, *Out, Target); > ? ? ? break; > ? ? } > > - ? ?if (Target.addPassesToEmitFileFinish(Passes, MCE, OLvl)) { > + ? ?if (Target.addPassesToEmitFileFinish(Passes, OCE, OLvl)) { > ? ? ? std::cerr << argv[0] << ": target does not support generation of this" > ? ? ? ? ? ? ? ? << " file type!\n"; > ? ? ? if (Out != &outs()) delete Out; > > Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=74813&r1=74812&r2=74813&view=diff > > ============================================================================== > --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) > +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon Jul ?6 00:09:34 2009 > @@ -430,16 +430,16 @@ > > ? ? codeGenPasses->add(new TargetData(*_target->getTargetData())); > > - ? ?MachineCodeEmitter* mce = NULL; > + ? ?ObjectCodeEmitter* oce = NULL; > > ? ? switch (_target->addPassesToEmitFile(*codeGenPasses, out, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?TargetMachine::AssemblyFile, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Aggressive)) { > ? ? ? ? case FileModel::MachOFile: > - ? ? ? ? ? ?mce = AddMachOWriter(*codeGenPasses, out, *_target); > + ? ? ? ? ? ?oce = AddMachOWriter(*codeGenPasses, out, *_target); > ? ? ? ? ? ? break; > ? ? ? ? case FileModel::ElfFile: > - ? ? ? ? ? ?mce = AddELFWriter(*codeGenPasses, out, *_target); > + ? ? ? ? ? ?oce = AddELFWriter(*codeGenPasses, out, *_target); > ? ? ? ? ? ? break; > ? ? ? ? case FileModel::AsmFile: > ? ? ? ? ? ? break; > @@ -449,7 +449,7 @@ > ? ? ? ? ? ? return true; > ? ? } > > - ? ?if (_target->addPassesToEmitFileFinish(*codeGenPasses, mce, > + ? ?if (_target->addPassesToEmitFileFinish(*codeGenPasses, oce, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CodeGenOpt::Aggressive)) { > ? ? ? ? errMsg = "target does not support generation of this file type"; > ? ? ? ? return true; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- Bruno Cardoso Lopes http://www.brunocardoso.cc -------------- next part -------------- This MachO-DOE patch introduces the ObjectCodeEmitter and BinaryObject classes and adds ObejectCodeEmitter to the code emitters, intermediate and llc, and LTO code. This demonstrates and tests the ObjectCodeEmitter and BinaryObject classes, but stubs the ELFWritter and makes it useless until updated to use this prototype DOE framework. I added label support to the MachOWriter in the process and am getting semi encoraging results in its output. * include/llvm/Target/TargetMachine.h class TargetMachine - added addPassesToEmitFileFinish() for ObjectCodeEmitter class LLVMTargetMachine - addPassesToEmitFileFinish() for ObjectCodeEmitter - addSimpleCodeEmitter() for ObjectCodeEmitter * include/llvm/CodeGen/FileWriters.h - change AddMachOWriter() to return an ObjectCodeEmitter - change AddELFWriter() to return an ObjectCodeEmitter * include/llvm/CodeGen/MachineCodeEmitter.h - removed GVStub methods - made MachineCodeEmitter::getCurrentPCOffset() virtual * include/llvm/CodeGen/ObjectCodeEmitter.h - new file * include/llvm/CodeGen/BinaryObject.h - removed unnecessary unsigned casts - added reserveBytes() method - added Alignment filler byte value * lib/CodeGen/LLVMTargetMachine.cpp - added LLVMTargetMachine::addPassesToEmitFileFinish() * lib/CodeGen/ELFWriter.cpp - kludge to cast and converted AddELFWriter to return ObjectCodeEmitter * lib/CodeGen/MachO.h * lib/CodeGen/MachOCodeEmitter.h * lib/CodeGen/MachOCodeEmitter.cpp * lib/CodeGen/MachOWriter.h * lib/CodeGen/MachOWriter.cpp - converted to use ObjectCodeEmitter - made getObjectCodeEmitter() return a pointer * lib/Target/X86/X86.h * lib/Target/X86/X86CodeEmitter.cpp - added createX86ObjectCodeEmitterPass() * lib/Target/X86/X86TargetMachine.h * lib/Target/X86/X86TargetMachine.cpp - added X86TargetMachine::addCodeEmitter() - added X86TargetMachine::addSimpleCodeEmitter() * lib/Target/PowerPC/PPC.h * lib/Target/PowerPC/PPCCodeEmitter.cpp - added createPPCObjectCodeEmitterPass() * lib/Target/PowerPC/PPCTargetMachine.h * lib/Target/PowerPC/PPCTargetMachine.cpp - added PPCTargetMachine::addCodeEmitter() - added PPCTargetMachine::addSimpleCodeEmitter() * lib/Target/ARM/ARM.h * lib/Target/ARM/ARMCodeEmitter.cpp - added createARMObjectCodeEmitterPass() * lib/Target/ARM/ARMTargetMachine.h * lib/Target/ARM/ARMTargetMachine.cpp - added ARMTargetMachine::addCodeEmitter() - added ARMTargetMachine::addSimpleCodeEmitter() * lib/Target/Alpha/Alpha.h * lib/Target/Alpha/AlphaCodeEmitter.cpp - added createAlphaObjectCodeEmitterPass() * lib/Target/Alpha/AlphaTargetMachine.h * lib/Target/Alpha/AlphaTargetMachine.cpp - added AlphaTargetMachine::addCodeEmitter() - added AlphaTargetMachine::addSimpleCodeEmitter() * tools/lto/LTOCodeGenerator.cpp * tools/llc/llc.cpp - converted to use ObjectCodeEmitter From nicholas at mxc.ca Mon Jul 6 00:16:09 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 05 Jul 2009 22:16:09 -0700 Subject: [llvm-commits] PATCH: remove VICmp and VFCmp. Message-ID: <4A518899.80806@mxc.ca> This patch removes vicmp and vfcmp, which has the positive side that it fixes existing type-safety bugs and simplifies some code, but a downside in that it XFAILs 9 CodeGen tests. May I commit this? Nick -------------- next part -------------- A non-text attachment was scrubbed... Name: remove-vcmp.patch Type: text/x-diff Size: 86165 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090705/f403abc9/attachment.bin From bruno.cardoso at gmail.com Mon Jul 6 00:16:40 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 06 Jul 2009 05:16:40 -0000 Subject: [llvm-commits] [llvm] r74814 - in /llvm/trunk: include/llvm/CodeGen/ObjectCodeEmitter.h lib/CodeGen/ObjectCodeEmitter.cpp Message-ID: <200907060516.n665Gekx026755@zion.cs.uiuc.edu> Author: bruno Date: Mon Jul 6 00:16:40 2009 New Revision: 74814 URL: http://llvm.org/viewvc/llvm-project?rev=74814&view=rev Log: Just forgot to include the two new files Added: llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp Added: llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h?rev=74814&view=auto ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h (added) +++ llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h Mon Jul 6 00:16:40 2009 @@ -0,0 +1,171 @@ +//===-- llvm/CodeGen/ObjectCodeEmitter.h - Object Code Emitter -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Generalized Object Code Emitter, works with ObjectModule and BinaryObject. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_OBJECTCODEEMITTER_H +#define LLVM_CODEGEN_OBJECTCODEEMITTER_H + +#include "llvm/CodeGen/MachineCodeEmitter.h" + +namespace llvm { + +class BinaryObject; +class MachineBasicBlock; +class MachineCodeEmitter; +class MachineFunction; +class MachineConstantPool; +class MachineJumpTableInfo; +class MachineModuleInfo; + +class ObjectCodeEmitter : public MachineCodeEmitter { +protected: + + /// Binary Object (Section or Segment) we are emitting to. + BinaryObject *BO; + + /// MBBLocations - This vector is a mapping from MBB ID's to their address. + /// It is filled in by the StartMachineBasicBlock callback and queried by + /// the getMachineBasicBlockAddress callback. + std::vector MBBLocations; + + /// LabelLocations - This vector is a mapping from Label ID's to their + /// address. + std::vector LabelLocations; + + /// CPLocations - This is a map of constant pool indices to offsets from the + /// start of the section for that constant pool index. + std::vector CPLocations; + + /// CPSections - This is a map of constant pool indices to the Section + /// containing the constant pool entry for that index. + std::vector CPSections; + + /// JTLocations - This is a map of jump table indices to offsets from the + /// start of the section for that jump table index. + std::vector JTLocations; + +public: + ObjectCodeEmitter(); + ObjectCodeEmitter(BinaryObject *bo); + virtual ~ObjectCodeEmitter(); + + /// setBinaryObject - set the BinaryObject we are writting to + void setBinaryObject(BinaryObject *bo); + + /// emitByte - This callback is invoked when a byte needs to be + /// written to the data stream, without buffer overflow testing. + void emitByte(uint8_t B); + + /// emitWordLE - This callback is invoked when a 32-bit word needs to be + /// written to the data stream in little-endian format. + void emitWordLE(uint32_t W); + + /// emitWordBE - This callback is invoked when a 32-bit word needs to be + /// written to the data stream in big-endian format. + void emitWordBE(uint32_t W); + + /// emitDWordLE - This callback is invoked when a 64-bit word needs to be + /// written to the data stream in little-endian format. + void emitDWordLE(uint64_t W); + + /// emitDWordBE - This callback is invoked when a 64-bit word needs to be + /// written to the data stream in big-endian format. + void emitDWordBE(uint64_t W); + + /// emitAlignment - Move the CurBufferPtr pointer up the the specified + /// alignment (saturated to BufferEnd of course). + void emitAlignment(unsigned Alignment = 0, uint8_t fill = 0); + + /// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be + /// written to the data stream. + void emitULEB128Bytes(uint64_t Value); + + /// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be + /// written to the data stream. + void emitSLEB128Bytes(uint64_t Value); + + /// emitString - This callback is invoked when a String needs to be + /// written to the data stream. + void emitString(const std::string &String); + + /// getCurrentPCValue - This returns the address that the next emitted byte + /// will be output to. + uintptr_t getCurrentPCValue() const; + + /// getCurrentPCOffset - Return the offset from the start of the emitted + /// buffer that we are currently writing to. + uintptr_t getCurrentPCOffset() const; + + /// addRelocation - Whenever a relocatable address is needed, it should be + /// noted with this interface. + void addRelocation(const MachineRelocation& relocation); + + /// startFunction - This callback is invoked when the specified function is + /// about to be code generated. This initializes the BufferBegin/End/Ptr + /// fields. + virtual void startFunction(MachineFunction &F) = 0; + + /// finishFunction - This callback is invoked when the specified function has + /// finished code generation. If a buffer overflow has occurred, this method + /// returns true (the callee is required to try again), otherwise it returns + /// false. + virtual bool finishFunction(MachineFunction &F) = 0; + + /// StartMachineBasicBlock - This should be called by the target when a new + /// basic block is about to be emitted. This way the MCE knows where the + /// start of the block is, and can implement getMachineBasicBlockAddress. + virtual void StartMachineBasicBlock(MachineBasicBlock *MBB); + + /// getMachineBasicBlockAddress - Return the address of the specified + /// MachineBasicBlock, only usable after the label for the MBB has been + /// emitted. + virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const; + + /// emitLabel - Emits a label + virtual void emitLabel(uint64_t LabelID) = 0; + + /// getLabelAddress - Return the address of the specified LabelID, only usable + /// after the LabelID has been emitted. + virtual uintptr_t getLabelAddress(uint64_t LabelID) const = 0; + + /// emitJumpTables - Emit all the jump tables for a given jump table info + /// record to the appropriate section. + virtual void emitJumpTables(MachineJumpTableInfo *MJTI) = 0; + + /// getJumpTableEntryAddress - Return the address of the jump table with index + /// 'Index' in the function that last called initJumpTableInfo. + virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const; + + /// emitConstantPool - For each constant pool entry, figure out which section + /// the constant should live in, allocate space for it, and emit it to the + /// Section data buffer. + virtual void emitConstantPool(MachineConstantPool *MCP) = 0; + + /// getConstantPoolEntryAddress - Return the address of the 'Index' entry in + /// the constant pool that was last emitted with the emitConstantPool method. + virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const; + + /// getConstantPoolEntrySection - Return the section of the 'Index' entry in + /// the constant pool that was last emitted with the emitConstantPool method. + virtual uintptr_t getConstantPoolEntrySection(unsigned Index) const; + + /// Specifies the MachineModuleInfo object. This is used for exception handling + /// purposes. + virtual void setModuleInfo(MachineModuleInfo* Info) = 0; + // to be implemented or depreciated with MachineModuleInfo + +}; // end class ObjectCodeEmitter + +} // end namespace llvm + +#endif + Added: llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp?rev=74814&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp (added) +++ llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp Mon Jul 6 00:16:40 2009 @@ -0,0 +1,142 @@ +//===-- llvm/CodeGen/ObjectCodeEmitter.cpp -------------------- -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/BinaryObject.h" +#include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineRelocation.h" +#include "llvm/CodeGen/ObjectCodeEmitter.h" + +//===----------------------------------------------------------------------===// +// ObjectCodeEmitter Implementation +//===----------------------------------------------------------------------===// + +namespace llvm { + +ObjectCodeEmitter::ObjectCodeEmitter() : BO(0) {} +ObjectCodeEmitter::ObjectCodeEmitter(BinaryObject *bo) : BO(bo) {} +ObjectCodeEmitter::~ObjectCodeEmitter() {} + +/// setBinaryObject - set the BinaryObject we are writting to +void ObjectCodeEmitter::setBinaryObject(BinaryObject *bo) { BO = bo; } + +/// emitByte - This callback is invoked when a byte needs to be +/// written to the data stream, without buffer overflow testing. +void ObjectCodeEmitter::emitByte(uint8_t B) { + BO->emitByte(B); +} + +/// emitWordLE - This callback is invoked when a 32-bit word needs to be +/// written to the data stream in little-endian format. +void ObjectCodeEmitter::emitWordLE(uint32_t W) { + BO->emitWordLE(W); +} + +/// emitWordBE - This callback is invoked when a 32-bit word needs to be +/// written to the data stream in big-endian format. +void ObjectCodeEmitter::emitWordBE(uint32_t W) { + BO->emitWordBE(W); +} + +/// emitDWordLE - This callback is invoked when a 64-bit word needs to be +/// written to the data stream in little-endian format. +void ObjectCodeEmitter::emitDWordLE(uint64_t W) { + BO->emitDWordLE(W); +} + +/// emitDWordBE - This callback is invoked when a 64-bit word needs to be +/// written to the data stream in big-endian format. +void ObjectCodeEmitter::emitDWordBE(uint64_t W) { + BO->emitDWordBE(W); +} + +/// emitAlignment - Move the CurBufferPtr pointer up the the specified +/// alignment (saturated to BufferEnd of course). +void ObjectCodeEmitter::emitAlignment(unsigned Alignment /* 0 */, + uint8_t fill /* 0 */) { + BO->emitAlignment(Alignment, fill); +} + +/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be +/// written to the data stream. +void ObjectCodeEmitter::emitULEB128Bytes(uint64_t Value) { + BO->emitULEB128Bytes(Value); +} + +/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be +/// written to the data stream. +void ObjectCodeEmitter::emitSLEB128Bytes(uint64_t Value) { + BO->emitSLEB128Bytes(Value); +} + +/// emitString - This callback is invoked when a String needs to be +/// written to the data stream. +void ObjectCodeEmitter::emitString(const std::string &String) { + BO->emitString(String); +} + +/// getCurrentPCValue - This returns the address that the next emitted byte +/// will be output to. +uintptr_t ObjectCodeEmitter::getCurrentPCValue() const { + return BO->getCurrentPCOffset(); +} + +/// getCurrentPCOffset - Return the offset from the start of the emitted +/// buffer that we are currently writing to. +uintptr_t ObjectCodeEmitter::getCurrentPCOffset() const { + return BO->getCurrentPCOffset(); +} + +/// addRelocation - Whenever a relocatable address is needed, it should be +/// noted with this interface. +void ObjectCodeEmitter::addRelocation(const MachineRelocation& relocation) { + BO->addRelocation(relocation); +} + +/// StartMachineBasicBlock - This should be called by the target when a new +/// basic block is about to be emitted. This way the MCE knows where the +/// start of the block is, and can implement getMachineBasicBlockAddress. +void ObjectCodeEmitter::StartMachineBasicBlock(MachineBasicBlock *MBB) { + if (MBBLocations.size() <= (unsigned)MBB->getNumber()) + MBBLocations.resize((MBB->getNumber()+1)*2); + MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); +} + +/// getMachineBasicBlockAddress - Return the address of the specified +/// MachineBasicBlock, only usable after the label for the MBB has been +/// emitted. +uintptr_t +ObjectCodeEmitter::getMachineBasicBlockAddress(MachineBasicBlock *MBB) const { + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && + MBBLocations[MBB->getNumber()] && "MBB not emitted!"); + return MBBLocations[MBB->getNumber()]; +} + +/// getJumpTableEntryAddress - Return the address of the jump table with index +/// 'Index' in the function that last called initJumpTableInfo. +uintptr_t ObjectCodeEmitter::getJumpTableEntryAddress(unsigned Index) const { + assert(JTLocations.size() > Index && "JT not emitted!"); + return JTLocations[Index]; +} + +/// getConstantPoolEntryAddress - Return the address of the 'Index' entry in +/// the constant pool that was last emitted with the emitConstantPool method. +uintptr_t ObjectCodeEmitter::getConstantPoolEntryAddress(unsigned Index) const { + assert(CPLocations.size() > Index && "CP not emitted!"); + return CPLocations[Index]; +} + +/// getConstantPoolEntrySection - Return the section of the 'Index' entry in +/// the constant pool that was last emitted with the emitConstantPool method. +uintptr_t ObjectCodeEmitter::getConstantPoolEntrySection(unsigned Index) const { + assert(CPSections.size() > Index && "CP not emitted!"); + return CPSections[Index]; +} + +} // end namespace llvm + From eli.friedman at gmail.com Mon Jul 6 01:02:46 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Sun, 5 Jul 2009 23:02:46 -0700 Subject: [llvm-commits] PATCH: remove VICmp and VFCmp. In-Reply-To: <4A518899.80806@mxc.ca> References: <4A518899.80806@mxc.ca> Message-ID: On Sun, Jul 5, 2009 at 10:16 PM, Nick Lewycky wrote: > This patch removes vicmp and vfcmp, which has the positive side that it > fixes existing type-safety bugs and simplifies some code, but a downside in > that it XFAILs 9 CodeGen tests. > > May I commit this? The only question is whether anyone is using it; since vector icmp is effectively unusable, the only ways to compare vectors without vicmp/vfcmp are by scalarizing them or using platform-specific intrinsics. Either way, it's probably best to wait a few days to see if anyone objects. It would be nice to include testcases for the relevant type-safety bugs. -Eli From bruno.cardoso at gmail.com Mon Jul 6 01:40:51 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 06 Jul 2009 06:40:51 -0000 Subject: [llvm-commits] [llvm] r74817 - in /llvm/trunk/lib/CodeGen: MachO.h MachOCodeEmitter.cpp MachOCodeEmitter.h MachOWriter.cpp MachOWriter.h Message-ID: <200907060640.n666epJo029039@zion.cs.uiuc.edu> Author: bruno Date: Mon Jul 6 01:40:51 2009 New Revision: 74817 URL: http://llvm.org/viewvc/llvm-project?rev=74817&view=rev Log: Cleanup MachO writer and code emitter. Fix 80 cols problems, remove extra spaces, shrink down includes and move some methods out-of-line Modified: llvm/trunk/lib/CodeGen/MachO.h llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp llvm/trunk/lib/CodeGen/MachOCodeEmitter.h llvm/trunk/lib/CodeGen/MachOWriter.cpp llvm/trunk/lib/CodeGen/MachOWriter.h Modified: llvm/trunk/lib/CodeGen/MachO.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachO.h?rev=74817&r1=74816&r2=74817&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachO.h (original) +++ llvm/trunk/lib/CodeGen/MachO.h Mon Jul 6 01:40:51 2009 @@ -14,18 +14,15 @@ #ifndef MACHO_H #define MACHO_H -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/CodeGen/MachineRelocation.h" #include "llvm/CodeGen/BinaryObject.h" -#include "llvm/Target/TargetAsmInfo.h" #include #include namespace llvm { -typedef std::vector DataBuffer; - +class GlobalValue; +class TargetAsmInfo; + /// MachOSym - This struct contains information about each symbol that is /// added to logical symbol table for the module. This is eventually /// turned into a real symbol table in the file. @@ -111,7 +108,7 @@ /// HeaderData - The actual data for the header which we are building /// up for emission to the file. - DataBuffer HeaderData; + std::vector HeaderData; // Constants for the filetype field // see for additional info on the various types @@ -181,8 +178,8 @@ }; MachOHeader() : magic(0), filetype(0), ncmds(0), sizeofcmds(0), flags(0), - reserved(0) { } - + reserved(0) {} + /// cmdSize - This routine returns the size of the MachOSection as written /// to disk, depending on whether the destination is a 64 bit Mach-O file. unsigned cmdSize(bool is64Bit) const { @@ -204,7 +201,7 @@ } }; // end struct MachOHeader - + /// MachOSegment - This struct contains the necessary information to /// emit the load commands for each section in the file. struct MachOSegment { @@ -246,13 +243,13 @@ SEG_VM_PROT_EXECUTE = VM_PROT_EXECUTE, SEG_VM_PROT_ALL = VM_PROT_ALL }; - + // Constants for the cmd field // see enum { LC_SEGMENT = 0x01, // segment of this file to be mapped LC_SEGMENT_64 = 0x19 // 64-bit segment of this file to be mapped }; - + /// cmdSize - This routine returns the size of the MachOSection as written /// to disk, depending on whether the destination is a 64 bit Mach-O file. unsigned cmdSize(bool is64Bit) const { @@ -285,15 +282,15 @@ uint32_t reserved1; // reserved (for offset or index) uint32_t reserved2; // reserved (for count or sizeof) uint32_t reserved3; // reserved (64 bit only) - + /// A unique number for this section, which will be used to match symbols /// to the correct section. uint32_t Index; - + /// RelocBuffer - A buffer to hold the mach-o relocations before we write /// them out at the appropriate location in the file. - DataBuffer RelocBuffer; - + std::vector RelocBuffer; + // Constants for the section types (low 8 bits of flags field) // see enum { S_REGULAR = 0, @@ -405,7 +402,7 @@ ilocalsym(0), nlocalsym(0), iextdefsym(0), nextdefsym(0), iundefsym(0), nundefsym(0), tocoff(0), ntoc(0), modtaboff(0), nmodtab(0), extrefsymoff(0), nextrefsyms(0), indirectsymoff(0), - nindirectsyms(0), extreloff(0), nextrel(0), locreloff(0), nlocrel(0) { } + nindirectsyms(0), extreloff(0), nextrel(0), locreloff(0), nlocrel(0) {} }; // end struct MachODySymTab Modified: llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp?rev=74817&r1=74816&r2=74817&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp Mon Jul 6 01:40:51 2009 @@ -7,13 +7,18 @@ // //===----------------------------------------------------------------------===// +#include "MachO.h" +#include "MachOWriter.h" #include "MachOCodeEmitter.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" +#include "llvm/CodeGen/MachineRelocation.h" #include "llvm/Target/TargetAsmInfo.h" +#include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetMachine.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/OutputBuffer.h" #include @@ -23,7 +28,14 @@ //===----------------------------------------------------------------------===// namespace llvm { - + +MachOCodeEmitter::MachOCodeEmitter(MachOWriter &mow, MachOSection &mos) : + ObjectCodeEmitter(&mos), MOW(mow), TM(MOW.TM) { + is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; + isLittleEndian = TM.getTargetData()->isLittleEndian(); + TAI = TM.getTargetAsmInfo(); +} + /// startFunction - This callback is invoked when a new machine function is /// about to be emitted. @@ -141,7 +153,8 @@ for (unsigned j = 0; j < Size; ++j) SecDataOut.outbyte(0); - MachOWriter::InitMem(CP[i].Val.ConstVal, CPLocations[i], TM.getTargetData(), Sec); + MachOWriter::InitMem(CP[i].Val.ConstVal, CPLocations[i], + TM.getTargetData(), Sec); } } Modified: llvm/trunk/lib/CodeGen/MachOCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOCodeEmitter.h?rev=74817&r1=74816&r2=74817&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOCodeEmitter.h (original) +++ llvm/trunk/lib/CodeGen/MachOCodeEmitter.h Mon Jul 6 01:40:51 2009 @@ -10,10 +10,13 @@ #ifndef MACHOCODEEMITTER_H #define MACHOCODEEMITTER_H -#include "MachOWriter.h" +#include "llvm/CodeGen/ObjectCodeEmitter.h" +#include namespace llvm { +class MachOWriter; + /// MachOCodeEmitter - This class is used by the MachOWriter to emit the code /// for functions to the Mach-O file. @@ -36,12 +39,7 @@ std::map Labels; public: - MachOCodeEmitter(MachOWriter &mow, MachOSection &mos) : - ObjectCodeEmitter(&mos), MOW(mow), TM(MOW.TM) { - is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; - isLittleEndian = TM.getTargetData()->isLittleEndian(); - TAI = TM.getTargetAsmInfo(); - } + MachOCodeEmitter(MachOWriter &mow, MachOSection &mos); virtual void startFunction(MachineFunction &MF); virtual bool finishFunction(MachineFunction &MF); @@ -49,7 +47,7 @@ virtual void addRelocation(const MachineRelocation &MR) { Relocations.push_back(MR); } - + void emitConstantPool(MachineConstantPool *MCP); void emitJumpTables(MachineJumpTableInfo *MJTI); Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=74817&r1=74816&r2=74817&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Mon Jul 6 01:40:51 2009 @@ -22,25 +22,20 @@ // //===----------------------------------------------------------------------===// +#include "MachO.h" #include "MachOWriter.h" #include "MachOCodeEmitter.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/PassManager.h" -#include "llvm/CodeGen/FileWriters.h" -#include "llvm/CodeGen/MachineCodeEmitter.h" -#include "llvm/CodeGen/MachineConstantPool.h" -#include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/Target/TargetAsmInfo.h" -#include "llvm/Target/TargetJITInfo.h" +#include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetMachOWriterInfo.h" #include "llvm/Support/Mangler.h" -#include "llvm/Support/MathExtras.h" #include "llvm/Support/OutputBuffer.h" -#include "llvm/Support/Streams.h" #include "llvm/Support/raw_ostream.h" -#include -#include namespace llvm { @@ -60,16 +55,14 @@ char MachOWriter::ID = 0; -MachOWriter::MachOWriter(raw_ostream &o, TargetMachine &tm) - : MachineFunctionPass(&ID), O(o), TM(tm) - { +MachOWriter::MachOWriter(raw_ostream &o, TargetMachine &tm) + : MachineFunctionPass(&ID), O(o), TM(tm) { is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; isLittleEndian = TM.getTargetData()->isLittleEndian(); TAI = TM.getTargetAsmInfo(); // Create the machine code emitter object for this target. - MachOCE = new MachOCodeEmitter(*this, *getTextSection(true)); } @@ -98,13 +91,13 @@ /// the Mach-O file to 'O'. bool MachOWriter::doFinalization(Module &M) { // FIXME: we don't handle debug info yet, we should probably do that. - // Okay, the.text section has been completed, build the .data, .bss, and + // Okay, the.text section has been completed, build the .data, .bss, and // "common" sections next. for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) EmitGlobal(I); - + // Emit the header and load commands. EmitHeaderAndLoadCommands(); @@ -126,6 +119,89 @@ return false; } +// getConstSection - Get constant section for Constant 'C' +MachOSection *MachOWriter::getConstSection(Constant *C) { + const ConstantArray *CVA = dyn_cast(C); + if (CVA && CVA->isCString()) + return getSection("__TEXT", "__cstring", + MachOSection::S_CSTRING_LITERALS); + + const Type *Ty = C->getType(); + if (Ty->isPrimitiveType() || Ty->isInteger()) { + unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); + switch(Size) { + default: break; // Fall through to __TEXT,__const + case 4: + return getSection("__TEXT", "__literal4", + MachOSection::S_4BYTE_LITERALS); + case 8: + return getSection("__TEXT", "__literal8", + MachOSection::S_8BYTE_LITERALS); + case 16: + return getSection("__TEXT", "__literal16", + MachOSection::S_16BYTE_LITERALS); + } + } + return getSection("__TEXT", "__const"); +} + +// getJumpTableSection - Select the Jump Table section +MachOSection *MachOWriter::getJumpTableSection() { + if (TM.getRelocationModel() == Reloc::PIC_) + return getTextSection(false); + else + return getSection("__TEXT", "__const"); +} + +// getSection - Return the section with the specified name, creating a new +// section if one does not already exist. +MachOSection *MachOWriter::getSection(const std::string &seg, + const std::string §, + unsigned Flags /* = 0 */ ) { + MachOSection *MOS = SectionLookup[seg+sect]; + if (MOS) return MOS; + + MOS = new MachOSection(seg, sect); + SectionList.push_back(MOS); + MOS->Index = SectionList.size(); + MOS->flags = MachOSection::S_REGULAR | Flags; + SectionLookup[seg+sect] = MOS; + return MOS; +} + +// getTextSection - Return text section with different flags for code/data +MachOSection *MachOWriter::getTextSection(bool isCode /* = true */ ) { + if (isCode) + return getSection("__TEXT", "__text", + MachOSection::S_ATTR_PURE_INSTRUCTIONS | + MachOSection::S_ATTR_SOME_INSTRUCTIONS); + else + return getSection("__TEXT", "__text"); +} + +MachOSection *MachOWriter::getBSSSection() { + return getSection("__DATA", "__bss", MachOSection::S_ZEROFILL); +} + +// GetJTRelocation - Get a relocation a new BB relocation based +// on target information. +MachineRelocation MachOWriter::GetJTRelocation(unsigned Offset, + MachineBasicBlock *MBB) const { + return TM.getMachOWriterInfo()->GetJTRelocation(Offset, MBB); +} + +// GetTargetRelocation - Returns the number of relocations. +unsigned MachOWriter::GetTargetRelocation(MachineRelocation &MR, + unsigned FromIdx, unsigned ToAddr, + unsigned ToIndex, OutputBuffer &RelocOut, + OutputBuffer &SecOut, bool Scattered, + bool Extern) { + return TM.getMachOWriterInfo()->GetTargetRelocation(MR, FromIdx, ToAddr, + ToIndex, RelocOut, + SecOut, Scattered, + Extern); +} + void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) { const Type *Ty = GV->getType()->getElementType(); unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); @@ -151,15 +227,15 @@ // Record the offset of the symbol, and then allocate space for it. // FIXME: remove when we have unified size + output buffer - - // Now that we know what section the GlovalVariable is going to be emitted + + // Now that we know what section the GlovalVariable is going to be emitted // into, update our mappings. // FIXME: We may also need to update this when outputting non-GlobalVariable // GlobalValues such as functions. GVSection[GV] = Sec; GVOffset[GV] = Sec->size(); - + // Allocate space in the section for the global. for (unsigned i = 0; i < Size; ++i) SecDataOut.outbyte(0); @@ -169,7 +245,7 @@ const Type *Ty = GV->getType()->getElementType(); unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); bool NoInit = !GV->hasInitializer(); - + // If this global has a zero initializer, it is part of the .bss or common // section. if (NoInit || GV->getInitializer()->isNullValue()) { @@ -178,7 +254,8 @@ // merged with other symbols. if (NoInit || GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() || GV->hasCommonLinkage()) { - MachOSym ExtOrCommonSym(GV, Mang->getValueName(GV), MachOSym::NO_SECT, TAI); + MachOSym ExtOrCommonSym(GV, Mang->getValueName(GV), + MachOSym::NO_SECT, TAI); // For undefined (N_UNDF) external (N_EXT) types, n_value is the size in // bytes of the symbol. ExtOrCommonSym.n_value = Size; @@ -192,11 +269,11 @@ AddSymbolToSection(BSS, GV); return; } - + // Scalar read-only data goes in a literal section if the scalar is 4, 8, or // 16 bytes, or a cstring. Other read only data goes into a regular const // section. Read-write data goes in the data section. - MachOSection *Sec = GV->isConstant() ? getConstSection(GV->getInitializer()) : + MachOSection *Sec = GV->isConstant() ? getConstSection(GV->getInitializer()) : getDataSection(); AddSymbolToSection(Sec, GV); InitMem(GV->getInitializer(), GVOffset[GV], TM.getTargetData(), Sec); @@ -210,22 +287,22 @@ MachOSegment SEG("", is64Bit); SEG.nsects = SectionList.size(); - SEG.cmdsize = SEG.cmdSize(is64Bit) + + SEG.cmdsize = SEG.cmdSize(is64Bit) + SEG.nsects * SectionList[0]->cmdSize(is64Bit); - + // Step #1: calculate the number of load commands. We always have at least // one, for the LC_SEGMENT load command, plus two for the normal // and dynamic symbol tables, if there are any symbols. Header.ncmds = SymbolTable.empty() ? 1 : 3; - + // Step #2: calculate the size of the load commands Header.sizeofcmds = SEG.cmdsize; if (!SymbolTable.empty()) Header.sizeofcmds += SymTab.cmdsize + DySymTab.cmdsize; - + // Step #3: write the header to the file // Local alias to shortenify coming code. - DataBuffer &FH = Header.HeaderData; + std::vector &FH = Header.HeaderData; OutputBuffer FHOut(FH, is64Bit, isLittleEndian); FHOut.outword(Header.magic); @@ -237,7 +314,7 @@ FHOut.outword(Header.flags); if (is64Bit) FHOut.outword(Header.reserved); - + // Step #4: Finish filling in the segment load command and write it out for (std::vector::iterator I = SectionList.begin(), E = SectionList.end(); I != E; ++I) @@ -245,7 +322,7 @@ SEG.vmsize = SEG.filesize; SEG.fileoff = Header.cmdSize(is64Bit) + Header.sizeofcmds; - + FHOut.outword(SEG.cmd); FHOut.outword(SEG.cmdsize); FHOut.outstring(SEG.segname, 16); @@ -257,8 +334,8 @@ FHOut.outword(SEG.initprot); FHOut.outword(SEG.nsects); FHOut.outword(SEG.flags); - - // Step #5: Finish filling in the fields of the MachOSections + + // Step #5: Finish filling in the fields of the MachOSections uint64_t currentAddr = 0; for (std::vector::iterator I = SectionList.begin(), E = SectionList.end(); I != E; ++I) { @@ -268,13 +345,13 @@ // FIXME: do we need to do something with alignment here? currentAddr += MOS->size(); } - + // Step #6: Emit the symbol table to temporary buffers, so that we know the // size of the string table when we write the next load command. This also // sorts and assigns indices to each of the symbols, which is necessary for // emitting relocations to externally-defined objects. BufferSymbolAndStringTable(); - + // Step #7: Calculate the number of relocations for each section and write out // the section commands for each section currentAddr += SEG.fileoff; @@ -287,7 +364,7 @@ CalculateRelocations(*MOS); MOS->reloff = MOS->nreloc ? currentAddr : 0; currentAddr += MOS->nreloc * 8; - + // write the finalized section command to the output buffer FHOut.outstring(MOS->sectname, 16); FHOut.outstring(MOS->segname, 16); @@ -303,7 +380,7 @@ if (is64Bit) FHOut.outword(MOS->reserved3); } - + // Step #8: Emit LC_SYMTAB/LC_DYSYMTAB load commands SymTab.symoff = currentAddr; SymTab.nsyms = SymbolTable.size(); @@ -339,7 +416,7 @@ FHOut.outword(DySymTab.nextrel); FHOut.outword(DySymTab.locreloff); FHOut.outword(DySymTab.nlocrel); - + O.write((char*)&FH[0], FH.size()); } @@ -370,7 +447,7 @@ // 1. local symbols // 2. defined external symbols (sorted by name) // 3. undefined external symbols (sorted by name) - + // Before sorting the symbols, check the PendingGlobals for any undefined // globals that need to be put in the symbol table. for (std::vector::iterator I = PendingGlobals.begin(), @@ -386,10 +463,11 @@ // of definition, we won't have to sort by name within each partition. std::sort(SymbolTable.begin(), SymbolTable.end(), MachOSym::SymCmp()); - // Parition the symbol table entries so that all local symbols come before + // Parition the symbol table entries so that all local symbols come before // all symbols with external linkage. { 1 | 2 3 } - std::partition(SymbolTable.begin(), SymbolTable.end(), MachOSym::PartitionByLocal); - + std::partition(SymbolTable.begin(), SymbolTable.end(), + MachOSym::PartitionByLocal); + // Advance iterator to beginning of external symbols and partition so that // all external symbols defined in this module come before all external // symbols defined elsewhere. { 1 | 2 | 3 } @@ -401,7 +479,7 @@ } } - // Calculate the starting index for each of the local, extern defined, and + // Calculate the starting index for each of the local, extern defined, and // undefined symbols, as well as the number of each to put in the LC_DYSYMTAB // load command. for (std::vector::iterator I = SymbolTable.begin(), @@ -417,7 +495,7 @@ ++DySymTab.nundefsym; } } - + // Write out a leading zero byte when emitting string table, for n_strx == 0 // which means an empty string. OutputBuffer StrTOut(StrT, is64Bit, isLittleEndian); @@ -451,7 +529,7 @@ I->n_value += GVSection[GV]->addr; if (GV && (GVOffset[GV] == -1)) GVOffset[GV] = index; - + // Emit nlist to buffer SymTOut.outword(I->n_strx); SymTOut.outbyte(I->n_type); @@ -486,7 +564,7 @@ GlobalValue *GV = MR.getGlobalValue(); MachOSection *MOSPtr = GVSection[GV]; intptr_t Offset = GVOffset[GV]; - + // If we have never seen the global before, it must be to a symbol // defined in another module (N_UNDF). if (!MOSPtr) { @@ -500,7 +578,7 @@ } MR.setResultPointer((void*)Offset); } - + // If the symbol is locally defined, pass in the address of the section and // the section index to the code which will generate the target relocation. if (!Extern) { @@ -519,21 +597,21 @@ // InitMem - Write the value of a Constant to the specified memory location, // converting it into bytes and relocations. -void MachOWriter::InitMem(const Constant *C, uintptr_t Offset, +void MachOWriter::InitMem(const Constant *C, uintptr_t Offset, const TargetData *TD, MachOSection* mos) { typedef std::pair CPair; std::vector WorkList; uint8_t *Addr = &mos->getData()[0]; - + WorkList.push_back(CPair(C,(intptr_t)Addr + Offset)); - + intptr_t ScatteredOffset = 0; - + while (!WorkList.empty()) { const Constant *PC = WorkList.back().first; intptr_t PA = WorkList.back().second; WorkList.pop_back(); - + if (isa(PC)) { continue; } else if (const ConstantVector *CP = dyn_cast(PC)) { @@ -626,7 +704,7 @@ memset(ptr, 0, TD->getPointerSize()); else if (const GlobalValue* GV = dyn_cast(PC)) { // FIXME: what about function stubs? - mos->addRelocation(MachineRelocation::getGV(PA-(intptr_t)Addr, + mos->addRelocation(MachineRelocation::getGV(PA-(intptr_t)Addr, MachineRelocation::VANILLA, const_cast(GV), ScatteredOffset)); Modified: llvm/trunk/lib/CodeGen/MachOWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.h?rev=74817&r1=74816&r2=74817&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.h (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.h Mon Jul 6 01:40:51 2009 @@ -14,29 +14,27 @@ #ifndef MACHOWRITER_H #define MACHOWRITER_H -#include "MachO.h" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" #include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/CodeGen/ObjectCodeEmitter.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachOWriterInfo.h" #include #include namespace llvm { + class Constant; class GlobalVariable; class Mangler; class MachineRelocation; - class ObjectCodeEmitter; class MachOCodeEmitter; + class MachODySymTab; + class MachOHeader; + class MachOSection; + class MachOSym; class TargetData; class TargetMachine; + class TargetAsmInfo; + class ObjectCodeEmitter; class OutputBuffer; class raw_ostream; - /// MachOWriter - This class implements the common target-independent code for /// writing Mach-O files. Targets should derive a class from this to /// parameterize the output format. @@ -69,36 +67,30 @@ /// Mang - The object used to perform name mangling for this module. /// Mangler *Mang; - - /// MachOCE - The MachineCodeEmitter object that we are exposing to emit machine - /// code for functions to the .o file. + /// MachOCE - The MachineCodeEmitter object that we are exposing to emit + /// machine code for functions to the .o file. MachOCodeEmitter *MachOCE; /// is64Bit/isLittleEndian - This information is inferred from the target /// machine directly, indicating what header values and flags to set. - bool is64Bit, isLittleEndian; // Target Asm Info - const TargetAsmInfo *TAI; /// Header - An instance of MachOHeader that we will update while we build /// the file, and then emit during finalization. - MachOHeader Header; /// doInitialization - Emit the file header and all of the global variables /// for the module to the Mach-O file. - bool doInitialization(Module &M); bool runOnMachineFunction(MachineFunction &MF); /// doFinalization - Now that the module has been completely processed, emit /// the Mach-O file to 'O'. - bool doFinalization(Module &M); private: @@ -106,85 +98,37 @@ /// SectionList - This is the list of sections that we have emitted to the /// file. Once the file has been completely built, the segment load command /// SectionCommands are constructed from this info. - std::vector SectionList; /// SectionLookup - This is a mapping from section name to SectionList entry - std::map SectionLookup; - + /// GVSection - This is a mapping from a GlobalValue to a MachOSection, /// to aid in emitting relocations. - std::map GVSection; - /// GVOffset - This is a mapping from a GlobalValue to an offset from the + /// GVOffset - This is a mapping from a GlobalValue to an offset from the /// start of the section in which the GV resides, to aid in emitting /// relocations. - std::map GVOffset; /// getSection - Return the section with the specified name, creating a new /// section if one does not already exist. - MachOSection *getSection(const std::string &seg, const std::string §, - unsigned Flags = 0) { - MachOSection *MOS = SectionLookup[seg+sect]; - if (MOS) return MOS; - - MOS = new MachOSection(seg, sect); - SectionList.push_back(MOS); - MOS->Index = SectionList.size(); - MOS->flags = MachOSection::S_REGULAR | Flags; - SectionLookup[seg+sect] = MOS; - return MOS; - } - MachOSection *getTextSection(bool isCode = true) { - if (isCode) - return getSection("__TEXT", "__text", - MachOSection::S_ATTR_PURE_INSTRUCTIONS | - MachOSection::S_ATTR_SOME_INSTRUCTIONS); - else - return getSection("__TEXT", "__text"); - } - MachOSection *getBSSSection() { - return getSection("__DATA", "__bss", MachOSection::S_ZEROFILL); - } + unsigned Flags = 0); + + /// getTextSection - Return text section with different flags for code/data + MachOSection *getTextSection(bool isCode = true); + MachOSection *getDataSection() { return getSection("__DATA", "__data"); } - MachOSection *getConstSection(Constant *C) { - const ConstantArray *CVA = dyn_cast(C); - if (CVA && CVA->isCString()) - return getSection("__TEXT", "__cstring", - MachOSection::S_CSTRING_LITERALS); - - const Type *Ty = C->getType(); - if (Ty->isPrimitiveType() || Ty->isInteger()) { - unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); - switch(Size) { - default: break; // Fall through to __TEXT,__const - case 4: - return getSection("__TEXT", "__literal4", - MachOSection::S_4BYTE_LITERALS); - case 8: - return getSection("__TEXT", "__literal8", - MachOSection::S_8BYTE_LITERALS); - case 16: - return getSection("__TEXT", "__literal16", - MachOSection::S_16BYTE_LITERALS); - } - } - return getSection("__TEXT", "__const"); - } - MachOSection *getJumpTableSection() { - if (TM.getRelocationModel() == Reloc::PIC_) - return getTextSection(false); - else - return getSection("__TEXT", "__const"); - } - - /// MachOSymTab - This struct contains information about the offsets and + + MachOSection *getBSSSection(); + MachOSection *getConstSection(Constant *C); + MachOSection *getJumpTableSection(); + + /// MachOSymTab - This struct contains information about the offsets and /// size of symbol table information. /// segment. struct MachOSymTab { @@ -199,44 +143,42 @@ // see enum { LC_SYMTAB = 0x02 // link-edit stab symbol table info }; - + MachOSymTab() : cmd(LC_SYMTAB), cmdsize(6 * sizeof(uint32_t)), symoff(0), nsyms(0), stroff(0), strsize(0) { } }; - + /// SymTab - The "stab" style symbol table information - MachOSymTab SymTab; + MachOSymTab SymTab; /// DySymTab - symbol table info for the dynamic link editor MachODySymTab DySymTab; protected: - + /// SymbolTable - This is the list of symbols we have emitted to the file. /// This actually gets rearranged before emission to the file (to put the /// local symbols first in the list). std::vector SymbolTable; - + /// SymT - A buffer to hold the symbol table before we write it out at the /// appropriate location in the file. - DataBuffer SymT; - + std::vector SymT; + /// StrT - A buffer to hold the string table before we write it out at the /// appropriate location in the file. - DataBuffer StrT; - + std::vector StrT; + /// PendingSyms - This is a list of externally defined symbols that we have /// been asked to emit, but have not seen a reference to. When a reference /// is seen, the symbol will move from this list to the SymbolTable. std::vector PendingGlobals; - + /// DynamicSymbolTable - This is just a vector of indices into /// SymbolTable to aid in emitting the DYSYMTAB load command. std::vector DynamicSymbolTable; - - static void InitMem(const Constant *C, - uintptr_t Offset, - const TargetData *TD, - MachOSection* mos); + + static void InitMem(const Constant *C, uintptr_t Offset, + const TargetData *TD, MachOSection* mos); private: void AddSymbolToSection(MachOSection *MOS, GlobalVariable *GV); @@ -247,25 +189,16 @@ void BufferSymbolAndStringTable(); void CalculateRelocations(MachOSection &MOS); + // GetJTRelocation - Get a relocation a new BB relocation based + // on target information. MachineRelocation GetJTRelocation(unsigned Offset, - MachineBasicBlock *MBB) const { - return TM.getMachOWriterInfo()->GetJTRelocation(Offset, MBB); - } + MachineBasicBlock *MBB) const; /// GetTargetRelocation - Returns the number of relocations. - unsigned GetTargetRelocation(MachineRelocation &MR, - unsigned FromIdx, - unsigned ToAddr, - unsigned ToIndex, - OutputBuffer &RelocOut, - OutputBuffer &SecOut, - bool Scattered, - bool Extern) { - return TM.getMachOWriterInfo()->GetTargetRelocation(MR, FromIdx, ToAddr, - ToIndex, RelocOut, - SecOut, Scattered, - Extern); - } + unsigned GetTargetRelocation(MachineRelocation &MR, unsigned FromIdx, + unsigned ToAddr, unsigned ToIndex, + OutputBuffer &RelocOut, OutputBuffer &SecOut, + bool Scattered, bool Extern); }; } From sanjiv.gupta at microchip.com Mon Jul 6 03:22:16 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Mon, 06 Jul 2009 08:22:16 -0000 Subject: [llvm-commits] [llvm] r74819 - /llvm/trunk/lib/Target/PIC16/PIC16.h Message-ID: <200907060822.n668MG0k011337@zion.cs.uiuc.edu> Author: sgupta Date: Mon Jul 6 03:22:15 2009 New Revision: 74819 URL: http://llvm.org/viewvc/llvm-project?rev=74819&view=rev Log: Corrected the names description. Change in a comment. No functionality change. Modified: llvm/trunk/lib/Target/PIC16/PIC16.h Modified: llvm/trunk/lib/Target/PIC16/PIC16.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16.h?rev=74819&r1=74818&r2=74819&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16.h Mon Jul 6 03:22:15 2009 @@ -83,7 +83,7 @@ // initialized globals - @idata..# // Function frame - @.frame_section. // Function autos - @.autos_section. - // Declarations - @section.0 + // Declarations - Enclosed in comments. No section for them. //---------------------------------------------------------- // Tags used to mangle different names. From bruno.cardoso at gmail.com Mon Jul 6 04:27:00 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 06 Jul 2009 09:27:00 -0000 Subject: [llvm-commits] [llvm] r74821 - in /llvm/trunk/lib/CodeGen: ELFCodeEmitter.cpp ELFCodeEmitter.h ELFWriter.cpp ELFWriter.h Message-ID: <200907060927.n669R4bv013725@zion.cs.uiuc.edu> Author: bruno Date: Mon Jul 6 04:26:48 2009 New Revision: 74821 URL: http://llvm.org/viewvc/llvm-project?rev=74821&view=rev Log: Changed ELFCodeEmitter to inherit from ObjectCodeEmitter Modified: llvm/trunk/lib/CodeGen/ELFCodeEmitter.cpp llvm/trunk/lib/CodeGen/ELFCodeEmitter.h llvm/trunk/lib/CodeGen/ELFWriter.cpp llvm/trunk/lib/CodeGen/ELFWriter.h Modified: llvm/trunk/lib/CodeGen/ELFCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFCodeEmitter.cpp?rev=74821&r1=74820&r2=74821&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ELFCodeEmitter.cpp (original) +++ llvm/trunk/lib/CodeGen/ELFCodeEmitter.cpp Mon Jul 6 04:26:48 2009 @@ -33,47 +33,30 @@ /// startFunction - This callback is invoked when a new machine function is /// about to be emitted. void ELFCodeEmitter::startFunction(MachineFunction &MF) { + DOUT << "processing function: " << MF.getFunction()->getName() << "\n"; + // Get the ELF Section that this function belongs in. ES = &EW.getTextSection(); - DOUT << "processing function: " << MF.getFunction()->getName() << "\n"; - - // FIXME: better memory management, this will be replaced by BinaryObjects - BinaryData &BD = ES->getData(); - BD.reserve(4096); - BufferBegin = &BD[0]; - BufferEnd = BufferBegin + BD.capacity(); + // Set the desired binary object to be used by the code emitters + setBinaryObject(ES); // Get the function alignment in bytes unsigned Align = (1 << MF.getAlignment()); - // Align the section size with the function alignment, so the function can - // start in a aligned offset, also update the section alignment if needed. - if (ES->Align < Align) ES->Align = Align; - ES->Size = (ES->Size + (Align-1)) & (-Align); - - // Snaity check on allocated space for text section - assert( ES->Size < 4096 && "no more space in TextSection" ); + // The function must start on its required alignment + ES->emitAlignment(Align); - // FIXME: Using ES->Size directly here instead of calculating it from the - // output buffer size (impossible because the code emitter deals only in raw - // bytes) forces us to manually synchronize size and write padding zero bytes - // to the output buffer for all non-text sections. For text sections, we do - // not synchonize the output buffer, and we just blow up if anyone tries to - // write non-code to it. An assert should probably be added to - // AddSymbolToSection to prevent calling it on the text section. - CurBufferPtr = BufferBegin + ES->Size; + // Update the section alignment if needed. + if (ES->Align < Align) ES->Align = Align; - // Record function start address relative to BufferBegin - FnStartPtr = CurBufferPtr; + // Record the function start offset + FnStartOff = ES->getCurrentPCOffset(); } /// finishFunction - This callback is invoked after the function is completely /// finished. bool ELFCodeEmitter::finishFunction(MachineFunction &MF) { - // Update Section Size - ES->Size = CurBufferPtr - BufferBegin; - // Add a symbol to represent the function. const Function *F = MF.getFunction(); ELFSym FnSym(F); @@ -81,10 +64,10 @@ FnSym.setBind(EW.getGlobalELFLinkage(F)); FnSym.setVisibility(EW.getGlobalELFVisibility(F)); FnSym.SectionIdx = ES->SectionIdx; - FnSym.Size = CurBufferPtr-FnStartPtr; + FnSym.Size = ES->getCurrentPCOffset()-FnStartOff; // Offset from start of Section - FnSym.Value = FnStartPtr-BufferBegin; + FnSym.Value = FnStartOff; // Locals should go on the symbol list front if (!F->hasPrivateLinkage()) { Modified: llvm/trunk/lib/CodeGen/ELFCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFCodeEmitter.h?rev=74821&r1=74820&r2=74821&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ELFCodeEmitter.h (original) +++ llvm/trunk/lib/CodeGen/ELFCodeEmitter.h Mon Jul 6 04:26:48 2009 @@ -10,7 +10,7 @@ #ifndef ELFCODEEMITTER_H #define ELFCODEEMITTER_H -#include "llvm/CodeGen/MachineCodeEmitter.h" +#include "llvm/CodeGen/ObjectCodeEmitter.h" #include namespace llvm { @@ -19,7 +19,7 @@ /// ELFCodeEmitter - This class is used by the ELFWriter to /// emit the code for functions to the ELF file. - class ELFCodeEmitter : public MachineCodeEmitter { + class ELFCodeEmitter : public ObjectCodeEmitter { ELFWriter &EW; /// Target machine description @@ -28,30 +28,11 @@ /// Section containing code for functions ELFSection *ES; - /// Relocations - These are the relocations that the function needs, as - /// emitted. + /// Relocations - Record relocations needed by the current function std::vector Relocations; - /// CPLocations - This is a map of constant pool indices to offsets from the - /// start of the section for that constant pool index. - std::vector CPLocations; - - /// CPSections - This is a map of constant pool indices to the MachOSection - /// containing the constant pool entry for that index. - std::vector CPSections; - - /// JTLocations - This is a map of jump table indices to offsets from the - /// start of the section for that jump table index. - std::vector JTLocations; - - /// MBBLocations - This vector is a mapping from MBB ID's to their address. - /// It is filled in by the StartMachineBasicBlock callback and queried by - /// the getMachineBasicBlockAddress callback. - std::vector MBBLocations; - - /// FnStartPtr - Pointer to the start location of the current function - /// in the buffer - uint8_t *FnStartPtr; + /// FnStartPtr - Function offset from the beginning of ELFSection 'ES' + uintptr_t FnStartOff; /// JumpTableSectionIdx - Holds the index of the Jump Table Section unsigned JumpTableSectionIdx; @@ -59,71 +40,36 @@ explicit ELFCodeEmitter(ELFWriter &ew) : EW(ew), TM(EW.TM), JumpTableSectionIdx(0) {} - void startFunction(MachineFunction &F); - bool finishFunction(MachineFunction &F); - + /// addRelocation - Register new relocations for this function void addRelocation(const MachineRelocation &MR) { Relocations.push_back(MR); } - virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { - if (MBBLocations.size() <= (unsigned)MBB->getNumber()) - MBBLocations.resize((MBB->getNumber()+1)*2); - MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); - } + /// emitConstantPool - For each constant pool entry, figure out which + /// section the constant should live in and emit data to it + void emitConstantPool(MachineConstantPool *MCP); - virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const { - assert(CPLocations.size() > Index && "CP not emitted!"); - return CPLocations[Index]; - } + /// emitJumpTables - Emit all the jump tables for a given jump table + /// info and record them to the appropriate section. + void emitJumpTables(MachineJumpTableInfo *MJTI); - virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const { - assert(JTLocations.size() > Index && "JT not emitted!"); - return JTLocations[Index]; - } + void startFunction(MachineFunction &F); + bool finishFunction(MachineFunction &F); - virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const { - assert(MBBLocations.size() > (unsigned)MBB->getNumber() && - MBBLocations[MBB->getNumber()] && "MBB not emitted!"); - return MBBLocations[MBB->getNumber()]; + /// emitLabel - Emits a label + virtual void emitLabel(uint64_t LabelID) { + assert("emitLabel not implemented"); } + /// getLabelAddress - Return the address of the specified LabelID, + /// only usable after the LabelID has been emitted. virtual uintptr_t getLabelAddress(uint64_t Label) const { - assert(0 && "Label address not implementated yet!"); - abort(); + assert("getLabelAddress not implemented"); return 0; } - virtual void emitLabel(uint64_t LabelID) { - assert(0 && "emit Label not implementated yet!"); - abort(); - } - - /// emitConstantPool - For each constant pool entry, figure out which section - /// the constant should live in and emit the constant. - void emitConstantPool(MachineConstantPool *MCP); - - /// emitJumpTables - Emit all the jump tables for a given jump table info - /// record to the appropriate section. - void emitJumpTables(MachineJumpTableInfo *MJTI); - virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) {} - /// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE! - void startGVStub(const GlobalValue* F, unsigned StubSize, - unsigned Alignment = 1) { - assert(0 && "JIT specific function called!"); - abort(); - } - void startGVStub(const GlobalValue* F, void *Buffer, unsigned StubSize) { - assert(0 && "JIT specific function called!"); - abort(); - } - void *finishGVStub(const GlobalValue *F) { - assert(0 && "JIT specific function called!"); - abort(); - return 0; - } }; // end class ELFCodeEmitter } // end namespace llvm Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.cpp?rev=74821&r1=74820&r2=74821&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ELFWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/ELFWriter.cpp Mon Jul 6 04:26:48 2009 @@ -51,17 +51,18 @@ #include "llvm/Support/Streams.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Debug.h" + using namespace llvm; char ELFWriter::ID = 0; -/// AddELFWriter - Concrete function to add the ELF writer to the function pass -/// manager. + +/// AddELFWriter - Add the ELF writer to the function pass manager ObjectCodeEmitter *llvm::AddELFWriter(PassManagerBase &PM, - raw_ostream &O, - TargetMachine &TM) { + raw_ostream &O, + TargetMachine &TM) { ELFWriter *EW = new ELFWriter(O, TM); PM.add(EW); - return (ObjectCodeEmitter*) &EW->getMachineCodeEmitter(); + return EW->getObjectCodeEmitter(); } //===----------------------------------------------------------------------===// @@ -77,15 +78,15 @@ TAI = TM.getTargetAsmInfo(); TEW = TM.getELFWriterInfo(); - // Create the machine code emitter object for this target. - MCE = new ELFCodeEmitter(*this); + // Create the object code emitter object for this target. + ElfCE = new ELFCodeEmitter(*this); // Inital number of sections NumSections = 0; } ELFWriter::~ELFWriter() { - delete MCE; + delete ElfCE; } // doInitialization - Emit the file header and all of the global variables for @@ -361,23 +362,13 @@ bool ELFWriter::runOnMachineFunction(MachineFunction &MF) { - // Nothing to do here, this is all done through the MCE object above. + // Nothing to do here, this is all done through the ElfCE object above. return false; } /// doFinalization - Now that the module has been completely processed, emit /// the ELF file to 'O'. bool ELFWriter::doFinalization(Module &M) { - /// FIXME: This should be removed when moving to ObjectCodeEmiter. Since the - /// current ELFCodeEmiter uses CurrBuff, ... it doesn't update S.Data - /// vector size for .text sections, so this is a quick dirty fix - ELFSection &TS = getTextSection(); - if (TS.Size) { - BinaryData &BD = TS.getData(); - for (unsigned e=0; e(ElfCE); } ELFWriter(raw_ostream &O, TargetMachine &TM); ~ELFWriter(); - typedef std::vector DataBuffer; - protected: /// Output stream to send the resultant object file to. raw_ostream &O; @@ -67,7 +67,7 @@ /// MCE - The MachineCodeEmitter object that we are exposing to emit machine /// code for functions to the .o file. - ELFCodeEmitter *MCE; + ELFCodeEmitter *ElfCE; /// TAI - Target Asm Info, provide information about section names for /// globals and other target specific stuff. From sanjiv.gupta at microchip.com Mon Jul 6 05:18:44 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Mon, 06 Jul 2009 10:18:44 -0000 Subject: [llvm-commits] [llvm] r74822 - in /llvm/trunk/lib: CompilerDriver/BuiltinOptions.cpp CompilerDriver/Main.cpp Target/PIC16/PIC16.h Target/PIC16/PIC16AsmPrinter.cpp Target/PIC16/PIC16TargetAsmInfo.cpp Target/PIC16/PIC16TargetAsmInfo.h Message-ID: <200907061018.n66AIjau015273@zion.cs.uiuc.edu> Author: sgupta Date: Mon Jul 6 05:18:37 2009 New Revision: 74822 URL: http://llvm.org/viewvc/llvm-project?rev=74822&view=rev Log: Implement _CONFIG macro to allow users to se to configuration settings on the part. Implement _section macro to allow users to place objects in specific sections. Implement _address macro to allow users to place objects at a particular address. Placing objects at a memory address: crate a unique section name from varname, address, object type and put that section at specified address. Mark this section a full (size = banksize) so that other objects do not compete for it while placing objects to sections in AsmPrinter. Modified: llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp llvm/trunk/lib/CompilerDriver/Main.cpp llvm/trunk/lib/Target/PIC16/PIC16.h llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.h Modified: llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp?rev=74822&r1=74821&r2=74822&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp (original) +++ llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp Mon Jul 6 05:18:37 2009 @@ -52,4 +52,5 @@ "Use current working directory"), clEnumValN(SaveTempsEnum::Obj, "", "Same as 'cwd'"), clEnumValEnd), - cl::ValueOptional); + //cl::ValueOptional); + cl::Hidden); Modified: llvm/trunk/lib/CompilerDriver/Main.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Main.cpp?rev=74822&r1=74821&r2=74822&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Main.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Main.cpp Mon Jul 6 05:18:37 2009 @@ -31,6 +31,17 @@ sys::Path getTempDir() { sys::Path tempDir; +///////////////////////////////////////////// + std::string p = "tmp-objs"; + tempDir = sys::Path(p); + if (!tempDir.exists()) { + std::string ErrMsg; + if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) + throw std::runtime_error(ErrMsg); + } + return tempDir; +///////////////////////////////////////////// + // GCC 4.5-style -save-temps handling. if (SaveTemps == SaveTempsEnum::Unset) { tempDir = sys::Path::GetTemporaryDirectory(); Modified: llvm/trunk/lib/Target/PIC16/PIC16.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16.h?rev=74822&r1=74821&r2=74822&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16.h Mon Jul 6 05:18:37 2009 @@ -221,17 +221,29 @@ return Func1 + tag + "# CODE"; } - // udata and idata section names are generated by a given number. + // udata, romdata and idata section names are generated by a given number. // @udata..# - static std::string getUdataSectionName(unsigned num) { + static std::string getUdataSectionName(unsigned num, + std::string prefix = "") { std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << "udata." << num << ".# UDATA"; + o << getTagName(PREFIX_SYMBOL) << prefix << "udata." << num + << ".# UDATA"; return o.str(); } - static std::string getIdataSectionName(unsigned num) { + static std::string getRomdataSectionName(unsigned num, + std::string prefix = "") { std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << "idata." << num << ".# IDATA"; + o << getTagName(PREFIX_SYMBOL) << prefix << "romdata." << num + << ".# ROMDATA"; + return o.str(); + } + + static std::string getIdataSectionName(unsigned num, + std::string prefix = "") { + std::ostringstream o; + o << getTagName(PREFIX_SYMBOL) << prefix << "idata." << num + << ".# IDATA"; return o.str(); } Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp?rev=74822&r1=74821&r2=74822&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Mon Jul 6 05:18:37 2009 @@ -272,18 +272,19 @@ // Emit initialized data placed in ROM. void PIC16AsmPrinter::EmitRomData (Module &M) { - - std::vector Items = PTAI->ROSection->Items; - if (! Items.size()) return; - - // Print ROData ection. - O << "\n"; - SwitchToSection(PTAI->ROSection->S_); - for (unsigned j = 0; j < Items.size(); j++) { - O << Mang->getValueName(Items[j]); - Constant *C = Items[j]->getInitializer(); - int AddrSpace = Items[j]->getType()->getAddressSpace(); - EmitGlobalConstant(C, AddrSpace); + // Print ROM Data section. + std::vector ROSections = PTAI->ROSections; + for (unsigned i = 0; i < ROSections.size(); i++) { + std::vector Items = ROSections[i]->Items; + if (! Items.size()) continue; + O << "\n"; + SwitchToSection(PTAI->ROSections[i]->S_); + for (unsigned j = 0; j < Items.size(); j++) { + O << Mang->getValueName(Items[j]); + Constant *C = Items[j]->getInitializer(); + int AddrSpace = Items[j]->getType()->getAddressSpace(); + EmitGlobalConstant(C, AddrSpace); + } } } Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp?rev=74822&r1=74821&r2=74822&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp Mon Jul 6 05:18:37 2009 @@ -44,7 +44,8 @@ // Need because otherwise a .text symbol is emitted by DwarfWriter // in BeginModule, and gpasm cribbs for that .text symbol. TextSection = getUnnamedSection("", SectionFlags::Code); - ROSection = new PIC16Section(getReadOnlySection()); + PIC16Section *ROSection = new PIC16Section(getReadOnlySection()); + ROSections.push_back(ROSection); ExternalVarDecls = new PIC16Section(getNamedSection("ExternalVarDecls")); ExternalVarDefs = new PIC16Section(getNamedSection("ExternalVarDefs")); // Set it to false because we weed to generate c file name and not bc file @@ -235,10 +236,8 @@ return getIDATASectionForGlobal(GV); // This is initialized data in rom, put it in the readonly section. - if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) { - ROSection->Items.push_back(GV); - return ROSection->S_; - } + if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) + return getROSectionForGlobal(GV); // Else let the default implementation take care of it. return TargetAsmInfo::SelectSectionForGlobal(GV); @@ -258,7 +257,191 @@ delete AutosSections[i]; } - delete ROSection; + for (unsigned i = 0; i < ROSections.size(); i++) { + delete ROSections[i]; + } + delete ExternalVarDecls; delete ExternalVarDefs; } + +// Override the default implementation. Create PIC16sections for variables +// which have a section name or address. +const Section* +PIC16TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const { + const Section* S; + // If GV has a sectin name or section address create that section now. + if (GV->hasSection()) { + std::string SectName = GV->getSection(); + // If address for a variable is specified, get the address and create + // section. + std::string AddrStr = "Address="; + if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) { + std::string SectAddr = SectName.substr(AddrStr.length()); + S = CreateSectionForGlobal(GV, SectAddr); + } + else { + S = CreateSectionForGlobal(GV); + } + } else { + // Use section depending on the 'type' of variable + S = SelectSectionForGlobal(GV); + } + return S; +} + +// Create a new section for global variable. If Addr is given then create +// section at that address else create by name. +const Section * +PIC16TargetAsmInfo::CreateSectionForGlobal(const GlobalValue *GV1, + std::string Addr) const { + const GlobalVariable *GV = dyn_cast(GV1); + + if (!GV) + return TargetAsmInfo::SectionForGlobal(GV1); + + // See if this is an uninitialized global. + const Constant *C = GV->getInitializer(); + if (C->isNullValue()) + return CreateBSSSectionForGlobal(GV, Addr); + + // If this is initialized data in RAM. Put it in the correct IDATA section. + if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) + return CreateIDATASectionForGlobal(GV, Addr); + + // This is initialized data in rom, put it in the readonly section. + if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) + return CreateROSectionForGlobal(GV, Addr); + + // Else let the default implementation take care of it. + return TargetAsmInfo::SectionForGlobal(GV); +} + +// Create uninitialized section for a variable. +const Section * +PIC16TargetAsmInfo::CreateBSSSectionForGlobal(const GlobalVariable *GV, + std::string Addr) const { + assert (GV->hasInitializer() && "This global doesn't need space"); + Constant *C = GV->getInitializer(); + assert (C->isNullValue() && "Unitialized globals has non-zero initializer"); + std::string Name; + // If address is given then create a section at that address else create a + // section by section name specified in GV. + PIC16Section *FoundBSS = NULL; + if (Addr.empty()) { + Name = GV->getSection() + " UDATA"; + for (unsigned i = 0; i < BSSSections.size(); i++) { + if (BSSSections[i]->S_->getName() == Name) { + FoundBSS = BSSSections[i]; + break; + } + } + } + else { + std::string Prefix = GV->getName() + "." + Addr + "."; + Name = PAN::getUdataSectionName(BSSSections.size(), Prefix) + " " + Addr; + } + + PIC16Section *NewBSS = FoundBSS; + if (NewBSS == NULL) { + const Section *NewSection = getNamedSection (Name.c_str()); + NewBSS = new PIC16Section(NewSection); + BSSSections.push_back(NewBSS); + } + + // Insert the GV into this BSS. + NewBSS->Items.push_back(GV); + + // We do not want to put any GV without explicit section into this section + // so set its size to DatabankSize. + NewBSS->Size = DataBankSize; + return NewBSS->S_; +} + +// Get rom section for a variable. Currently there can be only one rom section +// unless a variable explicitly requests a section. +const Section * +PIC16TargetAsmInfo::getROSectionForGlobal(const GlobalVariable *GV) const { + ROSections[0]->Items.push_back(GV); + return ROSections[0]->S_; +} + +// Create initialized data section for a variable. +const Section * +PIC16TargetAsmInfo::CreateIDATASectionForGlobal(const GlobalVariable *GV, + std::string Addr) const { + assert (GV->hasInitializer() && "This global doesn't need space"); + Constant *C = GV->getInitializer(); + assert (!C->isNullValue() && "initialized globals has zero initializer"); + assert (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE && + "can be used for initialized RAM data only"); + + std::string Name; + // If address is given then create a section at that address else create a + // section by section name specified in GV. + PIC16Section *FoundIDATASec = NULL; + if (Addr.empty()) { + Name = GV->getSection() + " IDATA"; + for (unsigned i = 0; i < IDATASections.size(); i++) { + if (IDATASections[i]->S_->getName() == Name) { + FoundIDATASec = IDATASections[i]; + break; + } + } + } + else { + std::string Prefix = GV->getName() + "." + Addr + "."; + Name = PAN::getIdataSectionName(IDATASections.size(), Prefix) + " " + Addr; + } + + PIC16Section *NewIDATASec = FoundIDATASec; + if (NewIDATASec == NULL) { + const Section *NewSection = getNamedSection (Name.c_str()); + NewIDATASec = new PIC16Section(NewSection); + IDATASections.push_back(NewIDATASec); + } + // Insert the GV into this IDATA Section. + NewIDATASec->Items.push_back(GV); + // We do not want to put any GV without explicit section into this section + // so set its size to DatabankSize. + NewIDATASec->Size = DataBankSize; + return NewIDATASec->S_; +} + +// Create a section in rom for a variable. +const Section * +PIC16TargetAsmInfo::CreateROSectionForGlobal(const GlobalVariable *GV, + std::string Addr) const { + assert (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE && + "can be used for ROM data only"); + + std::string Name; + // If address is given then create a section at that address else create a + // section by section name specified in GV. + PIC16Section *FoundROSec = NULL; + if (Addr.empty()) { + Name = GV->getSection() + " ROMDATA"; + for (unsigned i = 1; i < ROSections.size(); i++) { + if (ROSections[i]->S_->getName() == Name) { + FoundROSec = ROSections[i]; + break; + } + } + } + else { + std::string Prefix = GV->getName() + "." + Addr + "."; + Name = PAN::getRomdataSectionName(ROSections.size(), Prefix) + " " + Addr; + } + + PIC16Section *NewRomSec = FoundROSec; + if (NewRomSec == NULL) { + const Section *NewSection = getNamedSection (Name.c_str()); + NewRomSec = new PIC16Section(NewSection); + ROSections.push_back(NewRomSec); + } + + // Insert the GV into this ROM Section. + NewRomSec->Items.push_back(GV); + return NewRomSec->S_; +} + Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.h?rev=74822&r1=74821&r2=74822&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.h Mon Jul 6 05:18:37 2009 @@ -48,7 +48,7 @@ mutable std::vector BSSSections; mutable std::vector IDATASections; mutable std::vector AutosSections; - mutable PIC16Section *ROSection; + mutable std::vector ROSections; mutable PIC16Section *ExternalVarDecls; mutable PIC16Section *ExternalVarDefs; virtual ~PIC16TargetAsmInfo(); @@ -62,9 +62,16 @@ const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const; const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const; const Section *getSectionForAuto(const GlobalVariable *GV) const; + const Section *CreateBSSSectionForGlobal(const GlobalVariable *GV, + std::string Addr = "") const; + const Section *CreateIDATASectionForGlobal(const GlobalVariable *GV, + std::string Addr = "") const; + const Section *getROSectionForGlobal(const GlobalVariable *GV) const; + const Section *CreateROSectionForGlobal(const GlobalVariable *GV, + std::string Addr = "") const; virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const; - - + const Section * CreateSectionForGlobal(const GlobalValue *GV, + std::string Addr = "") const; public: void SetSectionForGVs(Module &M); std::vector getBSSSections() const { @@ -76,6 +83,10 @@ std::vector getAutosSections() const { return AutosSections; } + std::vector getROSections() const { + return ROSections; + } + virtual const Section* SectionForGlobal(const GlobalValue *GV) const; }; } // namespace llvm From anton at korobeynikov.info Mon Jul 6 05:24:41 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Mon, 6 Jul 2009 14:24:41 +0400 Subject: [llvm-commits] [llvm] r74822 - in /llvm/trunk/lib: CompilerDriver/BuiltinOptions.cpp CompilerDriver/Main.cpp Target/PIC16/PIC16.h Target/PIC16/PIC16AsmPrinter.cpp Target/PIC16/PIC16TargetAsmInfo.cpp Target/PIC16/PIC16TargetAsmInfo.h In-Reply-To: <200907061018.n66AIjau015273@zion.cs.uiuc.edu> References: <200907061018.n66AIjau015273@zion.cs.uiuc.edu> Message-ID: Hello, Sanjiv > +///////////////////////////////////////////// > + std::string p = "tmp-objs"; > + tempDir = sys::Path(p); > + if (!tempDir.exists()) { > + std::string ErrMsg; > + if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) > + throw std::runtime_error(ErrMsg); > + } > + return tempDir; > +///////////////////////////////////////////// > + Revert this hunk, please, it breaks the whole driver. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anton at korobeynikov.info Mon Jul 6 05:25:52 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Mon, 6 Jul 2009 14:25:52 +0400 Subject: [llvm-commits] [llvm] r74822 - in /llvm/trunk/lib: CompilerDriver/BuiltinOptions.cpp CompilerDriver/Main.cpp Target/PIC16/PIC16.h Target/PIC16/PIC16AsmPrinter.cpp Target/PIC16/PIC16TargetAsmInfo.cpp Target/PIC16/PIC16TargetAsmInfo.h In-Reply-To: <200907061018.n66AIjau015273@zion.cs.uiuc.edu> References: <200907061018.n66AIjau015273@zion.cs.uiuc.edu> Message-ID: ============================================================================== > --- llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp (original) > +++ llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp Mon Jul 6 05:18:37 2009 > @@ -52,4 +52,5 @@ > "Use current working directory"), > clEnumValN(SaveTempsEnum::Obj, "", "Same as 'cwd'"), > clEnumValEnd), > - cl::ValueOptional); > + //cl::ValueOptional); > + cl::Hidden); And this one - too. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From sanjiv.gupta at microchip.com Mon Jul 6 05:34:24 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Mon, 06 Jul 2009 10:34:24 -0000 Subject: [llvm-commits] [llvm] r74823 - in /llvm/trunk/lib/CompilerDriver: BuiltinOptions.cpp Main.cpp Message-ID: <200907061034.n66AYPWS015997@zion.cs.uiuc.edu> Author: sgupta Date: Mon Jul 6 05:34:10 2009 New Revision: 74823 URL: http://llvm.org/viewvc/llvm-project?rev=74823&view=rev Log: Reverting back the changes checked-in accidently. Modified: llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp llvm/trunk/lib/CompilerDriver/Main.cpp Modified: llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp?rev=74823&r1=74822&r2=74823&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp (original) +++ llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp Mon Jul 6 05:34:10 2009 @@ -52,5 +52,4 @@ "Use current working directory"), clEnumValN(SaveTempsEnum::Obj, "", "Same as 'cwd'"), clEnumValEnd), - //cl::ValueOptional); - cl::Hidden); + cl::ValueOptional); Modified: llvm/trunk/lib/CompilerDriver/Main.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Main.cpp?rev=74823&r1=74822&r2=74823&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Main.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Main.cpp Mon Jul 6 05:34:10 2009 @@ -31,17 +31,6 @@ sys::Path getTempDir() { sys::Path tempDir; -///////////////////////////////////////////// - std::string p = "tmp-objs"; - tempDir = sys::Path(p); - if (!tempDir.exists()) { - std::string ErrMsg; - if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) - throw std::runtime_error(ErrMsg); - } - return tempDir; -///////////////////////////////////////////// - // GCC 4.5-style -save-temps handling. if (SaveTemps == SaveTempsEnum::Unset) { tempDir = sys::Path::GetTemporaryDirectory(); From xerxes at zafena.se Mon Jul 6 05:57:02 2009 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Mon, 06 Jul 2009 12:57:02 +0200 Subject: [llvm-commits] [patch] fix for: llvm_start_multithreaded() failed Message-ID: <4A51D87E.3090908@zafena.se> Greetings! when using the current llvm svn tip with the curent icedtea6 tip to compile OpenJDK i got a binary that complained alot that llvm_start_multithreaded failed to initialize. OpenJDK Shark VM warning: llvm_start_multithreaded() failed The attached patch fixes this issue: llvm/lib/System/Threading.cpp Let the LLVM_MULTITHREADED macro propagate from config.h to Threading.cpp so that the multithreaded llvm implementation are actually compiled in and used. Have a great day! Xerxes -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm_start_multithreaded_LLVM_MULTITHREADED_config.h.patch Type: text/x-patch Size: 418 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090706/77a57dae/attachment.bin From xerxes at zafena.se Mon Jul 6 07:52:43 2009 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Mon, 06 Jul 2009 14:52:43 +0200 Subject: [llvm-commits] [patch] cmake add lib/CodeGen/ObjectCodeEmitter.cpp Message-ID: <4A51F39B.3080408@zafena.se> fixes: ../../lib/libLLVMAlphaCodeGen.a(AlphaCodeEmitter.cpp.o): In function `(anonymous namespace)::Emitter::emitBasicBlock(llvm::MachineBasicBlock&)': AlphaCodeEmitter.cpp:(.text+0x132c): undefined reference to `llvm::ObjectCodeEmitter::emitWordLE(unsigned int and similar issues for cmake builds. -------------- next part -------------- A non-text attachment was scrubbed... Name: cmake_add_ObjectCodeEmitter.cpp.patch Type: text/x-patch Size: 417 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090706/8a9ce30a/attachment.bin From aaronngray.lists at googlemail.com Mon Jul 6 08:55:17 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 14:55:17 +0100 Subject: [llvm-commits] [llvm] r74814 - in /llvm/trunk: include/llvm/CodeGen/ObjectCodeEmitter.h lib/CodeGen/ObjectCodeEmitter.cpp References: <200907060516.n665Gekx026755@zion.cs.uiuc.edu> Message-ID: <7669CA9A7D814D5DBD8507485499BCD5@HPLAPTOP> The ObjectCodeEmitter was ment to be inline code to be used by the *CodeEmitter classes to end up with super fast code generation. Putting them as noninline classes is a bad idea. Basically this is why I/we parameterized the *CodeEmitter Classes in the first place. Aaron > Author: bruno > Date: Mon Jul 6 00:16:40 2009 > New Revision: 74814 > > URL: http://llvm.org/viewvc/llvm-project?rev=74814&view=rev > Log: > Just forgot to include the two new files > > Added: > llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h > llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp > > Added: llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h?rev=74814&view=auto > > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h (added) > +++ llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h Mon Jul 6 > 00:16:40 2009 > @@ -0,0 +1,171 @@ > +//===-- llvm/CodeGen/ObjectCodeEmitter.h - Object Code Emitter -*- > C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// Generalized Object Code Emitter, works with ObjectModule and > BinaryObject. > +// > +//===----------------------------------------------------------------------===// > + > +#ifndef LLVM_CODEGEN_OBJECTCODEEMITTER_H > +#define LLVM_CODEGEN_OBJECTCODEEMITTER_H > + > +#include "llvm/CodeGen/MachineCodeEmitter.h" > + > +namespace llvm { > + > +class BinaryObject; > +class MachineBasicBlock; > +class MachineCodeEmitter; > +class MachineFunction; > +class MachineConstantPool; > +class MachineJumpTableInfo; > +class MachineModuleInfo; > + > +class ObjectCodeEmitter : public MachineCodeEmitter { > +protected: > + > + /// Binary Object (Section or Segment) we are emitting to. > + BinaryObject *BO; > + > + /// MBBLocations - This vector is a mapping from MBB ID's to their > address. > + /// It is filled in by the StartMachineBasicBlock callback and queried > by > + /// the getMachineBasicBlockAddress callback. > + std::vector MBBLocations; > + > + /// LabelLocations - This vector is a mapping from Label ID's to their > + /// address. > + std::vector LabelLocations; > + > + /// CPLocations - This is a map of constant pool indices to offsets > from the > + /// start of the section for that constant pool index. > + std::vector CPLocations; > + > + /// CPSections - This is a map of constant pool indices to the Section > + /// containing the constant pool entry for that index. > + std::vector CPSections; > + > + /// JTLocations - This is a map of jump table indices to offsets from > the > + /// start of the section for that jump table index. > + std::vector JTLocations; > + > +public: > + ObjectCodeEmitter(); > + ObjectCodeEmitter(BinaryObject *bo); > + virtual ~ObjectCodeEmitter(); > + > + /// setBinaryObject - set the BinaryObject we are writting to > + void setBinaryObject(BinaryObject *bo); > + > + /// emitByte - This callback is invoked when a byte needs to be > + /// written to the data stream, without buffer overflow testing. > + void emitByte(uint8_t B); > + > + /// emitWordLE - This callback is invoked when a 32-bit word needs to > be > + /// written to the data stream in little-endian format. > + void emitWordLE(uint32_t W); > + > + /// emitWordBE - This callback is invoked when a 32-bit word needs to > be > + /// written to the data stream in big-endian format. > + void emitWordBE(uint32_t W); > + > + /// emitDWordLE - This callback is invoked when a 64-bit word needs to > be > + /// written to the data stream in little-endian format. > + void emitDWordLE(uint64_t W); > + > + /// emitDWordBE - This callback is invoked when a 64-bit word needs to > be > + /// written to the data stream in big-endian format. > + void emitDWordBE(uint64_t W); > + > + /// emitAlignment - Move the CurBufferPtr pointer up the the specified > + /// alignment (saturated to BufferEnd of course). > + void emitAlignment(unsigned Alignment = 0, uint8_t fill = 0); > + > + /// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to > be > + /// written to the data stream. > + void emitULEB128Bytes(uint64_t Value); > + > + /// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to > be > + /// written to the data stream. > + void emitSLEB128Bytes(uint64_t Value); > + > + /// emitString - This callback is invoked when a String needs to be > + /// written to the data stream. > + void emitString(const std::string &String); > + > + /// getCurrentPCValue - This returns the address that the next emitted > byte > + /// will be output to. > + uintptr_t getCurrentPCValue() const; > + > + /// getCurrentPCOffset - Return the offset from the start of the > emitted > + /// buffer that we are currently writing to. > + uintptr_t getCurrentPCOffset() const; > + > + /// addRelocation - Whenever a relocatable address is needed, it should > be > + /// noted with this interface. > + void addRelocation(const MachineRelocation& relocation); > + > + /// startFunction - This callback is invoked when the specified > function is > + /// about to be code generated. This initializes the > BufferBegin/End/Ptr > + /// fields. > + virtual void startFunction(MachineFunction &F) = 0; > + > + /// finishFunction - This callback is invoked when the specified > function has > + /// finished code generation. If a buffer overflow has occurred, this > method > + /// returns true (the callee is required to try again), otherwise it > returns > + /// false. > + virtual bool finishFunction(MachineFunction &F) = 0; > + > + /// StartMachineBasicBlock - This should be called by the target when a > new > + /// basic block is about to be emitted. This way the MCE knows where > the > + /// start of the block is, and can implement > getMachineBasicBlockAddress. > + virtual void StartMachineBasicBlock(MachineBasicBlock *MBB); > + > + /// getMachineBasicBlockAddress - Return the address of the specified > + /// MachineBasicBlock, only usable after the label for the MBB has been > + /// emitted. > + virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) > const; > + > + /// emitLabel - Emits a label > + virtual void emitLabel(uint64_t LabelID) = 0; > + > + /// getLabelAddress - Return the address of the specified LabelID, only > usable > + /// after the LabelID has been emitted. > + virtual uintptr_t getLabelAddress(uint64_t LabelID) const = 0; > + > + /// emitJumpTables - Emit all the jump tables for a given jump table > info > + /// record to the appropriate section. > + virtual void emitJumpTables(MachineJumpTableInfo *MJTI) = 0; > + > + /// getJumpTableEntryAddress - Return the address of the jump table > with index > + /// 'Index' in the function that last called initJumpTableInfo. > + virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const; > + > + /// emitConstantPool - For each constant pool entry, figure out which > section > + /// the constant should live in, allocate space for it, and emit it to > the > + /// Section data buffer. > + virtual void emitConstantPool(MachineConstantPool *MCP) = 0; > + > + /// getConstantPoolEntryAddress - Return the address of the 'Index' > entry in > + /// the constant pool that was last emitted with the emitConstantPool > method. > + virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const; > + > + /// getConstantPoolEntrySection - Return the section of the 'Index' > entry in > + /// the constant pool that was last emitted with the emitConstantPool > method. > + virtual uintptr_t getConstantPoolEntrySection(unsigned Index) const; > + > + /// Specifies the MachineModuleInfo object. This is used for exception > handling > + /// purposes. > + virtual void setModuleInfo(MachineModuleInfo* Info) = 0; > + // to be implemented or depreciated with MachineModuleInfo > + > +}; // end class ObjectCodeEmitter > + > +} // end namespace llvm > + > +#endif > + > > Added: llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp?rev=74814&view=auto > > ============================================================================== > --- llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp (added) > +++ llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp Mon Jul 6 00:16:40 2009 > @@ -0,0 +1,142 @@ > +//===-- llvm/CodeGen/ObjectCodeEmitter.cpp -------------------- -*- > C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > + > +#include "llvm/CodeGen/BinaryObject.h" > +#include "llvm/CodeGen/MachineBasicBlock.h" > +#include "llvm/CodeGen/MachineRelocation.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > + > +//===----------------------------------------------------------------------===// > +// ObjectCodeEmitter Implementation > +//===----------------------------------------------------------------------===// > + > +namespace llvm { > + > +ObjectCodeEmitter::ObjectCodeEmitter() : BO(0) {} > +ObjectCodeEmitter::ObjectCodeEmitter(BinaryObject *bo) : BO(bo) {} > +ObjectCodeEmitter::~ObjectCodeEmitter() {} > + > +/// setBinaryObject - set the BinaryObject we are writting to > +void ObjectCodeEmitter::setBinaryObject(BinaryObject *bo) { BO = bo; } > + > +/// emitByte - This callback is invoked when a byte needs to be > +/// written to the data stream, without buffer overflow testing. > +void ObjectCodeEmitter::emitByte(uint8_t B) { > + BO->emitByte(B); > +} > + > +/// emitWordLE - This callback is invoked when a 32-bit word needs to be > +/// written to the data stream in little-endian format. > +void ObjectCodeEmitter::emitWordLE(uint32_t W) { > + BO->emitWordLE(W); > +} > + > +/// emitWordBE - This callback is invoked when a 32-bit word needs to be > +/// written to the data stream in big-endian format. > +void ObjectCodeEmitter::emitWordBE(uint32_t W) { > + BO->emitWordBE(W); > +} > + > +/// emitDWordLE - This callback is invoked when a 64-bit word needs to be > +/// written to the data stream in little-endian format. > +void ObjectCodeEmitter::emitDWordLE(uint64_t W) { > + BO->emitDWordLE(W); > +} > + > +/// emitDWordBE - This callback is invoked when a 64-bit word needs to be > +/// written to the data stream in big-endian format. > +void ObjectCodeEmitter::emitDWordBE(uint64_t W) { > + BO->emitDWordBE(W); > +} > + > +/// emitAlignment - Move the CurBufferPtr pointer up the the specified > +/// alignment (saturated to BufferEnd of course). > +void ObjectCodeEmitter::emitAlignment(unsigned Alignment /* 0 */, > + uint8_t fill /* 0 */) { > + BO->emitAlignment(Alignment, fill); > +} > + > +/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to > be > +/// written to the data stream. > +void ObjectCodeEmitter::emitULEB128Bytes(uint64_t Value) { > + BO->emitULEB128Bytes(Value); > +} > + > +/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to > be > +/// written to the data stream. > +void ObjectCodeEmitter::emitSLEB128Bytes(uint64_t Value) { > + BO->emitSLEB128Bytes(Value); > +} > + > +/// emitString - This callback is invoked when a String needs to be > +/// written to the data stream. > +void ObjectCodeEmitter::emitString(const std::string &String) { > + BO->emitString(String); > +} > + > +/// getCurrentPCValue - This returns the address that the next emitted > byte > +/// will be output to. > +uintptr_t ObjectCodeEmitter::getCurrentPCValue() const { > + return BO->getCurrentPCOffset(); > +} > + > +/// getCurrentPCOffset - Return the offset from the start of the emitted > +/// buffer that we are currently writing to. > +uintptr_t ObjectCodeEmitter::getCurrentPCOffset() const { > + return BO->getCurrentPCOffset(); > +} > + > +/// addRelocation - Whenever a relocatable address is needed, it should > be > +/// noted with this interface. > +void ObjectCodeEmitter::addRelocation(const MachineRelocation& > relocation) { > + BO->addRelocation(relocation); > +} > + > +/// StartMachineBasicBlock - This should be called by the target when a > new > +/// basic block is about to be emitted. This way the MCE knows where the > +/// start of the block is, and can implement getMachineBasicBlockAddress. > +void ObjectCodeEmitter::StartMachineBasicBlock(MachineBasicBlock *MBB) { > + if (MBBLocations.size() <= (unsigned)MBB->getNumber()) > + MBBLocations.resize((MBB->getNumber()+1)*2); > + MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); > +} > + > +/// getMachineBasicBlockAddress - Return the address of the specified > +/// MachineBasicBlock, only usable after the label for the MBB has been > +/// emitted. > +uintptr_t > +ObjectCodeEmitter::getMachineBasicBlockAddress(MachineBasicBlock *MBB) > const { > + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && > + MBBLocations[MBB->getNumber()] && "MBB not emitted!"); > + return MBBLocations[MBB->getNumber()]; > +} > + > +/// getJumpTableEntryAddress - Return the address of the jump table with > index > +/// 'Index' in the function that last called initJumpTableInfo. > +uintptr_t ObjectCodeEmitter::getJumpTableEntryAddress(unsigned Index) > const { > + assert(JTLocations.size() > Index && "JT not emitted!"); > + return JTLocations[Index]; > +} > + > +/// getConstantPoolEntryAddress - Return the address of the 'Index' entry > in > +/// the constant pool that was last emitted with the emitConstantPool > method. > +uintptr_t ObjectCodeEmitter::getConstantPoolEntryAddress(unsigned Index) > const { > + assert(CPLocations.size() > Index && "CP not emitted!"); > + return CPLocations[Index]; > +} > + > +/// getConstantPoolEntrySection - Return the section of the 'Index' entry > in > +/// the constant pool that was last emitted with the emitConstantPool > method. > +uintptr_t ObjectCodeEmitter::getConstantPoolEntrySection(unsigned Index) > const { > + assert(CPSections.size() > Index && "CP not emitted!"); > + return CPSections[Index]; > +} > + > +} // end namespace llvm > + > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From aaronngray.lists at googlemail.com Mon Jul 6 08:59:16 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 14:59:16 +0100 Subject: [llvm-commits] [llvm] r74814 - in /llvm/trunk: include/llvm/CodeGen/ObjectCodeEmitter.h lib/CodeGen/ObjectCodeEmitter.cpp References: <200907060516.n665Gekx026755@zion.cs.uiuc.edu> Message-ID: Bruno, You also removed the 'virtual' on 'uintptr_t ::ObjecCodeEmitter::getCurrentPCOffset() const'. This is critical for correct code generation on the *CodeEmitter. Aaron > Author: bruno > Date: Mon Jul 6 00:16:40 2009 > New Revision: 74814 > > URL: http://llvm.org/viewvc/llvm-project?rev=74814&view=rev > Log: > Just forgot to include the two new files > > Added: > llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h > llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp > > Added: llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h?rev=74814&view=auto > > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h (added) > +++ llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h Mon Jul 6 > 00:16:40 2009 > @@ -0,0 +1,171 @@ > +//===-- llvm/CodeGen/ObjectCodeEmitter.h - Object Code Emitter -*- > C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// Generalized Object Code Emitter, works with ObjectModule and > BinaryObject. > +// > +//===----------------------------------------------------------------------===// > + > +#ifndef LLVM_CODEGEN_OBJECTCODEEMITTER_H > +#define LLVM_CODEGEN_OBJECTCODEEMITTER_H > + > +#include "llvm/CodeGen/MachineCodeEmitter.h" > + > +namespace llvm { > + > +class BinaryObject; > +class MachineBasicBlock; > +class MachineCodeEmitter; > +class MachineFunction; > +class MachineConstantPool; > +class MachineJumpTableInfo; > +class MachineModuleInfo; > + > +class ObjectCodeEmitter : public MachineCodeEmitter { > +protected: > + > + /// Binary Object (Section or Segment) we are emitting to. > + BinaryObject *BO; > + > + /// MBBLocations - This vector is a mapping from MBB ID's to their > address. > + /// It is filled in by the StartMachineBasicBlock callback and queried > by > + /// the getMachineBasicBlockAddress callback. > + std::vector MBBLocations; > + > + /// LabelLocations - This vector is a mapping from Label ID's to their > + /// address. > + std::vector LabelLocations; > + > + /// CPLocations - This is a map of constant pool indices to offsets > from the > + /// start of the section for that constant pool index. > + std::vector CPLocations; > + > + /// CPSections - This is a map of constant pool indices to the Section > + /// containing the constant pool entry for that index. > + std::vector CPSections; > + > + /// JTLocations - This is a map of jump table indices to offsets from > the > + /// start of the section for that jump table index. > + std::vector JTLocations; > + > +public: > + ObjectCodeEmitter(); > + ObjectCodeEmitter(BinaryObject *bo); > + virtual ~ObjectCodeEmitter(); > + > + /// setBinaryObject - set the BinaryObject we are writting to > + void setBinaryObject(BinaryObject *bo); > + > + /// emitByte - This callback is invoked when a byte needs to be > + /// written to the data stream, without buffer overflow testing. > + void emitByte(uint8_t B); > + > + /// emitWordLE - This callback is invoked when a 32-bit word needs to > be > + /// written to the data stream in little-endian format. > + void emitWordLE(uint32_t W); > + > + /// emitWordBE - This callback is invoked when a 32-bit word needs to > be > + /// written to the data stream in big-endian format. > + void emitWordBE(uint32_t W); > + > + /// emitDWordLE - This callback is invoked when a 64-bit word needs to > be > + /// written to the data stream in little-endian format. > + void emitDWordLE(uint64_t W); > + > + /// emitDWordBE - This callback is invoked when a 64-bit word needs to > be > + /// written to the data stream in big-endian format. > + void emitDWordBE(uint64_t W); > + > + /// emitAlignment - Move the CurBufferPtr pointer up the the specified > + /// alignment (saturated to BufferEnd of course). > + void emitAlignment(unsigned Alignment = 0, uint8_t fill = 0); > + > + /// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to > be > + /// written to the data stream. > + void emitULEB128Bytes(uint64_t Value); > + > + /// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to > be > + /// written to the data stream. > + void emitSLEB128Bytes(uint64_t Value); > + > + /// emitString - This callback is invoked when a String needs to be > + /// written to the data stream. > + void emitString(const std::string &String); > + > + /// getCurrentPCValue - This returns the address that the next emitted > byte > + /// will be output to. > + uintptr_t getCurrentPCValue() const; > + > + /// getCurrentPCOffset - Return the offset from the start of the > emitted > + /// buffer that we are currently writing to. > + uintptr_t getCurrentPCOffset() const; > + > + /// addRelocation - Whenever a relocatable address is needed, it should > be > + /// noted with this interface. > + void addRelocation(const MachineRelocation& relocation); > + > + /// startFunction - This callback is invoked when the specified > function is > + /// about to be code generated. This initializes the > BufferBegin/End/Ptr > + /// fields. > + virtual void startFunction(MachineFunction &F) = 0; > + > + /// finishFunction - This callback is invoked when the specified > function has > + /// finished code generation. If a buffer overflow has occurred, this > method > + /// returns true (the callee is required to try again), otherwise it > returns > + /// false. > + virtual bool finishFunction(MachineFunction &F) = 0; > + > + /// StartMachineBasicBlock - This should be called by the target when a > new > + /// basic block is about to be emitted. This way the MCE knows where > the > + /// start of the block is, and can implement > getMachineBasicBlockAddress. > + virtual void StartMachineBasicBlock(MachineBasicBlock *MBB); > + > + /// getMachineBasicBlockAddress - Return the address of the specified > + /// MachineBasicBlock, only usable after the label for the MBB has been > + /// emitted. > + virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) > const; > + > + /// emitLabel - Emits a label > + virtual void emitLabel(uint64_t LabelID) = 0; > + > + /// getLabelAddress - Return the address of the specified LabelID, only > usable > + /// after the LabelID has been emitted. > + virtual uintptr_t getLabelAddress(uint64_t LabelID) const = 0; > + > + /// emitJumpTables - Emit all the jump tables for a given jump table > info > + /// record to the appropriate section. > + virtual void emitJumpTables(MachineJumpTableInfo *MJTI) = 0; > + > + /// getJumpTableEntryAddress - Return the address of the jump table > with index > + /// 'Index' in the function that last called initJumpTableInfo. > + virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const; > + > + /// emitConstantPool - For each constant pool entry, figure out which > section > + /// the constant should live in, allocate space for it, and emit it to > the > + /// Section data buffer. > + virtual void emitConstantPool(MachineConstantPool *MCP) = 0; > + > + /// getConstantPoolEntryAddress - Return the address of the 'Index' > entry in > + /// the constant pool that was last emitted with the emitConstantPool > method. > + virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const; > + > + /// getConstantPoolEntrySection - Return the section of the 'Index' > entry in > + /// the constant pool that was last emitted with the emitConstantPool > method. > + virtual uintptr_t getConstantPoolEntrySection(unsigned Index) const; > + > + /// Specifies the MachineModuleInfo object. This is used for exception > handling > + /// purposes. > + virtual void setModuleInfo(MachineModuleInfo* Info) = 0; > + // to be implemented or depreciated with MachineModuleInfo > + > +}; // end class ObjectCodeEmitter > + > +} // end namespace llvm > + > +#endif > + > > Added: llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp?rev=74814&view=auto > > ============================================================================== > --- llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp (added) > +++ llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp Mon Jul 6 00:16:40 2009 > @@ -0,0 +1,142 @@ > +//===-- llvm/CodeGen/ObjectCodeEmitter.cpp -------------------- -*- > C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > + > +#include "llvm/CodeGen/BinaryObject.h" > +#include "llvm/CodeGen/MachineBasicBlock.h" > +#include "llvm/CodeGen/MachineRelocation.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > + > +//===----------------------------------------------------------------------===// > +// ObjectCodeEmitter Implementation > +//===----------------------------------------------------------------------===// > + > +namespace llvm { > + > +ObjectCodeEmitter::ObjectCodeEmitter() : BO(0) {} > +ObjectCodeEmitter::ObjectCodeEmitter(BinaryObject *bo) : BO(bo) {} > +ObjectCodeEmitter::~ObjectCodeEmitter() {} > + > +/// setBinaryObject - set the BinaryObject we are writting to > +void ObjectCodeEmitter::setBinaryObject(BinaryObject *bo) { BO = bo; } > + > +/// emitByte - This callback is invoked when a byte needs to be > +/// written to the data stream, without buffer overflow testing. > +void ObjectCodeEmitter::emitByte(uint8_t B) { > + BO->emitByte(B); > +} > + > +/// emitWordLE - This callback is invoked when a 32-bit word needs to be > +/// written to the data stream in little-endian format. > +void ObjectCodeEmitter::emitWordLE(uint32_t W) { > + BO->emitWordLE(W); > +} > + > +/// emitWordBE - This callback is invoked when a 32-bit word needs to be > +/// written to the data stream in big-endian format. > +void ObjectCodeEmitter::emitWordBE(uint32_t W) { > + BO->emitWordBE(W); > +} > + > +/// emitDWordLE - This callback is invoked when a 64-bit word needs to be > +/// written to the data stream in little-endian format. > +void ObjectCodeEmitter::emitDWordLE(uint64_t W) { > + BO->emitDWordLE(W); > +} > + > +/// emitDWordBE - This callback is invoked when a 64-bit word needs to be > +/// written to the data stream in big-endian format. > +void ObjectCodeEmitter::emitDWordBE(uint64_t W) { > + BO->emitDWordBE(W); > +} > + > +/// emitAlignment - Move the CurBufferPtr pointer up the the specified > +/// alignment (saturated to BufferEnd of course). > +void ObjectCodeEmitter::emitAlignment(unsigned Alignment /* 0 */, > + uint8_t fill /* 0 */) { > + BO->emitAlignment(Alignment, fill); > +} > + > +/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to > be > +/// written to the data stream. > +void ObjectCodeEmitter::emitULEB128Bytes(uint64_t Value) { > + BO->emitULEB128Bytes(Value); > +} > + > +/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to > be > +/// written to the data stream. > +void ObjectCodeEmitter::emitSLEB128Bytes(uint64_t Value) { > + BO->emitSLEB128Bytes(Value); > +} > + > +/// emitString - This callback is invoked when a String needs to be > +/// written to the data stream. > +void ObjectCodeEmitter::emitString(const std::string &String) { > + BO->emitString(String); > +} > + > +/// getCurrentPCValue - This returns the address that the next emitted > byte > +/// will be output to. > +uintptr_t ObjectCodeEmitter::getCurrentPCValue() const { > + return BO->getCurrentPCOffset(); > +} > + > +/// getCurrentPCOffset - Return the offset from the start of the emitted > +/// buffer that we are currently writing to. > +uintptr_t ObjectCodeEmitter::getCurrentPCOffset() const { > + return BO->getCurrentPCOffset(); > +} > + > +/// addRelocation - Whenever a relocatable address is needed, it should > be > +/// noted with this interface. > +void ObjectCodeEmitter::addRelocation(const MachineRelocation& > relocation) { > + BO->addRelocation(relocation); > +} > + > +/// StartMachineBasicBlock - This should be called by the target when a > new > +/// basic block is about to be emitted. This way the MCE knows where the > +/// start of the block is, and can implement getMachineBasicBlockAddress. > +void ObjectCodeEmitter::StartMachineBasicBlock(MachineBasicBlock *MBB) { > + if (MBBLocations.size() <= (unsigned)MBB->getNumber()) > + MBBLocations.resize((MBB->getNumber()+1)*2); > + MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); > +} > + > +/// getMachineBasicBlockAddress - Return the address of the specified > +/// MachineBasicBlock, only usable after the label for the MBB has been > +/// emitted. > +uintptr_t > +ObjectCodeEmitter::getMachineBasicBlockAddress(MachineBasicBlock *MBB) > const { > + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && > + MBBLocations[MBB->getNumber()] && "MBB not emitted!"); > + return MBBLocations[MBB->getNumber()]; > +} > + > +/// getJumpTableEntryAddress - Return the address of the jump table with > index > +/// 'Index' in the function that last called initJumpTableInfo. > +uintptr_t ObjectCodeEmitter::getJumpTableEntryAddress(unsigned Index) > const { > + assert(JTLocations.size() > Index && "JT not emitted!"); > + return JTLocations[Index]; > +} > + > +/// getConstantPoolEntryAddress - Return the address of the 'Index' entry > in > +/// the constant pool that was last emitted with the emitConstantPool > method. > +uintptr_t ObjectCodeEmitter::getConstantPoolEntryAddress(unsigned Index) > const { > + assert(CPLocations.size() > Index && "CP not emitted!"); > + return CPLocations[Index]; > +} > + > +/// getConstantPoolEntrySection - Return the section of the 'Index' entry > in > +/// the constant pool that was last emitted with the emitConstantPool > method. > +uintptr_t ObjectCodeEmitter::getConstantPoolEntrySection(unsigned Index) > const { > + assert(CPSections.size() > Index && "CP not emitted!"); > + return CPSections[Index]; > +} > + > +} // end namespace llvm > + > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From aaronngray.lists at googlemail.com Mon Jul 6 09:03:14 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 15:03:14 +0100 Subject: [llvm-commits] [llvm] r74814 - in /llvm/trunk: include/llvm/CodeGen/ObjectCodeEmitter.h lib/CodeGen/ObjectCodeEmitter.cpp References: <200907060516.n665Gekx026755@zion.cs.uiuc.edu> Message-ID: <06885ECEBD364A47B9AC5057F2E6C279@HPLAPTOP> Ah, 'uintptr_t getCurrentPCOffset() const' is 'virtual' in MachineCodeEmitter :) Sorry, Aaron > Author: bruno > Date: Mon Jul 6 00:16:40 2009 > New Revision: 74814 > > URL: http://llvm.org/viewvc/llvm-project?rev=74814&view=rev > Log: > Just forgot to include the two new files > > Added: > llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h > llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp > > Added: llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h?rev=74814&view=auto > > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h (added) > +++ llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h Mon Jul 6 > 00:16:40 2009 > @@ -0,0 +1,171 @@ > +//===-- llvm/CodeGen/ObjectCodeEmitter.h - Object Code Emitter -*- > C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// Generalized Object Code Emitter, works with ObjectModule and > BinaryObject. > +// > +//===----------------------------------------------------------------------===// > + > +#ifndef LLVM_CODEGEN_OBJECTCODEEMITTER_H > +#define LLVM_CODEGEN_OBJECTCODEEMITTER_H > + > +#include "llvm/CodeGen/MachineCodeEmitter.h" > + > +namespace llvm { > + > +class BinaryObject; > +class MachineBasicBlock; > +class MachineCodeEmitter; > +class MachineFunction; > +class MachineConstantPool; > +class MachineJumpTableInfo; > +class MachineModuleInfo; > + > +class ObjectCodeEmitter : public MachineCodeEmitter { > +protected: > + > + /// Binary Object (Section or Segment) we are emitting to. > + BinaryObject *BO; > + > + /// MBBLocations - This vector is a mapping from MBB ID's to their > address. > + /// It is filled in by the StartMachineBasicBlock callback and queried > by > + /// the getMachineBasicBlockAddress callback. > + std::vector MBBLocations; > + > + /// LabelLocations - This vector is a mapping from Label ID's to their > + /// address. > + std::vector LabelLocations; > + > + /// CPLocations - This is a map of constant pool indices to offsets > from the > + /// start of the section for that constant pool index. > + std::vector CPLocations; > + > + /// CPSections - This is a map of constant pool indices to the Section > + /// containing the constant pool entry for that index. > + std::vector CPSections; > + > + /// JTLocations - This is a map of jump table indices to offsets from > the > + /// start of the section for that jump table index. > + std::vector JTLocations; > + > +public: > + ObjectCodeEmitter(); > + ObjectCodeEmitter(BinaryObject *bo); > + virtual ~ObjectCodeEmitter(); > + > + /// setBinaryObject - set the BinaryObject we are writting to > + void setBinaryObject(BinaryObject *bo); > + > + /// emitByte - This callback is invoked when a byte needs to be > + /// written to the data stream, without buffer overflow testing. > + void emitByte(uint8_t B); > + > + /// emitWordLE - This callback is invoked when a 32-bit word needs to > be > + /// written to the data stream in little-endian format. > + void emitWordLE(uint32_t W); > + > + /// emitWordBE - This callback is invoked when a 32-bit word needs to > be > + /// written to the data stream in big-endian format. > + void emitWordBE(uint32_t W); > + > + /// emitDWordLE - This callback is invoked when a 64-bit word needs to > be > + /// written to the data stream in little-endian format. > + void emitDWordLE(uint64_t W); > + > + /// emitDWordBE - This callback is invoked when a 64-bit word needs to > be > + /// written to the data stream in big-endian format. > + void emitDWordBE(uint64_t W); > + > + /// emitAlignment - Move the CurBufferPtr pointer up the the specified > + /// alignment (saturated to BufferEnd of course). > + void emitAlignment(unsigned Alignment = 0, uint8_t fill = 0); > + > + /// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to > be > + /// written to the data stream. > + void emitULEB128Bytes(uint64_t Value); > + > + /// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to > be > + /// written to the data stream. > + void emitSLEB128Bytes(uint64_t Value); > + > + /// emitString - This callback is invoked when a String needs to be > + /// written to the data stream. > + void emitString(const std::string &String); > + > + /// getCurrentPCValue - This returns the address that the next emitted > byte > + /// will be output to. > + uintptr_t getCurrentPCValue() const; > + > + /// getCurrentPCOffset - Return the offset from the start of the > emitted > + /// buffer that we are currently writing to. > + uintptr_t getCurrentPCOffset() const; > + > + /// addRelocation - Whenever a relocatable address is needed, it should > be > + /// noted with this interface. > + void addRelocation(const MachineRelocation& relocation); > + > + /// startFunction - This callback is invoked when the specified > function is > + /// about to be code generated. This initializes the > BufferBegin/End/Ptr > + /// fields. > + virtual void startFunction(MachineFunction &F) = 0; > + > + /// finishFunction - This callback is invoked when the specified > function has > + /// finished code generation. If a buffer overflow has occurred, this > method > + /// returns true (the callee is required to try again), otherwise it > returns > + /// false. > + virtual bool finishFunction(MachineFunction &F) = 0; > + > + /// StartMachineBasicBlock - This should be called by the target when a > new > + /// basic block is about to be emitted. This way the MCE knows where > the > + /// start of the block is, and can implement > getMachineBasicBlockAddress. > + virtual void StartMachineBasicBlock(MachineBasicBlock *MBB); > + > + /// getMachineBasicBlockAddress - Return the address of the specified > + /// MachineBasicBlock, only usable after the label for the MBB has been > + /// emitted. > + virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) > const; > + > + /// emitLabel - Emits a label > + virtual void emitLabel(uint64_t LabelID) = 0; > + > + /// getLabelAddress - Return the address of the specified LabelID, only > usable > + /// after the LabelID has been emitted. > + virtual uintptr_t getLabelAddress(uint64_t LabelID) const = 0; > + > + /// emitJumpTables - Emit all the jump tables for a given jump table > info > + /// record to the appropriate section. > + virtual void emitJumpTables(MachineJumpTableInfo *MJTI) = 0; > + > + /// getJumpTableEntryAddress - Return the address of the jump table > with index > + /// 'Index' in the function that last called initJumpTableInfo. > + virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const; > + > + /// emitConstantPool - For each constant pool entry, figure out which > section > + /// the constant should live in, allocate space for it, and emit it to > the > + /// Section data buffer. > + virtual void emitConstantPool(MachineConstantPool *MCP) = 0; > + > + /// getConstantPoolEntryAddress - Return the address of the 'Index' > entry in > + /// the constant pool that was last emitted with the emitConstantPool > method. > + virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const; > + > + /// getConstantPoolEntrySection - Return the section of the 'Index' > entry in > + /// the constant pool that was last emitted with the emitConstantPool > method. > + virtual uintptr_t getConstantPoolEntrySection(unsigned Index) const; > + > + /// Specifies the MachineModuleInfo object. This is used for exception > handling > + /// purposes. > + virtual void setModuleInfo(MachineModuleInfo* Info) = 0; > + // to be implemented or depreciated with MachineModuleInfo > + > +}; // end class ObjectCodeEmitter > + > +} // end namespace llvm > + > +#endif > + > > Added: llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp?rev=74814&view=auto > > ============================================================================== > --- llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp (added) > +++ llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp Mon Jul 6 00:16:40 2009 > @@ -0,0 +1,142 @@ > +//===-- llvm/CodeGen/ObjectCodeEmitter.cpp -------------------- -*- > C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > + > +#include "llvm/CodeGen/BinaryObject.h" > +#include "llvm/CodeGen/MachineBasicBlock.h" > +#include "llvm/CodeGen/MachineRelocation.h" > +#include "llvm/CodeGen/ObjectCodeEmitter.h" > + > +//===----------------------------------------------------------------------===// > +// ObjectCodeEmitter Implementation > +//===----------------------------------------------------------------------===// > + > +namespace llvm { > + > +ObjectCodeEmitter::ObjectCodeEmitter() : BO(0) {} > +ObjectCodeEmitter::ObjectCodeEmitter(BinaryObject *bo) : BO(bo) {} > +ObjectCodeEmitter::~ObjectCodeEmitter() {} > + > +/// setBinaryObject - set the BinaryObject we are writting to > +void ObjectCodeEmitter::setBinaryObject(BinaryObject *bo) { BO = bo; } > + > +/// emitByte - This callback is invoked when a byte needs to be > +/// written to the data stream, without buffer overflow testing. > +void ObjectCodeEmitter::emitByte(uint8_t B) { > + BO->emitByte(B); > +} > + > +/// emitWordLE - This callback is invoked when a 32-bit word needs to be > +/// written to the data stream in little-endian format. > +void ObjectCodeEmitter::emitWordLE(uint32_t W) { > + BO->emitWordLE(W); > +} > + > +/// emitWordBE - This callback is invoked when a 32-bit word needs to be > +/// written to the data stream in big-endian format. > +void ObjectCodeEmitter::emitWordBE(uint32_t W) { > + BO->emitWordBE(W); > +} > + > +/// emitDWordLE - This callback is invoked when a 64-bit word needs to be > +/// written to the data stream in little-endian format. > +void ObjectCodeEmitter::emitDWordLE(uint64_t W) { > + BO->emitDWordLE(W); > +} > + > +/// emitDWordBE - This callback is invoked when a 64-bit word needs to be > +/// written to the data stream in big-endian format. > +void ObjectCodeEmitter::emitDWordBE(uint64_t W) { > + BO->emitDWordBE(W); > +} > + > +/// emitAlignment - Move the CurBufferPtr pointer up the the specified > +/// alignment (saturated to BufferEnd of course). > +void ObjectCodeEmitter::emitAlignment(unsigned Alignment /* 0 */, > + uint8_t fill /* 0 */) { > + BO->emitAlignment(Alignment, fill); > +} > + > +/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to > be > +/// written to the data stream. > +void ObjectCodeEmitter::emitULEB128Bytes(uint64_t Value) { > + BO->emitULEB128Bytes(Value); > +} > + > +/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to > be > +/// written to the data stream. > +void ObjectCodeEmitter::emitSLEB128Bytes(uint64_t Value) { > + BO->emitSLEB128Bytes(Value); > +} > + > +/// emitString - This callback is invoked when a String needs to be > +/// written to the data stream. > +void ObjectCodeEmitter::emitString(const std::string &String) { > + BO->emitString(String); > +} > + > +/// getCurrentPCValue - This returns the address that the next emitted > byte > +/// will be output to. > +uintptr_t ObjectCodeEmitter::getCurrentPCValue() const { > + return BO->getCurrentPCOffset(); > +} > + > +/// getCurrentPCOffset - Return the offset from the start of the emitted > +/// buffer that we are currently writing to. > +uintptr_t ObjectCodeEmitter::getCurrentPCOffset() const { > + return BO->getCurrentPCOffset(); > +} > + > +/// addRelocation - Whenever a relocatable address is needed, it should > be > +/// noted with this interface. > +void ObjectCodeEmitter::addRelocation(const MachineRelocation& > relocation) { > + BO->addRelocation(relocation); > +} > + > +/// StartMachineBasicBlock - This should be called by the target when a > new > +/// basic block is about to be emitted. This way the MCE knows where the > +/// start of the block is, and can implement getMachineBasicBlockAddress. > +void ObjectCodeEmitter::StartMachineBasicBlock(MachineBasicBlock *MBB) { > + if (MBBLocations.size() <= (unsigned)MBB->getNumber()) > + MBBLocations.resize((MBB->getNumber()+1)*2); > + MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); > +} > + > +/// getMachineBasicBlockAddress - Return the address of the specified > +/// MachineBasicBlock, only usable after the label for the MBB has been > +/// emitted. > +uintptr_t > +ObjectCodeEmitter::getMachineBasicBlockAddress(MachineBasicBlock *MBB) > const { > + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && > + MBBLocations[MBB->getNumber()] && "MBB not emitted!"); > + return MBBLocations[MBB->getNumber()]; > +} > + > +/// getJumpTableEntryAddress - Return the address of the jump table with > index > +/// 'Index' in the function that last called initJumpTableInfo. > +uintptr_t ObjectCodeEmitter::getJumpTableEntryAddress(unsigned Index) > const { > + assert(JTLocations.size() > Index && "JT not emitted!"); > + return JTLocations[Index]; > +} > + > +/// getConstantPoolEntryAddress - Return the address of the 'Index' entry > in > +/// the constant pool that was last emitted with the emitConstantPool > method. > +uintptr_t ObjectCodeEmitter::getConstantPoolEntryAddress(unsigned Index) > const { > + assert(CPLocations.size() > Index && "CP not emitted!"); > + return CPLocations[Index]; > +} > + > +/// getConstantPoolEntrySection - Return the section of the 'Index' entry > in > +/// the constant pool that was last emitted with the emitConstantPool > method. > +uintptr_t ObjectCodeEmitter::getConstantPoolEntrySection(unsigned Index) > const { > + assert(CPSections.size() > Index && "CP not emitted!"); > + return CPSections[Index]; > +} > + > +} // end namespace llvm > + > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From baldrick at free.fr Mon Jul 6 09:28:39 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 06 Jul 2009 14:28:39 -0000 Subject: [llvm-commits] [llvm] r74825 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <200907061428.n66ESgmn023597@zion.cs.uiuc.edu> Author: baldrick Date: Mon Jul 6 09:28:32 2009 New Revision: 74825 URL: http://llvm.org/viewvc/llvm-project?rev=74825&view=rev Log: Fix the cmake build - patch by Xerxes R?nby. Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=74825&r1=74824&r2=74825&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Mon Jul 6 09:28:32 2009 @@ -31,6 +31,7 @@ MachineRegisterInfo.cpp MachineSink.cpp MachineVerifier.cpp + ObjectCodeEmitter.cpp OcamlGC.cpp PBQP.cpp PHIElimination.cpp From aaronngray.lists at googlemail.com Mon Jul 6 10:05:50 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 16:05:50 +0100 Subject: [llvm-commits] [patch] cmake add lib/CodeGen/ObjectCodeEmitter.cpp References: <4A51F39B.3080408@zafena.se> Message-ID: > fixes: > ../../lib/libLLVMAlphaCodeGen.a(AlphaCodeEmitter.cpp.o): In function > `(anonymous > namespace)::Emitter::emitBasicBlock(llvm::MachineBasicBlock&)': > AlphaCodeEmitter.cpp:(.text+0x132c): undefined reference to > `llvm::ObjectCodeEmitter::emitWordLE(unsigned int > and similar issues for cmake builds. Thanks, we had forgotten about CMake ! Aaron From stuart at apple.com Mon Jul 6 10:36:24 2009 From: stuart at apple.com (Stuart Hastings) Date: Mon, 06 Jul 2009 15:36:24 -0000 Subject: [llvm-commits] [llvm] r74829 - /llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp Message-ID: <200907061536.n66FaOBo026070@zion.cs.uiuc.edu> Author: stuart Date: Mon Jul 6 10:36:23 2009 New Revision: 74829 URL: http://llvm.org/viewvc/llvm-project?rev=74829&view=rev Log: Mark this test as Darwin only. Patch by Bill Wendling. Modified: llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp Modified: llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2009-06-30-ByrefBlock.cpp?rev=74829&r1=74828&r2=74829&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp (original) +++ llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp Mon Jul 6 10:36:23 2009 @@ -1,6 +1,9 @@ -// Insure __block_holder_tmp is allocated on the stack. +// Insure __block_holder_tmp is allocated on the stack. Darwin only. // RUN: %llvmgxx %s -S -O2 -o - | egrep {__block_holder_tmp.*alloca} +// XFAIL: * +// XTARGET: darwin // +// END. extern void fubar_dispatch_sync(void (^PP)(void)); void fubar() { __block void *voodoo; From jyasskin at google.com Mon Jul 6 11:50:30 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Mon, 06 Jul 2009 16:50:30 -0000 Subject: [llvm-commits] [llvm] r74834 - /llvm/trunk/lib/System/Errno.cpp Message-ID: <200907061650.n66GoV5i028434@zion.cs.uiuc.edu> Author: jyasskin Date: Mon Jul 6 11:50:27 2009 New Revision: 74834 URL: http://llvm.org/viewvc/llvm-project?rev=74834&view=rev Log: Oops, I #included errno.h from inside the llvm::sys namespace. Modified: llvm/trunk/lib/System/Errno.cpp Modified: llvm/trunk/lib/System/Errno.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Errno.cpp?rev=74834&r1=74833&r2=74834&view=diff ============================================================================== --- llvm/trunk/lib/System/Errno.cpp (original) +++ llvm/trunk/lib/System/Errno.cpp Mon Jul 6 11:50:27 2009 @@ -17,6 +17,10 @@ #if HAVE_STRING_H #include +#if HAVE_ERRNO_H +#include +#endif + //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system //=== independent code. @@ -26,7 +30,6 @@ namespace sys { #if HAVE_ERRNO_H -#include std::string StrError() { return StrError(errno); } From clattner at apple.com Mon Jul 6 12:10:55 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Jul 2009 10:10:55 -0700 Subject: [llvm-commits] PATCH: remove VICmp and VFCmp. In-Reply-To: <4A518899.80806@mxc.ca> References: <4A518899.80806@mxc.ca> Message-ID: <7ABB6DFD-7F2E-4F31-A7D9-FC86362095E6@apple.com> On Jul 5, 2009, at 10:16 PM, Nick Lewycky wrote: > This patch removes vicmp and vfcmp, which has the positive side that > it fixes existing type-safety bugs and simplifies some code, but a > downside in that it XFAILs 9 CodeGen tests. I haven't had a chance to look at the patch, but removing v[fi]cmp will almost certainly break clang (which generates them for vector comparisons in opencl/ext_vector mode). The right way to remove this is to make codegen pattern match [fi]cmp+sext to the same nodes it is using for v[fi]cmp, then change clang to generate [fi]cmp+sext instead of v[if]cmp, then nuke v[fi]cmp. This way we won't loose any codegen capability and clang will still build :). I'm happy to help with this, but I won't have time to for another couple days. -Chris From sabre at nondot.org Mon Jul 6 12:25:04 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Jul 2009 17:25:04 -0000 Subject: [llvm-commits] [llvm] r74835 - /llvm/trunk/lib/System/Threading.cpp Message-ID: <200907061725.n66HP8CM029643@zion.cs.uiuc.edu> Author: lattner Date: Mon Jul 6 12:24:48 2009 New Revision: 74835 URL: http://llvm.org/viewvc/llvm-project?rev=74835&view=rev Log: improve portability to windows, patch by Xerces Ranby! Modified: llvm/trunk/lib/System/Threading.cpp Modified: llvm/trunk/lib/System/Threading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Threading.cpp?rev=74835&r1=74834&r2=74835&view=diff ============================================================================== --- llvm/trunk/lib/System/Threading.cpp (original) +++ llvm/trunk/lib/System/Threading.cpp Mon Jul 6 12:24:48 2009 @@ -14,8 +14,8 @@ #include "llvm/System/Threading.h" #include "llvm/System/Atomic.h" #include "llvm/System/Mutex.h" +#include "llvm/Config/config.h" #include - using namespace llvm; static bool multithreaded_mode = false; From sabre at nondot.org Mon Jul 6 12:30:12 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Jul 2009 17:30:12 -0000 Subject: [llvm-commits] [llvm] r74836 - in /llvm/trunk: include/llvm-c/Core.h lib/VMCore/Core.cpp Message-ID: <200907061730.n66HUGRI029862@zion.cs.uiuc.edu> Author: lattner Date: Mon Jul 6 12:29:59 2009 New Revision: 74836 URL: http://llvm.org/viewvc/llvm-project?rev=74836&view=rev Log: Add two new accessors to the C bindings, patch by Wladimir van der Laan! Modified: llvm/trunk/include/llvm-c/Core.h llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=74836&r1=74835&r2=74836&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Mon Jul 6 12:29:59 2009 @@ -218,6 +218,7 @@ /** See Module::addTypeName. */ int LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty); void LLVMDeleteTypeName(LLVMModuleRef M, const char *Name); +LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name); /** See Module::dump. */ void LLVMDumpModule(LLVMModuleRef M); @@ -398,6 +399,7 @@ int LLVMIsConstant(LLVMValueRef Val); int LLVMIsNull(LLVMValueRef Val); int LLVMIsUndef(LLVMValueRef Val); +LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); /* Operations on scalar constants */ LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=74836&r1=74835&r2=74836&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Mon Jul 6 12:29:59 2009 @@ -101,6 +101,11 @@ TST.remove(I); } +LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name) { + std::string N(Name); + return wrap(unwrap(M)->getTypeByName(N)); +} + void LLVMDumpModule(LLVMModuleRef M) { unwrap(M)->dump(); } @@ -313,6 +318,10 @@ return isa(unwrap(Val)); } +LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty) { + return wrap(ConstantPointerNull::get(unwrap(Ty))); +} + /*--.. Operations on scalar constants ......................................--*/ LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, From clattner at apple.com Mon Jul 6 12:34:41 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Jul 2009 10:34:41 -0700 Subject: [llvm-commits] llvm-c patch to add LLVMGetTypeByName and LLVMConstPointerNull In-Reply-To: <3a7f9e660907021956he1ae821vc7fb3068e8475d9c@mail.gmail.com> References: <3a7f9e660907021956he1ae821vc7fb3068e8475d9c@mail.gmail.com> Message-ID: <1AFE566F-80A6-48A8-9FB0-791CC436B436@apple.com> On Jul 2, 2009, at 7:56 PM, Wladimir van der Laan wrote: > Dear LLVM developers, > > When working on a project using LLVM I ran into two important calls > that were missing from the llvm-c API (and thus from llvm-py, which > binds it): > > LLVMGetTypeByName - a way to get a typedef by name > LLVMConstPointerNull - get a null pointer of whatever type > > The attached patch fixes this problem by adding them in Core.h and > Core.cpp. I might run into more of these, but I thought it'd be better > to send this patch before I forget about it. Applied, thanks! http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090706/080163.html -Chris From aaronngray.lists at googlemail.com Mon Jul 6 12:57:31 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 18:57:31 +0100 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction Message-ID: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> This patch separates the template instatiations for the createX86*CodeEmitterPass of [X86]Emiiter into separate .cpp file and thus different object modules in the library. This will result in a slightly smaller footprint for programs just using one of the MachineCodeEmitter, ObjectCodeEmitter, or JITCodeEmitter classes. This should save 2 * 47K each for llc, lli, and LTOCodeGenerator. Although the MachineCodeEmitter version is not being use anymore at present I have left it in for now. It also opens the door for altername MachineCodeEmitters for experimental or other purposes such as unladen Swallow. I will be submitting simular patches for Alpha, ARM, and PowerPC if this one gets accepted. I have made CMake the necessary CMake changes too in the patch. This patch needs to be applied relatively quickly as it moves X86CodeEmitter.cpp code to X86CodeEmitter.h and any chages in SVN inbetween would be lost. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090706/d07eab74/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: x86-Memory-Opt.patch Type: application/octet-stream Size: 63830 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090706/d07eab74/attachment.obj From sanjiv.gupta at microchip.com Mon Jul 6 13:07:15 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Mon, 06 Jul 2009 18:07:15 -0000 Subject: [llvm-commits] [llvm] r74838 - /llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Message-ID: <200907061807.n66I7G1Q031039@zion.cs.uiuc.edu> Author: sgupta Date: Mon Jul 6 13:07:06 2009 New Revision: 74838 URL: http://llvm.org/viewvc/llvm-project?rev=74838&view=rev Log: pic16 isn't ready to handle llvm.metadata yet. Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp?rev=74838&r1=74837&r2=74838&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Mon Jul 6 13:07:06 2009 @@ -348,6 +348,8 @@ std::vector IDATASections = PTAI->IDATASections; for (unsigned i = 0; i < IDATASections.size(); i++) { O << "\n"; + if (IDATASections[i]->S_->getName().find("llvm.") != std::string::npos) + continue; SwitchToSection(IDATASections[i]->S_); std::vector Items = IDATASections[i]->Items; for (unsigned j = 0; j < Items.size(); j++) { From sanjiv.gupta at microchip.com Mon Jul 6 13:09:15 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Mon, 06 Jul 2009 18:09:15 -0000 Subject: [llvm-commits] [llvm] r74839 - /llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp Message-ID: <200907061809.n66I9G8G031101@zion.cs.uiuc.edu> Author: sgupta Date: Mon Jul 6 13:09:11 2009 New Revision: 74839 URL: http://llvm.org/viewvc/llvm-project?rev=74839&view=rev Log: pic16 doesn't have a Data64bitsDirective. Set it NULL explicitly to tell the generic code to not pick the default. Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp?rev=74839&r1=74838&r2=74839&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp Mon Jul 6 13:09:11 2009 @@ -30,6 +30,7 @@ Data8bitsDirective = " db "; Data16bitsDirective = " dw "; Data32bitsDirective = " dl "; + Data64bitsDirective = NULL; RomData8bitsDirective = " dw "; RomData16bitsDirective = " rom_di "; RomData32bitsDirective = " rom_dl "; From brukman+llvm at gmail.com Mon Jul 6 13:29:13 2009 From: brukman+llvm at gmail.com (Misha Brukman) Date: Mon, 06 Jul 2009 18:29:13 -0000 Subject: [llvm-commits] [llvm] r74840 - /llvm/trunk/utils/crosstool/ARM/build-install-linux.sh Message-ID: <200907061829.n66ITIV6031680@zion.cs.uiuc.edu> Author: brukman Date: Mon Jul 6 13:29:03 2009 New Revision: 74840 URL: http://llvm.org/viewvc/llvm-project?rev=74840&view=rev Log: * Allow skipping parts of the installation to be able to do it in parts if one phase fails and the user wants to reinstall one of the components. * Fixed LLVM-GCC configuration flags: s/--with-gnu-{as,ld}/--with-{as,ld}/ The former is a boolean flag, the latter is a flag that takes a path. * Added a new flag CROSS_MARCH, defaults to armv6. Modified: llvm/trunk/utils/crosstool/ARM/build-install-linux.sh Modified: llvm/trunk/utils/crosstool/ARM/build-install-linux.sh URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/crosstool/ARM/build-install-linux.sh?rev=74840&r1=74839&r2=74840&view=diff ============================================================================== --- llvm/trunk/utils/crosstool/ARM/build-install-linux.sh (original) +++ llvm/trunk/utils/crosstool/ARM/build-install-linux.sh Mon Jul 6 13:29:03 2009 @@ -17,6 +17,7 @@ readonly CROSS_HOST="x86_64-unknown-linux-gnu" readonly CROSS_TARGET="arm-none-linux-gnueabi" +readonly CROSS_MARCH="${CROSS_MARCH:-armv6}" readonly CODE_SOURCERY="${INSTALL_ROOT}/codesourcery" readonly CODE_SOURCERY_PKG_PATH="${CODE_SOURCERY_PKG_PATH:-${HOME}/codesourcery}" @@ -104,12 +105,9 @@ } installCodeSourcery() { - # Create CodeSourcery dir, if necessary. - verifyNotDir ${CODE_SOURCERY} - sudoCreateDir ${CODE_SOURCERY} - - # Unpack the tarball. + # Unpack the tarball, creating the CodeSourcery dir, if necessary. if [[ ! -d ${CODE_SOURCERY_ROOT} ]]; then + sudoCreateDir ${CODE_SOURCERY} cd ${CODE_SOURCERY} if [[ -e ${CODE_SOURCERY_PKG_PATH}/${CODE_SOURCERY_PKG} ]]; then runCommand "Unpacking CodeSourcery in ${CODE_SOURCERY}" \ @@ -122,7 +120,7 @@ exit fi else - echo "CodeSourcery install dir already exists." + echo "CodeSourcery install dir already exists; skipping." fi # Verify our CodeSourcery toolchain installation. @@ -141,7 +139,11 @@ } installLLVM() { - verifyNotDir ${LLVM_INSTALL_DIR} + if [[ -d ${LLVM_INSTALL_DIR} ]]; then + echo "LLVM install dir ${LLVM_INSTALL_DIR} exists; skipping." + return + fi + sudoCreateDir ${LLVM_INSTALL_DIR} # Unpack LLVM tarball; should create the directory "llvm". @@ -165,7 +167,11 @@ } installLLVMGCC() { - verifyNotDir ${LLVMGCC_INSTALL_DIR} + if [[ -d ${LLVMGCC_INSTALL_DIR} ]]; then + echo "LLVM-GCC install dir ${LLVMGCC_INSTALL_DIR} exists; skipping." + return + fi + sudoCreateDir ${LLVMGCC_INSTALL_DIR} # Unpack LLVM-GCC tarball; should create the directory "llvm-gcc-4.2". @@ -182,8 +188,9 @@ --prefix=${LLVMGCC_INSTALL_DIR} \ --program-prefix=llvm- \ --target=${CROSS_TARGET} \ - --with-gnu-as=${CROSS_TARGET_AS} \ - --with-gnu-ld=${CROSS_TARGET_LD} \ + --with-arch=${CROSS_MARCH} \ + --with-as=${CROSS_TARGET_AS} \ + --with-ld=${CROSS_TARGET_LD} \ --with-sysroot=${SYSROOT} runAndLog "Building LLVM-GCC" ${LLVMGCC_OBJ_DIR}/llvmgcc-build.log \ make From kremenek at apple.com Mon Jul 6 13:31:19 2009 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 06 Jul 2009 18:31:19 -0000 Subject: [llvm-commits] [llvm] r74842 - /llvm/tags/checker/checker-0.213/ Message-ID: <200907061831.n66IVK9V031819@zion.cs.uiuc.edu> Author: kremenek Date: Mon Jul 6 13:31:18 2009 New Revision: 74842 URL: http://llvm.org/viewvc/llvm-project?rev=74842&view=rev Log: Tagging checker-0.213. Added: llvm/tags/checker/checker-0.213/ - copied from r74841, llvm/trunk/ From resistor at mac.com Mon Jul 6 13:42:47 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 06 Jul 2009 18:42:47 -0000 Subject: [llvm-commits] [llvm] r74844 - in /llvm/trunk: include/llvm/Analysis/ include/llvm/Support/ lib/Analysis/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ Message-ID: <200907061842.n66Igvqn032166@zion.cs.uiuc.edu> Author: resistor Date: Mon Jul 6 13:42:36 2009 New Revision: 74844 URL: http://llvm.org/viewvc/llvm-project?rev=74844&view=rev Log: Thread LLVMContext through the constant folding APIs, which touches a lot of files. Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h llvm/trunk/include/llvm/Support/TargetFolder.h llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp llvm/trunk/lib/Transforms/Utils/UnrollLoop.cpp Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ConstantFolding.h?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ConstantFolding.h (original) +++ llvm/trunk/include/llvm/Analysis/ConstantFolding.h Mon Jul 6 13:42:36 2009 @@ -22,18 +22,20 @@ class TargetData; class Function; class Type; + class LLVMContext; /// ConstantFoldInstruction - Attempt to constant fold the specified /// instruction. If successful, the constant result is returned, if not, null /// is returned. Note that this function can only fail when attempting to fold /// instructions like loads and stores, which have no constant expression form. /// -Constant *ConstantFoldInstruction(Instruction *I, const TargetData *TD = 0); +Constant *ConstantFoldInstruction(Instruction *I, LLVMContext* Context, + const TargetData *TD = 0); /// ConstantFoldConstantExpression - Attempt to fold the constant expression /// using the specified TargetData. If successful, the constant result is /// result is returned, if not, null is returned. -Constant *ConstantFoldConstantExpression(ConstantExpr *CE, +Constant *ConstantFoldConstantExpression(ConstantExpr *CE, LLVMContext* Context, const TargetData *TD = 0); /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the @@ -44,6 +46,7 @@ /// Constant *ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, Constant*const * Ops, unsigned NumOps, + LLVMContext* Context, const TargetData *TD = 0); /// ConstantFoldCompareInstOperands - Attempt to constant fold a compare @@ -52,13 +55,15 @@ /// Constant *ConstantFoldCompareInstOperands(unsigned Predicate, Constant*const * Ops, unsigned NumOps, + LLVMContext* Context, const TargetData *TD = 0); /// ConstantFoldLoadThroughGEPConstantExpr - Given a constant and a /// getelementptr constantexpr, return the constant value being addressed by the /// constant expression, or null if something is funny and we can't decide. -Constant *ConstantFoldLoadThroughGEPConstantExpr(Constant *C, ConstantExpr *CE); +Constant *ConstantFoldLoadThroughGEPConstantExpr(Constant *C, ConstantExpr *CE, + LLVMContext* Context); /// canConstantFoldCallTo - Return true if its even possible to fold a call to /// the specified function. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon Jul 6 13:42:36 2009 @@ -36,6 +36,7 @@ class Type; class ScalarEvolution; class TargetData; + class LLVMContext; /// SCEV - This class represents an analyzed expression in the program. These /// are opaque objects that the client is not allowed to do much with @@ -354,6 +355,8 @@ static char ID; // Pass identification, replacement for typeid ScalarEvolution(); + LLVMContext* getContext() const { return Context; } + /// isSCEVable - Test if values of the given type are analyzable within /// the SCEV framework. This primarily includes integer types, and it /// can optionally include pointer types if the ScalarEvolution class Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Mon Jul 6 13:42:36 2009 @@ -37,7 +37,7 @@ friend struct SCEVVisitor; public: explicit SCEVExpander(ScalarEvolution &se) - : SE(se), Builder(TargetFolder(se.TD)) {} + : SE(se), Builder(TargetFolder(se.TD, se.getContext())) {} /// clear - Erase the contents of the InsertedExpressions map so that users /// trying to expand the same expression into multiple BasicBlocks or Modified: llvm/trunk/include/llvm/Support/TargetFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetFolder.h (original) +++ llvm/trunk/include/llvm/Support/TargetFolder.h Mon Jul 6 13:42:36 2009 @@ -25,21 +25,24 @@ namespace llvm { class TargetData; +class LLVMContext; /// TargetFolder - Create constants with target dependent folding. class TargetFolder { const TargetData *TD; + LLVMContext* Context; /// Fold - Fold the constant using target specific information. Constant *Fold(Constant *C) const { if (ConstantExpr *CE = dyn_cast(C)) - if (Constant *CF = ConstantFoldConstantExpression(CE, TD)) + if (Constant *CF = ConstantFoldConstantExpression(CE, Context, TD)) return CF; return C; } public: - explicit TargetFolder(const TargetData *TheTD) : TD(TheTD) {} + explicit TargetFolder(const TargetData *TheTD, LLVMContext* C) : + TD(TheTD), Context(C) {} //===--------------------------------------------------------------------===// // Binary Operators Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Mon Jul 6 13:42:36 2009 @@ -22,6 +22,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" +#include "llvm/LLVMContext.h" #include "llvm/Pass.h" #include "llvm/Target/TargetData.h" #include "llvm/ADT/SmallVector.h" @@ -394,13 +395,13 @@ // the base pointers. while (isGEP(GEP1->getOperand(0)) && GEP1->getOperand(1) == - Constant::getNullValue(GEP1->getOperand(1)->getType())) + Context->getNullValue(GEP1->getOperand(1)->getType())) GEP1 = cast(GEP1->getOperand(0)); const Value *BasePtr1 = GEP1->getOperand(0); while (isGEP(GEP2->getOperand(0)) && GEP2->getOperand(1) == - Constant::getNullValue(GEP2->getOperand(1)->getType())) + Context->getNullValue(GEP2->getOperand(1)->getType())) GEP2 = cast(GEP2->getOperand(0)); const Value *BasePtr2 = GEP2->getOperand(0); @@ -480,7 +481,7 @@ for (unsigned i = 0; i != GEPOperands.size(); ++i) if (!isa(GEPOperands[i])) GEPOperands[i] = - Constant::getNullValue(GEPOperands[i]->getType()); + Context->getNullValue(GEPOperands[i]->getType()); int64_t Offset = getTargetData().getIndexedOffset(BasePtr->getType(), &GEPOperands[0], @@ -498,16 +499,16 @@ // This function is used to determine if the indices of two GEP instructions are // equal. V1 and V2 are the indices. -static bool IndexOperandsEqual(Value *V1, Value *V2) { +static bool IndexOperandsEqual(Value *V1, Value *V2, LLVMContext* Context) { if (V1->getType() == V2->getType()) return V1 == V2; if (Constant *C1 = dyn_cast(V1)) if (Constant *C2 = dyn_cast(V2)) { // Sign extend the constants to long types, if necessary if (C1->getType() != Type::Int64Ty) - C1 = ConstantExpr::getSExt(C1, Type::Int64Ty); + C1 = Context->getConstantExprSExt(C1, Type::Int64Ty); if (C2->getType() != Type::Int64Ty) - C2 = ConstantExpr::getSExt(C2, Type::Int64Ty); + C2 = Context->getConstantExprSExt(C2, Type::Int64Ty); return C1 == C2; } return false; @@ -535,7 +536,8 @@ unsigned MaxOperands = std::max(NumGEP1Operands, NumGEP2Operands); unsigned UnequalOper = 0; while (UnequalOper != MinOperands && - IndexOperandsEqual(GEP1Ops[UnequalOper], GEP2Ops[UnequalOper])) { + IndexOperandsEqual(GEP1Ops[UnequalOper], GEP2Ops[UnequalOper], + Context)) { // Advance through the type as we go... ++UnequalOper; if (const CompositeType *CT = dyn_cast(BasePtr1Ty)) @@ -600,9 +602,9 @@ if (G1OC->getType() != G2OC->getType()) { // Sign extend both operands to long. if (G1OC->getType() != Type::Int64Ty) - G1OC = ConstantExpr::getSExt(G1OC, Type::Int64Ty); + G1OC = Context->getConstantExprSExt(G1OC, Type::Int64Ty); if (G2OC->getType() != Type::Int64Ty) - G2OC = ConstantExpr::getSExt(G2OC, Type::Int64Ty); + G2OC = Context->getConstantExprSExt(G2OC, Type::Int64Ty); GEP1Ops[FirstConstantOper] = G1OC; GEP2Ops[FirstConstantOper] = G2OC; } @@ -689,7 +691,7 @@ // TargetData::getIndexedOffset. for (i = 0; i != MaxOperands; ++i) if (!isa(GEP1Ops[i])) - GEP1Ops[i] = Constant::getNullValue(GEP1Ops[i]->getType()); + GEP1Ops[i] = Context->getNullValue(GEP1Ops[i]->getType()); // Okay, now get the offset. This is the relative offset for the full // instruction. const TargetData &TD = getTargetData(); @@ -734,7 +736,7 @@ const Type *ZeroIdxTy = GEPPointerTy; for (unsigned i = 0; i != FirstConstantOper; ++i) { if (!isa(ZeroIdxTy)) - GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Type::Int32Ty); + GEP1Ops[i] = GEP2Ops[i] = Context->getNullValue(Type::Int32Ty); if (const CompositeType *CT = dyn_cast(ZeroIdxTy)) ZeroIdxTy = CT->getTypeAtIndex(GEP1Ops[i]); @@ -749,7 +751,7 @@ // If they are equal, use a zero index... if (Op1 == Op2 && BasePtr1Ty == BasePtr2Ty) { if (!isa(Op1)) - GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Op1->getType()); + GEP1Ops[i] = GEP2Ops[i] = Context->getNullValue(Op1->getType()); // Otherwise, just keep the constants we have. } else { if (Op1) { @@ -775,9 +777,11 @@ // value possible. // if (const ArrayType *AT = dyn_cast(BasePtr1Ty)) - GEP1Ops[i] = ConstantInt::get(Type::Int64Ty,AT->getNumElements()-1); + GEP1Ops[i] = + Context->getConstantInt(Type::Int64Ty,AT->getNumElements()-1); else if (const VectorType *VT = dyn_cast(BasePtr1Ty)) - GEP1Ops[i] = ConstantInt::get(Type::Int64Ty,VT->getNumElements()-1); + GEP1Ops[i] = + Context->getConstantInt(Type::Int64Ty,VT->getNumElements()-1); } } @@ -792,7 +796,7 @@ return MayAlias; // Be conservative with out-of-range accesses } } else { // Conservatively assume the minimum value for this index - GEP2Ops[i] = Constant::getNullValue(Op2->getType()); + GEP2Ops[i] = Context->getNullValue(Op2->getType()); } } } Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Mon Jul 6 13:42:36 2009 @@ -19,6 +19,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" +#include "llvm/LLVMContext.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/Target/TargetData.h" @@ -92,7 +93,8 @@ /// these together. If target data info is available, it is provided as TD, /// otherwise TD is null. static Constant *SymbolicallyEvaluateBinop(unsigned Opc, Constant *Op0, - Constant *Op1, const TargetData *TD){ + Constant *Op1, const TargetData *TD, + LLVMContext* Context){ // SROA // Fold (and 0xffffffff00000000, (shl x, 32)) -> shl. @@ -110,7 +112,7 @@ if (IsConstantOffsetFromGlobal(Op1, GV2, Offs2, *TD) && GV1 == GV2) { // (&GV+C1) - (&GV+C2) -> C1-C2, pointer arithmetic cannot overflow. - return ConstantInt::get(Op0->getType(), Offs1-Offs2); + return Context->getConstantInt(Op0->getType(), Offs1-Offs2); } } @@ -121,6 +123,7 @@ /// constant expression, do so. static Constant *SymbolicallyEvaluateGEP(Constant* const* Ops, unsigned NumOps, const Type *ResultTy, + LLVMContext* Context, const TargetData *TD) { Constant *Ptr = Ops[0]; if (!TD || !cast(Ptr->getType())->getElementType()->isSized()) @@ -147,14 +150,14 @@ uint64_t Offset = TD->getIndexedOffset(Ptr->getType(), (Value**)Ops+1, NumOps-1); - Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset+BasePtr); - return ConstantExpr::getIntToPtr(C, ResultTy); + Constant *C = Context->getConstantInt(TD->getIntPtrType(), Offset+BasePtr); + return Context->getConstantExprIntToPtr(C, ResultTy); } /// FoldBitCast - Constant fold bitcast, symbolically evaluating it with /// targetdata. Return 0 if unfoldable. static Constant *FoldBitCast(Constant *C, const Type *DestTy, - const TargetData &TD) { + const TargetData &TD, LLVMContext* Context) { // If this is a bitcast from constant vector -> vector, fold it. if (ConstantVector *CV = dyn_cast(C)) { if (const VectorType *DestVTy = dyn_cast(DestTy)) { @@ -180,24 +183,24 @@ if (DstEltTy->isFloatingPoint()) { // Fold to an vector of integers with same size as our FP type. unsigned FPWidth = DstEltTy->getPrimitiveSizeInBits(); - const Type *DestIVTy = VectorType::get(IntegerType::get(FPWidth), - NumDstElt); + const Type *DestIVTy = Context->getVectorType( + Context->getIntegerType(FPWidth), NumDstElt); // Recursively handle this integer conversion, if possible. - C = FoldBitCast(C, DestIVTy, TD); + C = FoldBitCast(C, DestIVTy, TD, Context); if (!C) return 0; // Finally, VMCore can handle this now that #elts line up. - return ConstantExpr::getBitCast(C, DestTy); + return Context->getConstantExprBitCast(C, DestTy); } // Okay, we know the destination is integer, if the input is FP, convert // it to integer first. if (SrcEltTy->isFloatingPoint()) { unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits(); - const Type *SrcIVTy = VectorType::get(IntegerType::get(FPWidth), - NumSrcElt); + const Type *SrcIVTy = Context->getVectorType( + Context->getIntegerType(FPWidth), NumSrcElt); // Ask VMCore to do the conversion now that #elts line up. - C = ConstantExpr::getBitCast(C, SrcIVTy); + C = Context->getConstantExprBitCast(C, SrcIVTy); CV = dyn_cast(C); if (!CV) return 0; // If VMCore wasn't able to fold it, bail out. } @@ -211,7 +214,7 @@ SmallVector Result; if (NumDstElt < NumSrcElt) { // Handle: bitcast (<4 x i32> to <2 x i64>) - Constant *Zero = Constant::getNullValue(DstEltTy); + Constant *Zero = Context->getNullValue(DstEltTy); unsigned Ratio = NumSrcElt/NumDstElt; unsigned SrcBitSize = SrcEltTy->getPrimitiveSizeInBits(); unsigned SrcElt = 0; @@ -224,15 +227,15 @@ if (!Src) return 0; // Reject constantexpr elements. // Zero extend the element to the right size. - Src = ConstantExpr::getZExt(Src, Elt->getType()); + Src = Context->getConstantExprZExt(Src, Elt->getType()); // Shift it to the right place, depending on endianness. - Src = ConstantExpr::getShl(Src, - ConstantInt::get(Src->getType(), ShiftAmt)); + Src = Context->getConstantExprShl(Src, + Context->getConstantInt(Src->getType(), ShiftAmt)); ShiftAmt += isLittleEndian ? SrcBitSize : -SrcBitSize; // Mix it in. - Elt = ConstantExpr::getOr(Elt, Src); + Elt = Context->getConstantExprOr(Elt, Src); } Result.push_back(Elt); } @@ -250,17 +253,17 @@ for (unsigned j = 0; j != Ratio; ++j) { // Shift the piece of the value into the right place, depending on // endianness. - Constant *Elt = ConstantExpr::getLShr(Src, - ConstantInt::get(Src->getType(), ShiftAmt)); + Constant *Elt = Context->getConstantExprLShr(Src, + Context->getConstantInt(Src->getType(), ShiftAmt)); ShiftAmt += isLittleEndian ? DstBitSize : -DstBitSize; // Truncate and remember this piece. - Result.push_back(ConstantExpr::getTrunc(Elt, DstEltTy)); + Result.push_back(Context->getConstantExprTrunc(Elt, DstEltTy)); } } } - return ConstantVector::get(Result.data(), Result.size()); + return Context->getConstantVector(Result.data(), Result.size()); } } @@ -278,10 +281,11 @@ /// is returned. Note that this function can only fail when attempting to fold /// instructions like loads and stores, which have no constant expression form. /// -Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) { +Constant *llvm::ConstantFoldInstruction(Instruction *I, LLVMContext* Context, + const TargetData *TD) { if (PHINode *PN = dyn_cast(I)) { if (PN->getNumIncomingValues() == 0) - return UndefValue::get(PN->getType()); + return Context->getUndef(PN->getType()); Constant *Result = dyn_cast(PN->getIncomingValue(0)); if (Result == 0) return 0; @@ -306,16 +310,18 @@ if (const CmpInst *CI = dyn_cast(I)) return ConstantFoldCompareInstOperands(CI->getPredicate(), - Ops.data(), Ops.size(), TD); + Ops.data(), Ops.size(), + Context, TD); else return ConstantFoldInstOperands(I->getOpcode(), I->getType(), - Ops.data(), Ops.size(), TD); + Ops.data(), Ops.size(), Context, TD); } /// ConstantFoldConstantExpression - Attempt to fold the constant expression /// using the specified TargetData. If successful, the constant result is /// result is returned, if not, null is returned. Constant *llvm::ConstantFoldConstantExpression(ConstantExpr *CE, + LLVMContext* Context, const TargetData *TD) { SmallVector Ops; for (User::op_iterator i = CE->op_begin(), e = CE->op_end(); i != e; ++i) @@ -323,10 +329,11 @@ if (CE->isCompare()) return ConstantFoldCompareInstOperands(CE->getPredicate(), - Ops.data(), Ops.size(), TD); + Ops.data(), Ops.size(), + Context, TD); else return ConstantFoldInstOperands(CE->getOpcode(), CE->getType(), - Ops.data(), Ops.size(), TD); + Ops.data(), Ops.size(), Context, TD); } /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the @@ -337,14 +344,16 @@ /// Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, Constant* const* Ops, unsigned NumOps, + LLVMContext* Context, const TargetData *TD) { // Handle easy binops first. if (Instruction::isBinaryOp(Opcode)) { if (isa(Ops[0]) || isa(Ops[1])) - if (Constant *C = SymbolicallyEvaluateBinop(Opcode, Ops[0], Ops[1], TD)) + if (Constant *C = SymbolicallyEvaluateBinop(Opcode, Ops[0], Ops[1], TD, + Context)) return C; - return ConstantExpr::get(Opcode, Ops[0], Ops[1]); + return Context->getConstantExpr(Opcode, Ops[0], Ops[1]); } switch (Opcode) { @@ -368,15 +377,15 @@ unsigned InWidth = Input->getType()->getScalarSizeInBits(); if (TD->getPointerSizeInBits() < InWidth) { Constant *Mask = - ConstantInt::get(APInt::getLowBitsSet(InWidth, + Context->getConstantInt(APInt::getLowBitsSet(InWidth, TD->getPointerSizeInBits())); - Input = ConstantExpr::getAnd(Input, Mask); + Input = Context->getConstantExprAnd(Input, Mask); } // Do a zext or trunc to get to the dest size. - return ConstantExpr::getIntegerCast(Input, DestTy, false); + return Context->getConstantExprIntegerCast(Input, DestTy, false); } } - return ConstantExpr::getCast(Opcode, Ops[0], DestTy); + return Context->getConstantExprCast(Opcode, Ops[0], DestTy); case Instruction::IntToPtr: // If the input is a ptrtoint, turn the pair into a ptr to ptr bitcast if // the int size is >= the ptr size. This requires knowing the width of a @@ -387,8 +396,8 @@ CE->getType()->getScalarSizeInBits()) { if (CE->getOpcode() == Instruction::PtrToInt) { Constant *Input = CE->getOperand(0); - Constant *C = FoldBitCast(Input, DestTy, *TD); - return C ? C : ConstantExpr::getBitCast(Input, DestTy); + Constant *C = FoldBitCast(Input, DestTy, *TD, Context); + return C ? C : Context->getConstantExprBitCast(Input, DestTy); } // If there's a constant offset added to the integer value before // it is casted back to a pointer, see if the expression can be @@ -411,17 +420,18 @@ if (ElemIdx.ult(APInt(ElemIdx.getBitWidth(), AT->getNumElements()))) { Constant *Index[] = { - Constant::getNullValue(CE->getType()), - ConstantInt::get(ElemIdx) + Context->getNullValue(CE->getType()), + Context->getConstantInt(ElemIdx) }; - return ConstantExpr::getGetElementPtr(GV, &Index[0], 2); + return + Context->getConstantExprGetElementPtr(GV, &Index[0], 2); } } } } } } - return ConstantExpr::getCast(Opcode, Ops[0], DestTy); + return Context->getConstantExprCast(Opcode, Ops[0], DestTy); case Instruction::Trunc: case Instruction::ZExt: case Instruction::SExt: @@ -431,25 +441,25 @@ case Instruction::SIToFP: case Instruction::FPToUI: case Instruction::FPToSI: - return ConstantExpr::getCast(Opcode, Ops[0], DestTy); + return Context->getConstantExprCast(Opcode, Ops[0], DestTy); case Instruction::BitCast: if (TD) - if (Constant *C = FoldBitCast(Ops[0], DestTy, *TD)) + if (Constant *C = FoldBitCast(Ops[0], DestTy, *TD, Context)) return C; - return ConstantExpr::getBitCast(Ops[0], DestTy); + return Context->getConstantExprBitCast(Ops[0], DestTy); case Instruction::Select: - return ConstantExpr::getSelect(Ops[0], Ops[1], Ops[2]); + return Context->getConstantExprSelect(Ops[0], Ops[1], Ops[2]); case Instruction::ExtractElement: - return ConstantExpr::getExtractElement(Ops[0], Ops[1]); + return Context->getConstantExprExtractElement(Ops[0], Ops[1]); case Instruction::InsertElement: - return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]); + return Context->getConstantExprInsertElement(Ops[0], Ops[1], Ops[2]); case Instruction::ShuffleVector: - return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]); + return Context->getConstantExprShuffleVector(Ops[0], Ops[1], Ops[2]); case Instruction::GetElementPtr: - if (Constant *C = SymbolicallyEvaluateGEP(Ops, NumOps, DestTy, TD)) + if (Constant *C = SymbolicallyEvaluateGEP(Ops, NumOps, DestTy, Context, TD)) return C; - return ConstantExpr::getGetElementPtr(Ops[0], Ops+1, NumOps-1); + return Context->getConstantExprGetElementPtr(Ops[0], Ops+1, NumOps-1); } } @@ -460,6 +470,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate, Constant*const * Ops, unsigned NumOps, + LLVMContext* Context, const TargetData *TD) { // fold: icmp (inttoptr x), null -> icmp x, 0 // fold: icmp (ptrtoint x), 0 -> icmp x, null @@ -474,10 +485,11 @@ if (CE0->getOpcode() == Instruction::IntToPtr) { // Convert the integer value to the right size to ensure we get the // proper extension or truncation. - Constant *C = ConstantExpr::getIntegerCast(CE0->getOperand(0), + Constant *C = Context->getConstantExprIntegerCast(CE0->getOperand(0), IntPtrTy, false); - Constant *NewOps[] = { C, Constant::getNullValue(C->getType()) }; - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); + Constant *NewOps[] = { C, Context->getNullValue(C->getType()) }; + return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, + Context, TD); } // Only do this transformation if the int is intptrty in size, otherwise @@ -485,9 +497,10 @@ if (CE0->getOpcode() == Instruction::PtrToInt && CE0->getType() == IntPtrTy) { Constant *C = CE0->getOperand(0); - Constant *NewOps[] = { C, Constant::getNullValue(C->getType()) }; + Constant *NewOps[] = { C, Context->getNullValue(C->getType()) }; // FIXME! - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); + return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, + Context, TD); } } @@ -498,12 +511,13 @@ if (CE0->getOpcode() == Instruction::IntToPtr) { // Convert the integer value to the right size to ensure we get the // proper extension or truncation. - Constant *C0 = ConstantExpr::getIntegerCast(CE0->getOperand(0), + Constant *C0 = Context->getConstantExprIntegerCast(CE0->getOperand(0), IntPtrTy, false); - Constant *C1 = ConstantExpr::getIntegerCast(CE1->getOperand(0), + Constant *C1 = Context->getConstantExprIntegerCast(CE1->getOperand(0), IntPtrTy, false); Constant *NewOps[] = { C0, C1 }; - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); + return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, + Context, TD); } // Only do this transformation if the int is intptrty in size, otherwise @@ -514,12 +528,13 @@ Constant *NewOps[] = { CE0->getOperand(0), CE1->getOperand(0) }; - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); + return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, + Context, TD); } } } } - return ConstantExpr::getCompare(Predicate, Ops[0], Ops[1]); + return Context->getConstantExprCompare(Predicate, Ops[0], Ops[1]); } @@ -527,8 +542,9 @@ /// getelementptr constantexpr, return the constant value being addressed by the /// constant expression, or null if something is funny and we can't decide. Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, - ConstantExpr *CE) { - if (CE->getOperand(1) != Constant::getNullValue(CE->getOperand(1)->getType())) + ConstantExpr *CE, + LLVMContext* Context) { + if (CE->getOperand(1) != Context->getNullValue(CE->getOperand(1)->getType())) return 0; // Do not allow stepping over the value! // Loop over all of the operands, tracking down which value we are @@ -543,9 +559,9 @@ if (ConstantStruct *CS = dyn_cast(C)) { C = CS->getOperand(El); } else if (isa(C)) { - C = Constant::getNullValue(STy->getElementType(El)); + C = Context->getNullValue(STy->getElementType(El)); } else if (isa(C)) { - C = UndefValue::get(STy->getElementType(El)); + C = Context->getUndef(STy->getElementType(El)); } else { return 0; } @@ -556,9 +572,9 @@ if (ConstantArray *CA = dyn_cast(C)) C = CA->getOperand(CI->getZExtValue()); else if (isa(C)) - C = Constant::getNullValue(ATy->getElementType()); + C = Context->getNullValue(ATy->getElementType()); else if (isa(C)) - C = UndefValue::get(ATy->getElementType()); + C = Context->getUndef(ATy->getElementType()); else return 0; } else if (const VectorType *PTy = dyn_cast(*I)) { @@ -567,9 +583,9 @@ if (ConstantVector *CP = dyn_cast(C)) C = CP->getOperand(CI->getZExtValue()); else if (isa(C)) - C = Constant::getNullValue(PTy->getElementType()); + C = Context->getNullValue(PTy->getElementType()); else if (isa(C)) - C = UndefValue::get(PTy->getElementType()); + C = Context->getUndef(PTy->getElementType()); else return 0; } else { @@ -664,7 +680,7 @@ } static Constant *ConstantFoldFP(double (*NativeFP)(double), double V, - const Type *Ty) { + const Type *Ty, LLVMContext* Context) { errno = 0; V = NativeFP(V); if (errno != 0) { @@ -673,16 +689,17 @@ } if (Ty == Type::FloatTy) - return ConstantFP::get(APFloat((float)V)); + return Context->getConstantFP(APFloat((float)V)); if (Ty == Type::DoubleTy) - return ConstantFP::get(APFloat(V)); + return Context->getConstantFP(APFloat(V)); assert(0 && "Can only constant fold float/double"); return 0; // dummy return to suppress warning } static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double), double V, double W, - const Type *Ty) { + const Type *Ty, + LLVMContext* Context) { errno = 0; V = NativeFP(V, W); if (errno != 0) { @@ -691,9 +708,9 @@ } if (Ty == Type::FloatTy) - return ConstantFP::get(APFloat((float)V)); + return Context->getConstantFP(APFloat((float)V)); if (Ty == Type::DoubleTy) - return ConstantFP::get(APFloat(V)); + return Context->getConstantFP(APFloat(V)); assert(0 && "Can only constant fold float/double"); return 0; // dummy return to suppress warning } @@ -705,6 +722,7 @@ llvm::ConstantFoldCall(Function *F, Constant* const* Operands, unsigned NumOperands) { if (!F->hasName()) return 0; + LLVMContext* Context = F->getContext(); const char *Str = F->getNameStart(); unsigned Len = F->getNameLen(); @@ -722,75 +740,75 @@ switch (Str[0]) { case 'a': if (Len == 4 && !strcmp(Str, "acos")) - return ConstantFoldFP(acos, V, Ty); + return ConstantFoldFP(acos, V, Ty, Context); else if (Len == 4 && !strcmp(Str, "asin")) - return ConstantFoldFP(asin, V, Ty); + return ConstantFoldFP(asin, V, Ty, Context); else if (Len == 4 && !strcmp(Str, "atan")) - return ConstantFoldFP(atan, V, Ty); + return ConstantFoldFP(atan, V, Ty, Context); break; case 'c': if (Len == 4 && !strcmp(Str, "ceil")) - return ConstantFoldFP(ceil, V, Ty); + return ConstantFoldFP(ceil, V, Ty, Context); else if (Len == 3 && !strcmp(Str, "cos")) - return ConstantFoldFP(cos, V, Ty); + return ConstantFoldFP(cos, V, Ty, Context); else if (Len == 4 && !strcmp(Str, "cosh")) - return ConstantFoldFP(cosh, V, Ty); + return ConstantFoldFP(cosh, V, Ty, Context); else if (Len == 4 && !strcmp(Str, "cosf")) - return ConstantFoldFP(cos, V, Ty); + return ConstantFoldFP(cos, V, Ty, Context); break; case 'e': if (Len == 3 && !strcmp(Str, "exp")) - return ConstantFoldFP(exp, V, Ty); + return ConstantFoldFP(exp, V, Ty, Context); break; case 'f': if (Len == 4 && !strcmp(Str, "fabs")) - return ConstantFoldFP(fabs, V, Ty); + return ConstantFoldFP(fabs, V, Ty, Context); else if (Len == 5 && !strcmp(Str, "floor")) - return ConstantFoldFP(floor, V, Ty); + return ConstantFoldFP(floor, V, Ty, Context); break; case 'l': if (Len == 3 && !strcmp(Str, "log") && V > 0) - return ConstantFoldFP(log, V, Ty); + return ConstantFoldFP(log, V, Ty, Context); else if (Len == 5 && !strcmp(Str, "log10") && V > 0) - return ConstantFoldFP(log10, V, Ty); + return ConstantFoldFP(log10, V, Ty, Context); else if (!strcmp(Str, "llvm.sqrt.f32") || !strcmp(Str, "llvm.sqrt.f64")) { if (V >= -0.0) - return ConstantFoldFP(sqrt, V, Ty); + return ConstantFoldFP(sqrt, V, Ty, Context); else // Undefined - return Constant::getNullValue(Ty); + return Context->getNullValue(Ty); } break; case 's': if (Len == 3 && !strcmp(Str, "sin")) - return ConstantFoldFP(sin, V, Ty); + return ConstantFoldFP(sin, V, Ty, Context); else if (Len == 4 && !strcmp(Str, "sinh")) - return ConstantFoldFP(sinh, V, Ty); + return ConstantFoldFP(sinh, V, Ty, Context); else if (Len == 4 && !strcmp(Str, "sqrt") && V >= 0) - return ConstantFoldFP(sqrt, V, Ty); + return ConstantFoldFP(sqrt, V, Ty, Context); else if (Len == 5 && !strcmp(Str, "sqrtf") && V >= 0) - return ConstantFoldFP(sqrt, V, Ty); + return ConstantFoldFP(sqrt, V, Ty, Context); else if (Len == 4 && !strcmp(Str, "sinf")) - return ConstantFoldFP(sin, V, Ty); + return ConstantFoldFP(sin, V, Ty, Context); break; case 't': if (Len == 3 && !strcmp(Str, "tan")) - return ConstantFoldFP(tan, V, Ty); + return ConstantFoldFP(tan, V, Ty, Context); else if (Len == 4 && !strcmp(Str, "tanh")) - return ConstantFoldFP(tanh, V, Ty); + return ConstantFoldFP(tanh, V, Ty, Context); break; default: break; } } else if (ConstantInt *Op = dyn_cast(Operands[0])) { if (Len > 11 && !memcmp(Str, "llvm.bswap", 10)) - return ConstantInt::get(Op->getValue().byteSwap()); + return Context->getConstantInt(Op->getValue().byteSwap()); else if (Len > 11 && !memcmp(Str, "llvm.ctpop", 10)) - return ConstantInt::get(Ty, Op->getValue().countPopulation()); + return Context->getConstantInt(Ty, Op->getValue().countPopulation()); else if (Len > 10 && !memcmp(Str, "llvm.cttz", 9)) - return ConstantInt::get(Ty, Op->getValue().countTrailingZeros()); + return Context->getConstantInt(Ty, Op->getValue().countTrailingZeros()); else if (Len > 10 && !memcmp(Str, "llvm.ctlz", 9)) - return ConstantInt::get(Ty, Op->getValue().countLeadingZeros()); + return Context->getConstantInt(Ty, Op->getValue().countLeadingZeros()); } } else if (NumOperands == 2) { if (ConstantFP *Op1 = dyn_cast(Operands[0])) { @@ -805,18 +823,18 @@ Op2->getValueAPF().convertToDouble(); if (Len == 3 && !strcmp(Str, "pow")) { - return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty); + return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty, Context); } else if (Len == 4 && !strcmp(Str, "fmod")) { - return ConstantFoldBinaryFP(fmod, Op1V, Op2V, Ty); + return ConstantFoldBinaryFP(fmod, Op1V, Op2V, Ty, Context); } else if (Len == 5 && !strcmp(Str, "atan2")) { - return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty); + return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty, Context); } } else if (ConstantInt *Op2C = dyn_cast(Operands[1])) { if (!strcmp(Str, "llvm.powi.f32")) { - return ConstantFP::get(APFloat((float)std::pow((float)Op1V, + return Context->getConstantFP(APFloat((float)std::pow((float)Op1V, (int)Op2C->getZExtValue()))); } else if (!strcmp(Str, "llvm.powi.f64")) { - return ConstantFP::get(APFloat((double)std::pow((double)Op1V, + return Context->getConstantFP(APFloat((double)std::pow((double)Op1V, (int)Op2C->getZExtValue()))); } } Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jul 6 13:42:36 2009 @@ -3420,6 +3420,7 @@ if (Constant *C = dyn_cast(V)) return C; if (GlobalValue *GV = dyn_cast(V)) return GV; Instruction *I = cast(V); + LLVMContext* Context = I->getParent()->getContext(); std::vector Operands; Operands.resize(I->getNumOperands()); @@ -3431,10 +3432,12 @@ if (const CmpInst *CI = dyn_cast(I)) return ConstantFoldCompareInstOperands(CI->getPredicate(), - &Operands[0], Operands.size()); + &Operands[0], Operands.size(), + Context); else return ConstantFoldInstOperands(I->getOpcode(), I->getType(), - &Operands[0], Operands.size()); + &Operands[0], Operands.size(), + Context); } /// getConstantEvolutionLoopExitValue - If we know that the specified Phi is @@ -3636,10 +3639,11 @@ Constant *C; if (const CmpInst *CI = dyn_cast(I)) C = ConstantFoldCompareInstOperands(CI->getPredicate(), - &Operands[0], Operands.size()); + &Operands[0], Operands.size(), + Context); else C = ConstantFoldInstOperands(I->getOpcode(), I->getType(), - &Operands[0], Operands.size()); + &Operands[0], Operands.size(), Context); Pair.first->second = C; return getSCEV(C); } Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Jul 6 13:42:36 2009 @@ -282,7 +282,8 @@ /// users of the global, cleaning up the obvious ones. This is largely just a /// quick scan over the use list to clean up the easy and obvious cruft. This /// returns true if it made a change. -static bool CleanupConstantGlobalUsers(Value *V, Constant *Init) { +static bool CleanupConstantGlobalUsers(Value *V, Constant *Init, + LLVMContext* Context) { bool Changed = false; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;) { User *U = *UI++; @@ -302,12 +303,12 @@ if (CE->getOpcode() == Instruction::GetElementPtr) { Constant *SubInit = 0; if (Init) - SubInit = ConstantFoldLoadThroughGEPConstantExpr(Init, CE); - Changed |= CleanupConstantGlobalUsers(CE, SubInit); + SubInit = ConstantFoldLoadThroughGEPConstantExpr(Init, CE, Context); + Changed |= CleanupConstantGlobalUsers(CE, SubInit, Context); } else if (CE->getOpcode() == Instruction::BitCast && isa(CE->getType())) { // Pointer cast, delete any stores and memsets to the global. - Changed |= CleanupConstantGlobalUsers(CE, 0); + Changed |= CleanupConstantGlobalUsers(CE, 0, Context); } if (CE->use_empty()) { @@ -321,11 +322,11 @@ Constant *SubInit = 0; if (!isa(GEP->getOperand(0))) { ConstantExpr *CE = - dyn_cast_or_null(ConstantFoldInstruction(GEP)); + dyn_cast_or_null(ConstantFoldInstruction(GEP, Context)); if (Init && CE && CE->getOpcode() == Instruction::GetElementPtr) - SubInit = ConstantFoldLoadThroughGEPConstantExpr(Init, CE); + SubInit = ConstantFoldLoadThroughGEPConstantExpr(Init, CE, Context); } - Changed |= CleanupConstantGlobalUsers(GEP, SubInit); + Changed |= CleanupConstantGlobalUsers(GEP, SubInit, Context); if (GEP->use_empty()) { GEP->eraseFromParent(); @@ -343,7 +344,7 @@ if (SafeToDestroyConstant(C)) { C->destroyConstant(); // This could have invalidated UI, start over from scratch. - CleanupConstantGlobalUsers(V, Init); + CleanupConstantGlobalUsers(V, Init, Context); return true; } } @@ -783,7 +784,7 @@ // nor is the global. if (AllNonStoreUsesGone) { DOUT << " *** GLOBAL NOW DEAD!\n"; - CleanupConstantGlobalUsers(GV, 0); + CleanupConstantGlobalUsers(GV, 0, Context); if (GV->use_empty()) { GV->eraseFromParent(); ++NumDeleted; @@ -795,10 +796,10 @@ /// ConstantPropUsersOf - Walk the use list of V, constant folding all of the /// instructions that are foldable. -static void ConstantPropUsersOf(Value *V) { +static void ConstantPropUsersOf(Value *V, LLVMContext* Context) { for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ) if (Instruction *I = dyn_cast(*UI++)) - if (Constant *NewC = ConstantFoldInstruction(I)) { + if (Constant *NewC = ConstantFoldInstruction(I, Context)) { I->replaceAllUsesWith(NewC); // Advance UI to the next non-I use to avoid invalidating it! @@ -925,9 +926,9 @@ // To further other optimizations, loop over all users of NewGV and try to // constant prop them. This will promote GEP instructions with constant // indices into GEP constant-exprs, which will allow global-opt to hack on it. - ConstantPropUsersOf(NewGV); + ConstantPropUsersOf(NewGV, Context); if (RepValue != NewGV) - ConstantPropUsersOf(RepValue); + ConstantPropUsersOf(RepValue, Context); return NewGV; } @@ -1717,7 +1718,8 @@ // Delete any stores we can find to the global. We may not be able to // make it completely dead though. - bool Changed = CleanupConstantGlobalUsers(GV, GV->getInitializer()); + bool Changed = CleanupConstantGlobalUsers(GV, GV->getInitializer(), + Context); // If the global is dead now, delete it. if (GV->use_empty()) { @@ -1732,7 +1734,7 @@ GV->setConstant(true); // Clean up any obviously simplifiable users now. - CleanupConstantGlobalUsers(GV, GV->getInitializer()); + CleanupConstantGlobalUsers(GV, GV->getInitializer(), Context); // If the global is dead now, just nuke it. if (GV->use_empty()) { @@ -1762,7 +1764,7 @@ GV->setInitializer(SOVConstant); // Clean up any obviously simplifiable users now. - CleanupConstantGlobalUsers(GV, GV->getInitializer()); + CleanupConstantGlobalUsers(GV, GV->getInitializer(), Context); if (GV->use_empty()) { DOUT << " *** Substituting initializer allowed us to " @@ -2007,7 +2009,7 @@ /// enough for us to understand. In particular, if it is a cast of something, /// we punt. We basically just support direct accesses to globals and GEP's of /// globals. This should be kept up to date with CommitValueTo. -static bool isSimpleEnoughPointerToCommit(Constant *C) { +static bool isSimpleEnoughPointerToCommit(Constant *C, LLVMContext* Context) { if (GlobalVariable *GV = dyn_cast(C)) { if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage()) return false; // do not allow weak/linkonce/dllimport/dllexport linkage. @@ -2021,7 +2023,8 @@ if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage()) return false; // do not allow weak/linkonce/dllimport/dllexport linkage. return GV->hasInitializer() && - ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE); + ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE, + Context); } return false; } @@ -2113,7 +2116,8 @@ /// P after the stores reflected by 'memory' have been performed. If we can't /// decide, return null. static Constant *ComputeLoadResult(Constant *P, - const DenseMap &Memory) { + const DenseMap &Memory, + LLVMContext* Context) { // If this memory location has been recently stored, use the stored value: it // is the most up-to-date. DenseMap::const_iterator I = Memory.find(P); @@ -2132,7 +2136,8 @@ isa(CE->getOperand(0))) { GlobalVariable *GV = cast(CE->getOperand(0)); if (GV->hasInitializer()) - return ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE); + return ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE, + Context); } return 0; // don't know how to evaluate. @@ -2179,7 +2184,7 @@ if (StoreInst *SI = dyn_cast(CurInst)) { if (SI->isVolatile()) return false; // no volatile accesses. Constant *Ptr = getVal(Values, SI->getOperand(1)); - if (!isSimpleEnoughPointerToCommit(Ptr)) + if (!isSimpleEnoughPointerToCommit(Ptr, Context)) // If this is too complex for us to commit, reject it. return false; Constant *Val = getVal(Values, SI->getOperand(0)); @@ -2212,7 +2217,7 @@ } else if (LoadInst *LI = dyn_cast(CurInst)) { if (LI->isVolatile()) return false; // no volatile accesses. InstResult = ComputeLoadResult(getVal(Values, LI->getOperand(0)), - MutatedMemory); + MutatedMemory, Context); if (InstResult == 0) return false; // Could not evaluate load. } else if (AllocaInst *AI = dyn_cast(CurInst)) { if (AI->isArrayAllocation()) return false; // Cannot handle array allocs. Modified: llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp Mon Jul 6 13:42:36 2009 @@ -21,6 +21,7 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Support/Compiler.h" @@ -62,10 +63,10 @@ if (!I->isDeclaration()) ++NumFunctions; - const Type *ATy = ArrayType::get(Type::Int32Ty, NumFunctions); + const Type *ATy = Context->getArrayType(Type::Int32Ty, NumFunctions); GlobalVariable *Counters = new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, - Constant::getNullValue(ATy), "FuncProfCounters", &M); + Context->getNullValue(ATy), "FuncProfCounters", &M); // Instrument all of the functions... unsigned i = 0; @@ -107,10 +108,10 @@ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) NumBlocks += I->size(); - const Type *ATy = ArrayType::get(Type::Int32Ty, NumBlocks); + const Type *ATy = Context->getArrayType(Type::Int32Ty, NumBlocks); GlobalVariable *Counters = new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, - Constant::getNullValue(ATy), "BlockProfCounters", &M); + Context->getNullValue(ATy), "BlockProfCounters", &M); // Instrument all of the blocks... unsigned i = 0; Modified: llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp Mon Jul 6 13:42:36 2009 @@ -20,6 +20,7 @@ #include "ProfilingUtils.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Support/Compiler.h" @@ -63,10 +64,10 @@ NumEdges += BB->getTerminator()->getNumSuccessors(); } - const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges); + const Type *ATy = Context->getArrayType(Type::Int32Ty, NumEdges); GlobalVariable *Counters = new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, - Constant::getNullValue(ATy), "EdgeProfCounters", &M); + Context->getNullValue(ATy), "EdgeProfCounters", &M); // Instrument all of the edges... unsigned i = 0; Modified: llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp Mon Jul 6 13:42:36 2009 @@ -18,13 +18,15 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, GlobalValue *Array) { + LLVMContext* Context = MainFn->getContext(); const Type *ArgVTy = - PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty)); - const PointerType *UIntPtr = PointerType::getUnqual(Type::Int32Ty); + Context->getPointerTypeUnqual(Context->getPointerTypeUnqual(Type::Int8Ty)); + const PointerType *UIntPtr = Context->getPointerTypeUnqual(Type::Int32Ty); Module &M = *MainFn->getParent(); Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty, ArgVTy, UIntPtr, Type::Int32Ty, @@ -33,27 +35,27 @@ // This could force argc and argv into programs that wouldn't otherwise have // them, but instead we just pass null values in. std::vector Args(4); - Args[0] = Constant::getNullValue(Type::Int32Ty); - Args[1] = Constant::getNullValue(ArgVTy); + Args[0] = Context->getNullValue(Type::Int32Ty); + Args[1] = Context->getNullValue(ArgVTy); // Skip over any allocas in the entry block. BasicBlock *Entry = MainFn->begin(); BasicBlock::iterator InsertPos = Entry->begin(); while (isa(InsertPos)) ++InsertPos; - std::vector GEPIndices(2, Constant::getNullValue(Type::Int32Ty)); + std::vector GEPIndices(2, Context->getNullValue(Type::Int32Ty)); unsigned NumElements = 0; if (Array) { - Args[2] = ConstantExpr::getGetElementPtr(Array, &GEPIndices[0], + Args[2] = Context->getConstantExprGetElementPtr(Array, &GEPIndices[0], GEPIndices.size()); NumElements = cast(Array->getType()->getElementType())->getNumElements(); } else { // If this profiling instrumentation doesn't have a constant array, just // pass null. - Args[2] = ConstantPointerNull::get(UIntPtr); + Args[2] = Context->getConstantPointerNull(UIntPtr); } - Args[3] = ConstantInt::get(Type::Int32Ty, NumElements); + Args[3] = Context->getConstantInt(Type::Int32Ty, NumElements); Instruction *InitCall = CallInst::Create(InitFn, Args.begin(), Args.end(), "newargc", InsertPos); @@ -99,6 +101,8 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, GlobalValue *CounterArray) { + LLVMContext* Context = BB->getContext(); + // Insert the increment after any alloca or PHI instructions... BasicBlock::iterator InsertPos = BB->getFirstNonPHI(); while (isa(InsertPos)) @@ -106,15 +110,16 @@ // Create the getelementptr constant expression std::vector Indices(2); - Indices[0] = Constant::getNullValue(Type::Int32Ty); - Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum); + Indices[0] = Context->getNullValue(Type::Int32Ty); + Indices[1] = Context->getConstantInt(Type::Int32Ty, CounterNum); Constant *ElementPtr = - ConstantExpr::getGetElementPtr(CounterArray, &Indices[0], Indices.size()); + Context->getConstantExprGetElementPtr(CounterArray, &Indices[0], + Indices.size()); // Load, increment and store the value back. Value *OldVal = new LoadInst(ElementPtr, "OldFuncCounter", InsertPos); Value *NewVal = BinaryOperator::Create(Instruction::Add, OldVal, - ConstantInt::get(Type::Int32Ty, 1), + Context->getConstantInt(Type::Int32Ty, 1), "NewFuncCounter", InsertPos); new StoreInst(NewVal, ElementPtr, InsertPos); } Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Mon Jul 6 13:42:36 2009 @@ -33,6 +33,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Pass.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Instructions.h" #include "llvm/Constants.h" @@ -195,7 +196,7 @@ GlobalRandomCounter::GlobalRandomCounter(Module& M, const IntegerType* t, uint64_t resetval) : T(t) { - ConstantInt* Init = ConstantInt::get(T, resetval); + ConstantInt* Init = M.getContext().getConstantInt(T, resetval); ResetValue = Init; Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, Init, "RandomSteeringCounter", &M); @@ -207,14 +208,16 @@ void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) { BranchInst* t = cast(bb->getTerminator()); + LLVMContext* Context = bb->getContext(); //decrement counter LoadInst* l = new LoadInst(Counter, "counter", t); - ICmpInst* s = new ICmpInst(ICmpInst::ICMP_EQ, l, ConstantInt::get(T, 0), + ICmpInst* s = new ICmpInst(ICmpInst::ICMP_EQ, l, + Context->getConstantInt(T, 0), "countercc", t); - Value* nv = BinaryOperator::CreateSub(l, ConstantInt::get(T, 1), + Value* nv = BinaryOperator::CreateSub(l, Context->getConstantInt(T, 1), "counternew", t); new StoreInst(nv, Counter, t); t->setCondition(s); @@ -232,7 +235,7 @@ GlobalRandomCounterOpt::GlobalRandomCounterOpt(Module& M, const IntegerType* t, uint64_t resetval) : AI(0), T(t) { - ConstantInt* Init = ConstantInt::get(T, resetval); + ConstantInt* Init = M.getContext().getConstantInt(T, resetval); ResetValue = Init; Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, Init, "RandomSteeringCounter", &M); @@ -279,14 +282,16 @@ void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) { BranchInst* t = cast(bb->getTerminator()); + LLVMContext* Context = bb->getContext(); //decrement counter LoadInst* l = new LoadInst(AI, "counter", t); - ICmpInst* s = new ICmpInst(ICmpInst::ICMP_EQ, l, ConstantInt::get(T, 0), + ICmpInst* s = new ICmpInst(ICmpInst::ICMP_EQ, l, + Context->getConstantInt(T, 0), "countercc", t); - Value* nv = BinaryOperator::CreateSub(l, ConstantInt::get(T, 1), + Value* nv = BinaryOperator::CreateSub(l, Context->getConstantInt(T, 1), "counternew", t); new StoreInst(nv, AI, t); t->setCondition(s); @@ -312,14 +317,15 @@ void CycleCounter::ProcessChoicePoint(BasicBlock* bb) { BranchInst* t = cast(bb->getTerminator()); + LLVMContext* Context = bb->getContext(); CallInst* c = CallInst::Create(F, "rdcc", t); BinaryOperator* b = - BinaryOperator::CreateAnd(c, ConstantInt::get(Type::Int64Ty, rm), + BinaryOperator::CreateAnd(c, Context->getConstantInt(Type::Int64Ty, rm), "mrdcc", t); ICmpInst *s = new ICmpInst(ICmpInst::ICMP_EQ, b, - ConstantInt::get(Type::Int64Ty, 0), + Context->getConstantInt(Type::Int64Ty, 0), "mrdccc", t); t->setCondition(s); @@ -345,16 +351,16 @@ // Create the getelementptr constant expression std::vector Indices(2); - Indices[0] = Constant::getNullValue(Type::Int32Ty); - Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum); - Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, + Indices[0] = Context->getNullValue(Type::Int32Ty); + Indices[1] = Context->getConstantInt(Type::Int32Ty, CounterNum); + Constant *ElementPtr = Context->getConstantExprGetElementPtr(CounterArray, &Indices[0], 2); // Load, increment and store the value back. Value *OldVal = new LoadInst(ElementPtr, "OldCounter", InsertPos); profcode.insert(OldVal); Value *NewVal = BinaryOperator::CreateAdd(OldVal, - ConstantInt::get(Type::Int32Ty, 1), + Context->getConstantInt(Type::Int32Ty, 1), "NewCounter", InsertPos); profcode.insert(NewVal); profcode.insert(new StoreInst(NewVal, ElementPtr, InsertPos)); @@ -475,7 +481,7 @@ //b: BranchInst::Create(cast(Translate(dst)), bbC); BranchInst::Create(dst, cast(Translate(dst)), - ConstantInt::get(Type::Int1Ty, true), bbCp); + Context->getConstantInt(Type::Int1Ty, true), bbCp); //c: { TerminatorInst* iB = src->getTerminator(); @@ -532,7 +538,7 @@ ReplaceInstWithInst(T, BranchInst::Create(T->getSuccessor(0), cast( Translate(T->getSuccessor(0))), - ConstantInt::get(Type::Int1Ty, + Context->getConstantInt(Type::Int1Ty, true))); //do whatever is needed now that the function is duplicated Modified: llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp Mon Jul 6 13:42:36 2009 @@ -67,7 +67,7 @@ WorkList.erase(WorkList.begin()); // Get an element from the worklist... if (!I->use_empty()) // Don't muck with dead instructions... - if (Constant *C = ConstantFoldInstruction(I)) { + if (Constant *C = ConstantFoldInstruction(I, Context)) { // Add all of the users of this instruction to the worklist, they might // be constant propagatable now... for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jul 6 13:42:36 2009 @@ -11598,7 +11598,8 @@ if (GlobalVariable *GV = dyn_cast(CE->getOperand(0))) if (GV->isConstant() && GV->hasDefinitiveInitializer()) if (Constant *V = - ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE)) + ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE, + Context)) return ReplaceInstUsesWith(LI, V); if (CE->getOperand(0)->isNullValue()) { // Insert a new store to null instruction before the load to indicate @@ -12876,7 +12877,7 @@ } // ConstantProp instruction if trivially constant. - if (Constant *C = ConstantFoldInstruction(Inst, TD)) { + if (Constant *C = ConstantFoldInstruction(Inst, BB->getContext(), TD)) { DOUT << "IC: ConstFold to: " << *C << " from: " << *Inst; Inst->replaceAllUsesWith(C); ++NumConstProp; @@ -12991,7 +12992,7 @@ } // Instruction isn't dead, see if we can constant propagate it. - if (Constant *C = ConstantFoldInstruction(I, TD)) { + if (Constant *C = ConstantFoldInstruction(I, F.getContext(), TD)) { DOUT << "IC: ConstFold to: " << *C << " from: " << *I; // Add operands to the worklist. @@ -13011,7 +13012,8 @@ // See if we can constant fold its operands. for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) if (ConstantExpr *CE = dyn_cast(i)) - if (Constant *NewC = ConstantFoldConstantExpression(CE, TD)) + if (Constant *NewC = ConstantFoldConstantExpression(CE, + F.getContext(), TD)) if (NewC != CE) { i->set(NewC); Changed = true; Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Jul 6 13:42:36 2009 @@ -982,7 +982,7 @@ BI = NewBB->begin(); for (BasicBlock::iterator E = NewBB->end(); BI != E; ) { Instruction *Inst = BI++; - if (Constant *C = ConstantFoldInstruction(Inst, TD)) { + if (Constant *C = ConstantFoldInstruction(Inst, BB->getContext(), TD)) { Inst->replaceAllUsesWith(C); Inst->eraseFromParent(); continue; Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Mon Jul 6 13:42:36 2009 @@ -986,7 +986,7 @@ Worklist.pop_back(); // Simple constant folding. - if (Constant *C = ConstantFoldInstruction(I)) { + if (Constant *C = ConstantFoldInstruction(I, Context)) { ReplaceUsesOfWith(I, C, Worklist, L, LPM); continue; } Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Jul 6 13:42:36 2009 @@ -1158,7 +1158,8 @@ if (GlobalVariable *GV = dyn_cast(CE->getOperand(0))) if (GV->isConstant() && GV->hasDefinitiveInitializer()) if (Constant *V = - ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE)) { + ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE, + Context)) { markConstant(IV, &I, V); return; } Modified: llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp Mon Jul 6 13:42:36 2009 @@ -358,7 +358,7 @@ Instruction *Inst = BI++; if (isInstructionTriviallyDead(Inst)) Inst->eraseFromParent(); - else if (Constant *C = ConstantFoldInstruction(Inst)) { + else if (Constant *C = ConstantFoldInstruction(Inst, Context)) { Inst->replaceAllUsesWith(C); Inst->eraseFromParent(); } Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Mon Jul 6 13:42:36 2009 @@ -338,7 +338,8 @@ if (const CmpInst *CI = dyn_cast(I)) return ConstantFoldCompareInstOperands(CI->getPredicate(), - &Ops[0], Ops.size(), TD); + &Ops[0], Ops.size(), + Context, TD); if (const LoadInst *LI = dyn_cast(I)) if (ConstantExpr *CE = dyn_cast(Ops[0])) @@ -346,10 +347,10 @@ if (GlobalVariable *GV = dyn_cast(CE->getOperand(0))) if (GV->isConstant() && GV->hasDefinitiveInitializer()) return ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), - CE); + CE, Context); return ConstantFoldInstOperands(I->getOpcode(), I->getType(), &Ops[0], - Ops.size(), TD); + Ops.size(), Context, TD); } /// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto, Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Jul 6 13:42:36 2009 @@ -1178,6 +1178,7 @@ /// ultimate destination. static bool FoldCondBranchOnPHI(BranchInst *BI) { BasicBlock *BB = BI->getParent(); + LLVMContext* Context = BB->getContext(); PHINode *PN = dyn_cast(BI->getCondition()); // NOTE: we currently cannot transform this case if the PHI node is used // outside of the block. @@ -1243,7 +1244,7 @@ } // Check for trivial simplification. - if (Constant *C = ConstantFoldInstruction(N)) { + if (Constant *C = ConstantFoldInstruction(N, Context)) { TranslateMap[BBI] = C; delete N; // Constant folded away, don't need actual inst } else { Modified: llvm/trunk/lib/Transforms/Utils/UnrollLoop.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/UnrollLoop.cpp?rev=74844&r1=74843&r2=74844&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/UnrollLoop.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/UnrollLoop.cpp Mon Jul 6 13:42:36 2009 @@ -349,7 +349,8 @@ if (isInstructionTriviallyDead(Inst)) (*BB)->getInstList().erase(Inst); - else if (Constant *C = ConstantFoldInstruction(Inst)) { + else if (Constant *C = ConstantFoldInstruction(Inst, + Header->getContext())) { Inst->replaceAllUsesWith(C); (*BB)->getInstList().erase(Inst); } From resistor at mac.com Mon Jul 6 13:44:08 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 06 Jul 2009 18:44:08 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r74845 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-convert.cpp Message-ID: <200907061844.n66Ii969032213@zion.cs.uiuc.edu> Author: resistor Date: Mon Jul 6 13:44:04 2009 New Revision: 74845 URL: http://llvm.org/viewvc/llvm-project?rev=74845&view=rev Log: Update for constant folding API changes. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=74845&r1=74844&r2=74845&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Jul 6 13:44:04 2009 @@ -466,7 +466,7 @@ TheTarget = TME->CtorFn(*TheModule, FeatureStr); assert(TheTarget->getTargetData()->isBigEndian() == BYTES_BIG_ENDIAN); - TheFolder = new TargetFolder(TheTarget->getTargetData()); + TheFolder = new TargetFolder(TheTarget->getTargetData(), &getGlobalContext()); // Install information about target datalayout stuff into the module for // optimizer use. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=74845&r1=74844&r2=74845&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Jul 6 13:44:04 2009 @@ -33,6 +33,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/InlineAsm.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/System/Host.h" @@ -7904,7 +7905,7 @@ FieldPtr = ConstantFoldInstOperands(Instruction::GetElementPtr, FieldPtr->getType(), Ops, - 3, &TD); + 3, &getGlobalContext(), &TD); // Now that we did an offset from the start of the struct, subtract off // the offset from BitStart. From resistor at mac.com Mon Jul 6 13:50:55 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 06 Jul 2009 18:50:55 -0000 Subject: [llvm-commits] [llvm] r74846 - /llvm/trunk/lib/System/Threading.cpp Message-ID: <200907061850.n66IoxVS032412@zion.cs.uiuc.edu> Author: resistor Date: Mon Jul 6 13:50:47 2009 New Revision: 74846 URL: http://llvm.org/viewvc/llvm-project?rev=74846&view=rev Log: We need to include config.h to get the proper setting to LLVM_MULTITHREADED. Patch by Xerxes Ranby. Modified: llvm/trunk/lib/System/Threading.cpp Modified: llvm/trunk/lib/System/Threading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Threading.cpp?rev=74846&r1=74845&r2=74846&view=diff ============================================================================== --- llvm/trunk/lib/System/Threading.cpp (original) +++ llvm/trunk/lib/System/Threading.cpp Mon Jul 6 13:50:47 2009 @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Config/config.h" #include "llvm/System/Threading.h" #include "llvm/System/Atomic.h" #include "llvm/System/Mutex.h" From evan.cheng at apple.com Mon Jul 6 14:11:05 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 6 Jul 2009 12:11:05 -0700 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction In-Reply-To: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> Message-ID: <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> Sorry, I am missing some context. Why is each of the emitter a separate template instantiation in the first place? Why can't the code in X86CodeEmitter.cpp be shared across all 3? Evan On Jul 6, 2009, at 10:57 AM, Aaron Gray wrote: > This patch separates the template instatiations for the > createX86*CodeEmitterPass of [X86]Emiiter into > separate .cpp file and thus different object modules in the library. > This will result in a slightly smaller footprint for programs just > using one of the MachineCodeEmitter, ObjectCodeEmitter, or > JITCodeEmitter classes. > > This should save 2 * 47K each for llc, lli, and LTOCodeGenerator. > > Although the MachineCodeEmitter version is not being use anymore at > present I have left it in for now. > > It also opens the door for altername MachineCodeEmitters for > experimental or other purposes such as unladen Swallow. > > I will be submitting simular patches for Alpha, ARM, and PowerPC if > this one gets accepted. > > I have made CMake the necessary CMake changes too in the patch. > > This patch needs to be applied relatively quickly as it moves > X86CodeEmitter.cpp code to X86CodeEmitter.h and any chages in SVN > inbetween would be lost. > > Aaron > > From mai4 at uiuc.edu Mon Jul 6 14:32:56 2009 From: mai4 at uiuc.edu (Haohui Mai) Date: Mon, 06 Jul 2009 19:32:56 -0000 Subject: [llvm-commits] [poolalloc] r74848 - in /poolalloc/trunk/lib/DSA: Steensgaard.cpp SteensgaardAA.cpp Message-ID: <200907061932.n66JWuwL001216@zion.cs.uiuc.edu> Author: mai4 Date: Mon Jul 6 14:32:55 2009 New Revision: 74848 URL: http://llvm.org/viewvc/llvm-project?rev=74848&view=rev Log: Export the DSGraph interface of steensgaard alais analysis. Added: poolalloc/trunk/lib/DSA/SteensgaardAA.cpp Modified: poolalloc/trunk/lib/DSA/Steensgaard.cpp Modified: poolalloc/trunk/lib/DSA/Steensgaard.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Steensgaard.cpp?rev=74848&r1=74847&r2=74848&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Steensgaard.cpp (original) +++ poolalloc/trunk/lib/DSA/Steensgaard.cpp Mon Jul 6 14:32:55 2009 @@ -1,4 +1,4 @@ -//===- Steensgaard.cpp - Context Insensitive Alias Analysis ---------------===// +//===- Steensgaard.cpp - Context Insensitive Data Structure Analysis ------===// // // The LLVM Compiler Infrastructure // @@ -7,10 +7,9 @@ // //===----------------------------------------------------------------------===// // -// This pass uses the data structure graphs to implement a simple context -// insensitive alias analysis. It does this by computing the local analysis -// graphs for all of the functions, then merging them together into a single big -// graph without cloning. +// This pass computes a context-insensitive data analysis graph. It does this +// by computing the local analysis graphs for all of the functions, then merging +// them together into a single big graph without cloning. // //===----------------------------------------------------------------------===// @@ -21,116 +20,57 @@ #include "llvm/Module.h" #include "llvm/Support/Debug.h" #include -using namespace llvm; - -namespace { - class Steens : public ModulePass, public AliasAnalysis { - DSGraph *ResultGraph; - - EquivalenceClasses GlobalECs; // Always empty - public: - static char ID; - Steens() : ModulePass((intptr_t)&ID), ResultGraph(0) {} - ~Steens() { - releaseMyMemory(); - assert(ResultGraph == 0 && "releaseMemory not called?"); - } - - //------------------------------------------------ - // Implement the Pass API - // - - // run - Build up the result graph, representing the pointer graph for the - // program. - // - bool runOnModule(Module &M); - - virtual void releaseMyMemory() { delete ResultGraph; ResultGraph = 0; } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AliasAnalysis::getAnalysisUsage(AU); - AU.setPreservesAll(); // Does not transform code... - AU.addRequired(); // Uses local dsgraph - } - - // print - Implement the Pass::print method... - void print(OStream O, const Module *M) const { - if (O.stream()) print(*O.stream(), M); - } - void print(std::ostream &O, const Module *M) const { - assert(ResultGraph && "Result graph has not yet been computed!"); - ResultGraph->writeGraphToFile(O, "steensgaards"); - } - //------------------------------------------------ - // Implement the AliasAnalysis API - // - - AliasResult alias(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size); - - virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); - virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2); - - private: - void ResolveFunctionCall(const Function *F, const DSCallSite &Call, - DSNodeHandle &RetVal); - }; - - // Register the pass... - RegisterPass X("steens-aa", - "Steensgaard's alias analysis (DSGraph based)"); +using namespace llvm; - // Register as an implementation of AliasAnalysis - RegisterAnalysisGroup Y(X); +SteensgaardDataStructures::~SteensgaardDataStructures() { + releaseMyMemory(); + assert(ResultGraph == 0 && "releaseMemory not called?"); } -char Steens::ID; - -ModulePass *llvm::createSteensgaardPass() { return new Steens(); } - -/// ResolveFunctionCall - Resolve the actual arguments of a call to function F -/// with the specified call site descriptor. This function links the arguments -/// and the return value for the call site context-insensitively. -/// -void Steens::ResolveFunctionCall(const Function *F, const DSCallSite &Call, - DSNodeHandle &RetVal) { - assert(ResultGraph != 0 && "Result graph not allocated!"); - DSGraph::ScalarMapTy &ValMap = ResultGraph->getScalarMap(); - - // Handle the return value of the function... - if (Call.getRetVal().getNode() && RetVal.getNode()) - RetVal.mergeWith(Call.getRetVal()); +void +SteensgaardDataStructures::releaseMyMemory() { + delete ResultGraph; + ResultGraph = 0; +} - // Loop over all pointer arguments, resolving them to their provided pointers - unsigned PtrArgIdx = 0; - for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end(); - AI != AE && PtrArgIdx < Call.getNumPtrArgs(); ++AI) { - DSGraph::ScalarMapTy::iterator I = ValMap.find(AI); - if (I != ValMap.end()) // If its a pointer argument... - I->second.mergeWith(Call.getPtrArg(PtrArgIdx++)); - } +// print - Implement the Pass::print method... +void +SteensgaardDataStructures::print(OStream O, const Module *M) const { + if (O.stream()) print(*O.stream(), M); } +void +SteensgaardDataStructures::print(std::ostream &O, const Module *M) const { + assert(ResultGraph && "Result graph has not yet been computed!"); + ResultGraph->writeGraphToFile(O, "steensgaards"); +} /// run - Build up the result graph, representing the pointer graph for the /// program. /// -bool Steens::runOnModule(Module &M) { - InitializeAliasAnalysis(this); +bool +SteensgaardDataStructures::runOnModule(Module &M) { + DS = &getAnalysis(); + return runOnModuleInternal(M); +} + +bool +SteensgaardDataStructures::runOnModuleInternal(Module &M) { assert(ResultGraph == 0 && "Result graph already allocated!"); - LocalDataStructures &LDS = getAnalysis(); // Create a new, empty, graph... ResultGraph = new DSGraph(GlobalECs, getTargetData()); - ResultGraph->spliceFrom(LDS.getGlobalsGraph()); + ResultGraph->spliceFrom(DS->getGlobalsGraph()); // Loop over the rest of the module, merging graphs for non-external functions // into this graph. // - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isDeclaration()) - ResultGraph->spliceFrom(LDS.getDSGraph(*I)); + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { + if (!I->isDeclaration()) { + ResultGraph->spliceFrom(DS->getDSGraph(*I)); + } + } ResultGraph->removeTriviallyDeadNodes(); @@ -139,11 +79,9 @@ // Now that we have all of the graphs inlined, we can go about eliminating // call nodes... // - std::list &Calls = ResultGraph->getAuxFunctionCalls(); - assert(Calls.empty() && "Aux call list is already in use??"); // Start with a copy of the original call sites. - Calls = ResultGraph->getFunctionCalls(); + std::list & Calls = ResultGraph->getFunctionCalls(); for (std::list::iterator CI = Calls.begin(), E = Calls.end(); CI != E;) { @@ -187,95 +125,47 @@ // Update the "incomplete" markers on the nodes, ignoring unknownness due to // incoming arguments... ResultGraph->maskIncompleteMarkers(); - ResultGraph->markIncompleteNodes(DSGraph::IgnoreGlobals | - DSGraph::MarkFormalArgs); + + ResultGraph->markIncompleteNodes(DSGraph::MarkFormalArgs | DSGraph::IgnoreGlobals); // Remove any nodes that are dead after all of the merging we have done... // FIXME: We should be able to disable the globals graph for steens! - //ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals); + + ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals); print(DOUT, &M); return false; } -AliasAnalysis::AliasResult Steens::alias(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size) { - assert(ResultGraph && "Result graph has not been computed yet!"); - - DSGraph::ScalarMapTy &GSM = ResultGraph->getScalarMap(); - - DSGraph::ScalarMapTy::iterator I = GSM.find(const_cast(V1)); - DSGraph::ScalarMapTy::iterator J = GSM.find(const_cast(V2)); - if (I != GSM.end() && !I->second.isNull() && - J != GSM.end() && !J->second.isNull()) { - DSNodeHandle &V1H = I->second; - DSNodeHandle &V2H = J->second; - - // If at least one of the nodes is complete, we can say something about - // this. If one is complete and the other isn't, then they are obviously - // different nodes. If they are both complete, we can't say anything - // useful. - if (I->second.getNode()->isCompleteNode() || - J->second.getNode()->isCompleteNode()) { - // If the two pointers point to different data structure graph nodes, they - // cannot alias! - if (V1H.getNode() != V2H.getNode()) - return NoAlias; - - // See if they point to different offsets... if so, we may be able to - // determine that they do not alias... - unsigned O1 = I->second.getOffset(), O2 = J->second.getOffset(); - if (O1 != O2) { - if (O2 < O1) { // Ensure that O1 <= O2 - std::swap(V1, V2); - std::swap(O1, O2); - std::swap(V1Size, V2Size); - } - - if (O1+V1Size <= O2) - return NoAlias; - } - } - } +/// ResolveFunctionCall - Resolve the actual arguments of a call to function F +/// with the specified call site descriptor. This function links the arguments +/// and the return value for the call site context-insensitively. +/// +void +SteensgaardDataStructures::ResolveFunctionCall(const Function *F, + const DSCallSite &Call, + DSNodeHandle &RetVal) { - // If we cannot determine alias properties based on our graph, fall back on - // some other AA implementation. - // - return AliasAnalysis::alias(V1, V1Size, V2, V2Size); -} + assert(ResultGraph != 0 && "Result graph not allocated!"); + DSGraph::ScalarMapTy &ValMap = ResultGraph->getScalarMap(); -AliasAnalysis::ModRefResult -Steens::getModRefInfo(CallSite CS, Value *P, unsigned Size) { - AliasAnalysis::ModRefResult Result = ModRef; - - // Find the node in question. - DSGraph::ScalarMapTy &GSM = ResultGraph->getScalarMap(); - DSGraph::ScalarMapTy::iterator I = GSM.find(P); - - if (I != GSM.end() && !I->second.isNull()) { - DSNode *N = I->second.getNode(); - if (N->isCompleteNode()) { - // If this is a direct call to an external function, and if the pointer - // points to a complete node, the external function cannot modify or read - // the value (we know it's not passed out of the program!). - if (Function *F = CS.getCalledFunction()) - if (F->isDeclaration()) - return NoModRef; - - // Otherwise, if the node is complete, but it is only M or R, return this. - // This can be useful for globals that should be marked const but are not. - if (!N->isModifiedNode()) - Result = (ModRefResult)(Result & ~Mod); - if (!N->isReadNode()) - Result = (ModRefResult)(Result & ~Ref); - } - } + // Handle the return value of the function... + if (Call.getRetVal().getNode() && RetVal.getNode()) + RetVal.mergeWith(Call.getRetVal()); - return (ModRefResult)(Result & AliasAnalysis::getModRefInfo(CS, P, Size)); + // Loop over all pointer arguments, resolving them to their provided pointers + unsigned PtrArgIdx = 0; + for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end(); + AI != AE && PtrArgIdx < Call.getNumPtrArgs(); ++AI) { + DSGraph::ScalarMapTy::iterator I = ValMap.find(AI); + if (I != ValMap.end()) // If its a pointer argument... + I->second.mergeWith(Call.getPtrArg(PtrArgIdx++)); + } } -AliasAnalysis::ModRefResult -Steens::getModRefInfo(CallSite CS1, CallSite CS2) -{ - return AliasAnalysis::getModRefInfo(CS1,CS2); -} +char SteensgaardDataStructures::ID = 0; + +// Register the pass... +static RegisterPass X +("dsa-steens", + "Context-insensitive Data Structure Analysis"); Added: poolalloc/trunk/lib/DSA/SteensgaardAA.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/SteensgaardAA.cpp?rev=74848&view=auto ============================================================================== --- poolalloc/trunk/lib/DSA/SteensgaardAA.cpp (added) +++ poolalloc/trunk/lib/DSA/SteensgaardAA.cpp Mon Jul 6 14:32:55 2009 @@ -0,0 +1,162 @@ +//===- Steensgaard.cpp - Context Insensitive Alias Analysis ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This pass uses the data structure graphs to implement a simple context +// insensitive alias analysis. It does this by computing the local analysis +// graphs for all of the functions, then merging them together into a single big +// graph without cloning. +// +//===----------------------------------------------------------------------===// + +#include "dsa/DataStructure.h" +#include "dsa/DSGraph.h" +#include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/Analysis/Passes.h" +#include "llvm/Module.h" +#include "llvm/Support/Debug.h" +#include +using namespace llvm; + +namespace { + class Steens : public ModulePass, public AliasAnalysis { + DSGraph * ResultGraph; + public: + static char ID; + Steens() : ModulePass((intptr_t)&ID), ResultGraph(NULL) {} + ~Steens() { } + + //------------------------------------------------ + // Implement the Pass API + // + + // run - Build up the result graph, representing the pointer graph for the + // program. + // + bool runOnModule(Module &M); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AliasAnalysis::getAnalysisUsage(AU); + AU.setPreservesAll(); // Does not transform code... + AU.addRequired(); // Uses steensgaard dsgraph + } + + //------------------------------------------------ + // Implement the AliasAnalysis API + // + + AliasResult alias(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size); + + virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); + virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2); + + }; + + // Register the pass... + RegisterPass X("steens-aa", + "Steensgaard's alias analysis (DSGraph based)"); + + // Register as an implementation of AliasAnalysis + RegisterAnalysisGroup Y(X); +} + +char Steens::ID; + +ModulePass *llvm::createSteensgaardPass() { return new Steens(); } + +/// run - Build up the result graph, representing the pointer graph for the +/// program. +/// +bool Steens::runOnModule(Module &M) { + InitializeAliasAnalysis(this); + ResultGraph = getAnalysis().getResultGraph(); + return false; +} + +AliasAnalysis::AliasResult Steens::alias(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size) { + assert(ResultGraph && "Result graph has not been computed yet!"); + + DSGraph::ScalarMapTy &GSM = ResultGraph->getScalarMap(); + + DSGraph::ScalarMapTy::iterator I = GSM.find(const_cast(V1)); + DSGraph::ScalarMapTy::iterator J = GSM.find(const_cast(V2)); + if (I != GSM.end() && !I->second.isNull() && + J != GSM.end() && !J->second.isNull()) { + DSNodeHandle &V1H = I->second; + DSNodeHandle &V2H = J->second; + + // If at least one of the nodes is complete, we can say something about + // this. If one is complete and the other isn't, then they are obviously + // different nodes. If they are both complete, we can't say anything + // useful. + if (I->second.getNode()->isCompleteNode() || + J->second.getNode()->isCompleteNode()) { + // If the two pointers point to different data structure graph nodes, they + // cannot alias! + if (V1H.getNode() != V2H.getNode()) + return NoAlias; + + // See if they point to different offsets... if so, we may be able to + // determine that they do not alias... + unsigned O1 = I->second.getOffset(), O2 = J->second.getOffset(); + if (O1 != O2) { + if (O2 < O1) { // Ensure that O1 <= O2 + std::swap(V1, V2); + std::swap(O1, O2); + std::swap(V1Size, V2Size); + } + + if (O1+V1Size <= O2) + return NoAlias; + } + } + } + + // If we cannot determine alias properties based on our graph, fall back on + // some other AA implementation. + // + return AliasAnalysis::alias(V1, V1Size, V2, V2Size); +} + +AliasAnalysis::ModRefResult +Steens::getModRefInfo(CallSite CS, Value *P, unsigned Size) { + AliasAnalysis::ModRefResult Result = ModRef; + + // Find the node in question. + DSGraph::ScalarMapTy &GSM = ResultGraph->getScalarMap(); + DSGraph::ScalarMapTy::iterator I = GSM.find(P); + + if (I != GSM.end() && !I->second.isNull()) { + DSNode *N = I->second.getNode(); + if (N->isCompleteNode()) { + // If this is a direct call to an external function, and if the pointer + // points to a complete node, the external function cannot modify or read + // the value (we know it's not passed out of the program!). + if (Function *F = CS.getCalledFunction()) + if (F->isDeclaration()) + return NoModRef; + + // Otherwise, if the node is complete, but it is only M or R, return this. + // This can be useful for globals that should be marked const but are not. + if (!N->isModifiedNode()) + Result = (ModRefResult)(Result & ~Mod); + if (!N->isReadNode()) + Result = (ModRefResult)(Result & ~Ref); + } + } + + return (ModRefResult)(Result & AliasAnalysis::getModRefInfo(CS, P, Size)); +} + +AliasAnalysis::ModRefResult +Steens::getModRefInfo(CallSite CS1, CallSite CS2) +{ + return AliasAnalysis::getModRefInfo(CS1,CS2); +} From bruno.cardoso at gmail.com Mon Jul 6 14:53:36 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 6 Jul 2009 16:53:36 -0300 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction In-Reply-To: <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> Message-ID: <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> On Mon, Jul 6, 2009 at 4:11 PM, Evan Cheng wrote: > Sorry, I am missing some context. Why is each of the emitter a separate > template instantiation in the first place? Why can't the code in This happens because ObjectCodeEmitter is a lot simpler than JITCodeEmitter and we don't need to deal with CurrBufferBegin, GVStub*, and so on. > X86CodeEmitter.cpp be shared across all 3? I agree with Evan, I don't see why this code shouldn't be shared, besides that, putting all that code in a header file doesn't seems like the right approach. -- Bruno Cardoso Lopes http://www.brunocardoso.cc From aaronngray.lists at googlemail.com Mon Jul 6 15:13:34 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 21:13:34 +0100 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> Message-ID: <1F76B5AD92E84E2AAF89D7725C81112E@HPLAPTOP> > Sorry, I am missing some context. Why is each of the emitter a separate > template instantiation in the first place? Why can't the code in > X86CodeEmitter.cpp be shared across all 3? If you rememer we generically parameterized X86CodeEmitter, ARMBaseCodeEmitter, AlphaCodeEmitter, and the PowerPCCodeEmitter to take different machineCodeEmitters, one for JIT, JITCodeEmitter, and one for ObjectCodeEmission. Both JITCodeEmitter and ObjectCodeEmitter inherit from MachineCodeEmitter, but JITCodeEmitter writes to a buffer where as MachineCodeEmitter writes to a vector. Basically this patch is a cleanup patch that reduces the need to linkin the JITCodeEmitter version of the actual code Emitter if you are only producing Object Modules, or coversly the Emitter if you are doing JIT, which is where you may want a small footprint on some embedded device. Having templates and templated methods into headers is quite common stuff in projects which use alot of templating. Basically everything is transparent and this allow other CodeEmitters to be created and added easily. Reid Kleckner may well want to inherit from the current JITCodeEmitter and add extra functionality for his unladden swallow Python/LLVM project. And having separate .cpp objects means we don't link in his code and he only links in what code he needs. Hope this explains things, Aaron > Evan > On Jul 6, 2009, at 10:57 AM, Aaron Gray wrote: > >> This patch separates the template instatiations for the >> createX86*CodeEmitterPass of [X86]Emiiter into separate >> .cpp file and thus different object modules in the library. This will >> result in a slightly smaller footprint for programs just using one of >> the MachineCodeEmitter, ObjectCodeEmitter, or JITCodeEmitter classes. >> >> This should save 2 * 47K each for llc, lli, and LTOCodeGenerator. >> >> Although the MachineCodeEmitter version is not being use anymore at >> present I have left it in for now. >> >> It also opens the door for altername MachineCodeEmitters for >> experimental or other purposes such as unladen Swallow. >> >> I will be submitting simular patches for Alpha, ARM, and PowerPC if this >> one gets accepted. >> >> I have made CMake the necessary CMake changes too in the patch. >> >> This patch needs to be applied relatively quickly as it moves >> X86CodeEmitter.cpp code to X86CodeEmitter.h and any chages in SVN >> inbetween would be lost. >> >> Aaron >> >> > From aaronngray.lists at googlemail.com Mon Jul 6 15:17:05 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 21:17:05 +0100 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> Message-ID: > On Mon, Jul 6, 2009 at 4:11 PM, Evan Cheng wrote: >> Sorry, I am missing some context. Why is each of the emitter a separate >> template instantiation in the first place? Why can't the code in > > This happens because ObjectCodeEmitter is a lot simpler than > JITCodeEmitter and > we don't need to deal with CurrBufferBegin, GVStub*, and so on. > >> X86CodeEmitter.cpp be shared across all 3? > > I agree with Evan, I don't see why this code shouldn't be shared, > besides that, putting > all that code in a header file doesn't seems like the right approach. > On Mon, Jul 6, 2009 at 4:11 PM, Evan Cheng wrote: >> Sorry, I am missing some context. Why is each of the emitter a separate >> template instantiation in the first place? Why can't the code in > > This happens because ObjectCodeEmitter is a lot simpler than > JITCodeEmitter and > we don't need to deal with CurrBufferBegin, GVStub*, and so on. > >> X86CodeEmitter.cpp be shared across all 3? > > I agree with Evan, I don't see why this code shouldn't be shared, > besides that, putting > all that code in a header file doesn't seems like the right approach. Its the right approach. It allows us to have separate object modules thus reducing memory overheads for other projects that at least one other person has been asking for. Putting templated code in headers and instatiating separately in .cpp files is quite common practice once you use templating alot. Aaron From bruno.cardoso at gmail.com Mon Jul 6 16:16:28 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 6 Jul 2009 18:16:28 -0300 Subject: [llvm-commits] [llvm] r74814 - in /llvm/trunk: include/llvm/CodeGen/ObjectCodeEmitter.h lib/CodeGen/ObjectCodeEmitter.cpp In-Reply-To: <7669CA9A7D814D5DBD8507485499BCD5@HPLAPTOP> References: <200907060516.n665Gekx026755@zion.cs.uiuc.edu> <7669CA9A7D814D5DBD8507485499BCD5@HPLAPTOP> Message-ID: <275e64e40907061416q7d1bfdd8g7f8d781104b0d462@mail.gmail.com> On Mon, Jul 6, 2009 at 10:55 AM, Aaron Gray wrote: > The ObjectCodeEmitter was ment to be inline code to be used by the > *CodeEmitter classes to end up with super fast code generation. Putting them > as noninline classes is a bad idea. Basically this is why I/we parameterized > the *CodeEmitter Classes in the first place. I had problems with this in the original patch, could you send a new patch with this modifications? Thanks > > Aaron > >> Author: bruno >> Date: Mon Jul ?6 00:16:40 2009 >> New Revision: 74814 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=74814&view=rev >> Log: >> Just forgot to include the two new files >> >> Added: >> ? ?llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h >> ? ?llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp >> >> Added: llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h?rev=74814&view=auto >> >> ============================================================================== >> --- llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h (added) >> +++ llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h Mon Jul ?6 >> 00:16:40 2009 >> @@ -0,0 +1,171 @@ >> +//===-- llvm/CodeGen/ObjectCodeEmitter.h - Object Code Emitter -*- >> C++ -*-===// >> +// >> +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> +//===----------------------------------------------------------------------===// >> +// >> +// ?Generalized Object Code Emitter, works with ObjectModule and >> BinaryObject. >> +// >> +//===----------------------------------------------------------------------===// >> + >> +#ifndef LLVM_CODEGEN_OBJECTCODEEMITTER_H >> +#define LLVM_CODEGEN_OBJECTCODEEMITTER_H >> + >> +#include "llvm/CodeGen/MachineCodeEmitter.h" >> + >> +namespace llvm { >> + >> +class BinaryObject; >> +class MachineBasicBlock; >> +class MachineCodeEmitter; >> +class MachineFunction; >> +class MachineConstantPool; >> +class MachineJumpTableInfo; >> +class MachineModuleInfo; >> + >> +class ObjectCodeEmitter : public MachineCodeEmitter { >> +protected: >> + >> + ?/// Binary Object (Section or Segment) we are emitting to. >> + ?BinaryObject *BO; >> + >> + ?/// MBBLocations - This vector is a mapping from MBB ID's to their >> address. >> + ?/// It is filled in by the StartMachineBasicBlock callback and queried >> by >> + ?/// the getMachineBasicBlockAddress callback. >> + ?std::vector MBBLocations; >> + >> + ?/// LabelLocations - This vector is a mapping from Label ID's to their >> + ?/// address. >> + ?std::vector LabelLocations; >> + >> + ?/// CPLocations - This is a map of constant pool indices to offsets >> from the >> + ?/// start of the section for that constant pool index. >> + ?std::vector CPLocations; >> + >> + ?/// CPSections - This is a map of constant pool indices to the Section >> + ?/// containing the constant pool entry for that index. >> + ?std::vector CPSections; >> + >> + ?/// JTLocations - This is a map of jump table indices to offsets from >> the >> + ?/// start of the section for that jump table index. >> + ?std::vector JTLocations; >> + >> +public: >> + ?ObjectCodeEmitter(); >> + ?ObjectCodeEmitter(BinaryObject *bo); >> + ?virtual ~ObjectCodeEmitter(); >> + >> + ?/// setBinaryObject - set the BinaryObject we are writting to >> + ?void setBinaryObject(BinaryObject *bo); >> + >> + ?/// emitByte - This callback is invoked when a byte needs to be >> + ?/// written to the data stream, without buffer overflow testing. >> + ?void emitByte(uint8_t B); >> + >> + ?/// emitWordLE - This callback is invoked when a 32-bit word needs to >> be >> + ?/// written to the data stream in little-endian format. >> + ?void emitWordLE(uint32_t W); >> + >> + ?/// emitWordBE - This callback is invoked when a 32-bit word needs to >> be >> + ?/// written to the data stream in big-endian format. >> + ?void emitWordBE(uint32_t W); >> + >> + ?/// emitDWordLE - This callback is invoked when a 64-bit word needs to >> be >> + ?/// written to the data stream in little-endian format. >> + ?void emitDWordLE(uint64_t W); >> + >> + ?/// emitDWordBE - This callback is invoked when a 64-bit word needs to >> be >> + ?/// written to the data stream in big-endian format. >> + ?void emitDWordBE(uint64_t W); >> + >> + ?/// emitAlignment - Move the CurBufferPtr pointer up the the specified >> + ?/// alignment (saturated to BufferEnd of course). >> + ?void emitAlignment(unsigned Alignment = 0, uint8_t fill = 0); >> + >> + ?/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to >> be >> + ?/// written to the data stream. >> + ?void emitULEB128Bytes(uint64_t Value); >> + >> + ?/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to >> be >> + ?/// written to the data stream. >> + ?void emitSLEB128Bytes(uint64_t Value); >> + >> + ?/// emitString - This callback is invoked when a String needs to be >> + ?/// written to the data stream. >> + ?void emitString(const std::string &String); >> + >> + ?/// getCurrentPCValue - This returns the address that the next emitted >> byte >> + ?/// will be output to. >> + ?uintptr_t getCurrentPCValue() const; >> + >> + ?/// getCurrentPCOffset - Return the offset from the start of the >> emitted >> + ?/// buffer that we are currently writing to. >> + ?uintptr_t getCurrentPCOffset() const; >> + >> + ?/// addRelocation - Whenever a relocatable address is needed, it should >> be >> + ?/// noted with this interface. >> + ?void addRelocation(const MachineRelocation& relocation); >> + >> + ?/// startFunction - This callback is invoked when the specified >> function is >> + ?/// about to be code generated. ?This initializes the >> BufferBegin/End/Ptr >> + ?/// fields. >> + ?virtual void startFunction(MachineFunction &F) = 0; >> + >> + ?/// finishFunction - This callback is invoked when the specified >> function has >> + ?/// finished code generation. ?If a buffer overflow has occurred, this >> method >> + ?/// returns true (the callee is required to try again), otherwise it >> returns >> + ?/// false. >> + ?virtual bool finishFunction(MachineFunction &F) = 0; >> + >> + ?/// StartMachineBasicBlock - This should be called by the target when a >> new >> + ?/// basic block is about to be emitted. ?This way the MCE knows where >> the >> + ?/// start of the block is, and can implement >> getMachineBasicBlockAddress. >> + ?virtual void StartMachineBasicBlock(MachineBasicBlock *MBB); >> + >> + ?/// getMachineBasicBlockAddress - Return the address of the specified >> + ?/// MachineBasicBlock, only usable after the label for the MBB has been >> + ?/// emitted. >> + ?virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) >> const; >> + >> + ?/// emitLabel - Emits a label >> + ?virtual void emitLabel(uint64_t LabelID) = 0; >> + >> + ?/// getLabelAddress - Return the address of the specified LabelID, only >> usable >> + ?/// after the LabelID has been emitted. >> + ?virtual uintptr_t getLabelAddress(uint64_t LabelID) const = 0; >> + >> + ?/// emitJumpTables - Emit all the jump tables for a given jump table >> info >> + ?/// record to the appropriate section. >> + ?virtual void emitJumpTables(MachineJumpTableInfo *MJTI) = 0; >> + >> + ?/// getJumpTableEntryAddress - Return the address of the jump table >> with index >> + ?/// 'Index' in the function that last called initJumpTableInfo. >> + ?virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const; >> + >> + ?/// emitConstantPool - For each constant pool entry, figure out which >> section >> + ?/// the constant should live in, allocate space for it, and emit it to >> the >> + ?/// Section data buffer. >> + ?virtual void emitConstantPool(MachineConstantPool *MCP) = 0; >> + >> + ?/// getConstantPoolEntryAddress - Return the address of the 'Index' >> entry in >> + ?/// the constant pool that was last emitted with the emitConstantPool >> method. >> + ?virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const; >> + >> + ?/// getConstantPoolEntrySection - Return the section of the 'Index' >> entry in >> + ?/// the constant pool that was last emitted with the emitConstantPool >> method. >> + ?virtual uintptr_t getConstantPoolEntrySection(unsigned Index) const; >> + >> + ?/// Specifies the MachineModuleInfo object. This is used for exception >> handling >> + ?/// purposes. >> + ?virtual void setModuleInfo(MachineModuleInfo* Info) = 0; >> + ?// to be implemented or depreciated with MachineModuleInfo >> + >> +}; // end class ObjectCodeEmitter >> + >> +} // end namespace llvm >> + >> +#endif >> + >> >> Added: llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp?rev=74814&view=auto >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp (added) >> +++ llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp Mon Jul ?6 00:16:40 2009 >> @@ -0,0 +1,142 @@ >> +//===-- llvm/CodeGen/ObjectCodeEmitter.cpp -------------------- -*- >> C++ -*-===// >> +// >> +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> +//===----------------------------------------------------------------------===// >> + >> +#include "llvm/CodeGen/BinaryObject.h" >> +#include "llvm/CodeGen/MachineBasicBlock.h" >> +#include "llvm/CodeGen/MachineRelocation.h" >> +#include "llvm/CodeGen/ObjectCodeEmitter.h" >> + >> +//===----------------------------------------------------------------------===// >> +// ? ? ? ? ? ? ? ? ? ? ? ObjectCodeEmitter Implementation >> +//===----------------------------------------------------------------------===// >> + >> +namespace llvm { >> + >> +ObjectCodeEmitter::ObjectCodeEmitter() : BO(0) {} >> +ObjectCodeEmitter::ObjectCodeEmitter(BinaryObject *bo) : BO(bo) {} >> +ObjectCodeEmitter::~ObjectCodeEmitter() {} >> + >> +/// setBinaryObject - set the BinaryObject we are writting to >> +void ObjectCodeEmitter::setBinaryObject(BinaryObject *bo) { BO = bo; } >> + >> +/// emitByte - This callback is invoked when a byte needs to be >> +/// written to the data stream, without buffer overflow testing. >> +void ObjectCodeEmitter::emitByte(uint8_t B) { >> + ?BO->emitByte(B); >> +} >> + >> +/// emitWordLE - This callback is invoked when a 32-bit word needs to be >> +/// written to the data stream in little-endian format. >> +void ObjectCodeEmitter::emitWordLE(uint32_t W) { >> + ?BO->emitWordLE(W); >> +} >> + >> +/// emitWordBE - This callback is invoked when a 32-bit word needs to be >> +/// written to the data stream in big-endian format. >> +void ObjectCodeEmitter::emitWordBE(uint32_t W) { >> + ?BO->emitWordBE(W); >> +} >> + >> +/// emitDWordLE - This callback is invoked when a 64-bit word needs to be >> +/// written to the data stream in little-endian format. >> +void ObjectCodeEmitter::emitDWordLE(uint64_t W) { >> + ?BO->emitDWordLE(W); >> +} >> + >> +/// emitDWordBE - This callback is invoked when a 64-bit word needs to be >> +/// written to the data stream in big-endian format. >> +void ObjectCodeEmitter::emitDWordBE(uint64_t W) { >> + ?BO->emitDWordBE(W); >> +} >> + >> +/// emitAlignment - Move the CurBufferPtr pointer up the the specified >> +/// alignment (saturated to BufferEnd of course). >> +void ObjectCodeEmitter::emitAlignment(unsigned Alignment /* 0 */, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?uint8_t fill /* 0 */) { >> + ?BO->emitAlignment(Alignment, fill); >> +} >> + >> +/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to >> be >> +/// written to the data stream. >> +void ObjectCodeEmitter::emitULEB128Bytes(uint64_t Value) { >> + ?BO->emitULEB128Bytes(Value); >> +} >> + >> +/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to >> be >> +/// written to the data stream. >> +void ObjectCodeEmitter::emitSLEB128Bytes(uint64_t Value) { >> + ?BO->emitSLEB128Bytes(Value); >> +} >> + >> +/// emitString - This callback is invoked when a String needs to be >> +/// written to the data stream. >> +void ObjectCodeEmitter::emitString(const std::string &String) { >> + ?BO->emitString(String); >> +} >> + >> +/// getCurrentPCValue - This returns the address that the next emitted >> byte >> +/// will be output to. >> +uintptr_t ObjectCodeEmitter::getCurrentPCValue() const { >> + ?return BO->getCurrentPCOffset(); >> +} >> + >> +/// getCurrentPCOffset - Return the offset from the start of the emitted >> +/// buffer that we are currently writing to. >> +uintptr_t ObjectCodeEmitter::getCurrentPCOffset() const { >> + ?return BO->getCurrentPCOffset(); >> +} >> + >> +/// addRelocation - Whenever a relocatable address is needed, it should >> be >> +/// noted with this interface. >> +void ObjectCodeEmitter::addRelocation(const MachineRelocation& >> relocation) { >> + ?BO->addRelocation(relocation); >> +} >> + >> +/// StartMachineBasicBlock - This should be called by the target when a >> new >> +/// basic block is about to be emitted. ?This way the MCE knows where the >> +/// start of the block is, and can implement getMachineBasicBlockAddress. >> +void ObjectCodeEmitter::StartMachineBasicBlock(MachineBasicBlock *MBB) { >> + ?if (MBBLocations.size() <= (unsigned)MBB->getNumber()) >> + ? ?MBBLocations.resize((MBB->getNumber()+1)*2); >> + ?MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); >> +} >> + >> +/// getMachineBasicBlockAddress - Return the address of the specified >> +/// MachineBasicBlock, only usable after the label for the MBB has been >> +/// emitted. >> +uintptr_t >> +ObjectCodeEmitter::getMachineBasicBlockAddress(MachineBasicBlock *MBB) >> const { >> + ?assert(MBBLocations.size() > (unsigned)MBB->getNumber() && >> + ? ? ? ? MBBLocations[MBB->getNumber()] && "MBB not emitted!"); >> + ?return MBBLocations[MBB->getNumber()]; >> +} >> + >> +/// getJumpTableEntryAddress - Return the address of the jump table with >> index >> +/// 'Index' in the function that last called initJumpTableInfo. >> +uintptr_t ObjectCodeEmitter::getJumpTableEntryAddress(unsigned Index) >> const { >> + ?assert(JTLocations.size() > Index && "JT not emitted!"); >> + ?return JTLocations[Index]; >> +} >> + >> +/// getConstantPoolEntryAddress - Return the address of the 'Index' entry >> in >> +/// the constant pool that was last emitted with the emitConstantPool >> method. >> +uintptr_t ObjectCodeEmitter::getConstantPoolEntryAddress(unsigned Index) >> const { >> + ?assert(CPLocations.size() > Index && "CP not emitted!"); >> + ?return CPLocations[Index]; >> +} >> + >> +/// getConstantPoolEntrySection - Return the section of the 'Index' entry >> in >> +/// the constant pool that was last emitted with the emitConstantPool >> method. >> +uintptr_t ObjectCodeEmitter::getConstantPoolEntrySection(unsigned Index) >> const { >> + ?assert(CPSections.size() > Index && "CP not emitted!"); >> + ?return CPSections[Index]; >> +} >> + >> +} // end namespace llvm >> + >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- Bruno Cardoso Lopes http://www.brunocardoso.cc From xerxes at zafena.se Mon Jul 6 16:18:47 2009 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Mon, 06 Jul 2009 23:18:47 +0200 Subject: [llvm-commits] [llvm] r74835 *AND* r74846 - /llvm/trunk/lib/System/Threading.cpp In-Reply-To: <200907061725.n66HP8CM029643@zion.cs.uiuc.edu> References: <200907061725.n66HP8CM029643@zion.cs.uiuc.edu> Message-ID: <4A526A37.8090901@zafena.se> Thank you Chris and Owen for both applying my patch... the funny thing are that Chris have applied a "new variant" of the patch that added the config.h at the bottom while Owen applied the patch as is and thus added the config.h at the top. Basically now we have one config.h extra in Threading.cpp Chris would you mind if we back out your reverse-alphabetic version with the removed newline out? Cheers Xerxes Den 2009-07-06 19:25, Chris Lattner skrev: > Author: lattner > Date: Mon Jul 6 12:24:48 2009 > New Revision: 74835 > > URL: http://llvm.org/viewvc/llvm-project?rev=74835&view=rev > Log: > improve portability to windows, patch by Xerces Ranby! > > Modified: > llvm/trunk/lib/System/Threading.cpp > > Modified: llvm/trunk/lib/System/Threading.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Threading.cpp?rev=74835&r1=74834&r2=74835&view=diff > > ============================================================================== > --- llvm/trunk/lib/System/Threading.cpp (original) > +++ llvm/trunk/lib/System/Threading.cpp Mon Jul 6 12:24:48 2009 > @@ -14,8 +14,8 @@ > #include "llvm/System/Threading.h" > #include "llvm/System/Atomic.h" > #include "llvm/System/Mutex.h" > +#include "llvm/Config/config.h" > #include > - > using namespace llvm; > > static bool multithreaded_mode = false; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > Den 2009-07-06 20:50, Owen Anderson skrev: > Author: resistor > Date: Mon Jul 6 13:50:47 2009 > New Revision: 74846 > > URL: http://llvm.org/viewvc/llvm-project?rev=74846&view=rev > Log: > We need to include config.h to get the proper setting to LLVM_MULTITHREADED. > > Patch by Xerxes Ranby. > > Modified: > llvm/trunk/lib/System/Threading.cpp > > Modified: llvm/trunk/lib/System/Threading.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Threading.cpp?rev=74846&r1=74845&r2=74846&view=diff > > ============================================================================== > --- llvm/trunk/lib/System/Threading.cpp (original) > +++ llvm/trunk/lib/System/Threading.cpp Mon Jul 6 13:50:47 2009 > @@ -11,6 +11,7 @@ > // > //===----------------------------------------------------------------------===// > > +#include "llvm/Config/config.h" > #include "llvm/System/Threading.h" > #include "llvm/System/Atomic.h" > #include "llvm/System/Mutex.h" > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From resistor at mac.com Mon Jul 6 16:24:39 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 06 Jul 2009 21:24:39 -0000 Subject: [llvm-commits] [llvm] r74854 - /llvm/trunk/lib/System/Threading.cpp Message-ID: <200907062124.n66LOdmc004752@zion.cs.uiuc.edu> Author: resistor Date: Mon Jul 6 16:24:37 2009 New Revision: 74854 URL: http://llvm.org/viewvc/llvm-project?rev=74854&view=rev Log: No need to double-include config.h Modified: llvm/trunk/lib/System/Threading.cpp Modified: llvm/trunk/lib/System/Threading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Threading.cpp?rev=74854&r1=74853&r2=74854&view=diff ============================================================================== --- llvm/trunk/lib/System/Threading.cpp (original) +++ llvm/trunk/lib/System/Threading.cpp Mon Jul 6 16:24:37 2009 @@ -11,12 +11,12 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Config/config.h" #include "llvm/System/Threading.h" #include "llvm/System/Atomic.h" #include "llvm/System/Mutex.h" #include "llvm/Config/config.h" #include + using namespace llvm; static bool multithreaded_mode = false; From isanbard at gmail.com Mon Jul 6 16:33:09 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 06 Jul 2009 21:33:09 -0000 Subject: [llvm-commits] [llvm] r74855 - /llvm/tags/Apple/llvmCore-2116/ Message-ID: <200907062133.n66LX9O0005014@zion.cs.uiuc.edu> Author: void Date: Mon Jul 6 16:33:09 2009 New Revision: 74855 URL: http://llvm.org/viewvc/llvm-project?rev=74855&view=rev Log: Creating llvmCore-2116 branch Added: llvm/tags/Apple/llvmCore-2116/ - copied from r74854, llvm/trunk/ From isanbard at gmail.com Mon Jul 6 16:33:17 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 06 Jul 2009 21:33:17 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r74856 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2116/ Message-ID: <200907062133.n66LXH0L005033@zion.cs.uiuc.edu> Author: void Date: Mon Jul 6 16:33:17 2009 New Revision: 74856 URL: http://llvm.org/viewvc/llvm-project?rev=74856&view=rev Log: Creating llvmgcc42-2116 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2116/ - copied from r74855, llvm-gcc-4.2/trunk/ From evan.cheng at apple.com Mon Jul 6 16:34:05 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 06 Jul 2009 21:34:05 -0000 Subject: [llvm-commits] [llvm] r74857 - in /llvm/trunk: lib/CodeGen/LiveVariables.cpp test/CodeGen/X86/2009-07-06-TwoAddrAssert.ll Message-ID: <200907062134.n66LY5e8005067@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jul 6 16:34:05 2009 New Revision: 74857 URL: http://llvm.org/viewvc/llvm-project?rev=74857&view=rev Log: Avoid adding a duplicate def. This fixes PR4478. Added: llvm/trunk/test/CodeGen/X86/2009-07-06-TwoAddrAssert.ll Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=74857&r1=74856&r2=74857&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Mon Jul 6 16:34:05 2009 @@ -369,8 +369,17 @@ for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); unsigned SubReg = *SubRegs; ++SubRegs) { if (PartUses.count(SubReg)) { - PhysRegDef[Reg]->addOperand(MachineOperand::CreateReg(SubReg, - true, true)); + bool NeedDef = true; + if (PhysRegDef[Reg] == PhysRegDef[SubReg]) { + MachineOperand *MO = PhysRegDef[Reg]->findRegisterDefOperand(SubReg); + if (MO) { + NeedDef = false; + assert(!MO->isDead()); + } + } + if (NeedDef) + PhysRegDef[Reg]->addOperand(MachineOperand::CreateReg(SubReg, + true, true)); LastRefOrPartRef->addRegisterKilled(SubReg, TRI, true); for (const unsigned *SS = TRI->getSubRegisters(SubReg); *SS; ++SS) PartUses.erase(*SS); Added: llvm/trunk/test/CodeGen/X86/2009-07-06-TwoAddrAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-07-06-TwoAddrAssert.ll?rev=74857&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-07-06-TwoAddrAssert.ll (added) +++ llvm/trunk/test/CodeGen/X86/2009-07-06-TwoAddrAssert.ll Mon Jul 6 16:34:05 2009 @@ -0,0 +1,137 @@ +; RUN: llvm-as < %s | llc -march=x86 -mtriple=x86_64-unknown-freebsd7.2 +; PR4478 + + %struct.sockaddr = type <{ i8, i8, [14 x i8] }> + +define i32 @main(i32 %argc, i8** %argv) nounwind { +entry: + br label %while.cond + +while.cond: ; preds = %sw.bb6, %entry + switch i32 undef, label %sw.default [ + i32 -1, label %while.end + i32 119, label %sw.bb6 + ] + +sw.bb6: ; preds = %while.cond + br i1 undef, label %if.then, label %while.cond + +if.then: ; preds = %sw.bb6 + ret i32 1 + +sw.default: ; preds = %while.cond + ret i32 1 + +while.end: ; preds = %while.cond + br i1 undef, label %if.then15, label %if.end16 + +if.then15: ; preds = %while.end + ret i32 1 + +if.end16: ; preds = %while.end + br i1 undef, label %lor.lhs.false, label %if.then21 + +lor.lhs.false: ; preds = %if.end16 + br i1 undef, label %if.end22, label %if.then21 + +if.then21: ; preds = %lor.lhs.false, %if.end16 + ret i32 1 + +if.end22: ; preds = %lor.lhs.false + br i1 undef, label %lor.lhs.false27, label %if.then51 + +lor.lhs.false27: ; preds = %if.end22 + br i1 undef, label %lor.lhs.false39, label %if.then51 + +lor.lhs.false39: ; preds = %lor.lhs.false27 + br i1 undef, label %if.end52, label %if.then51 + +if.then51: ; preds = %lor.lhs.false39, %lor.lhs.false27, %if.end22 + ret i32 1 + +if.end52: ; preds = %lor.lhs.false39 + br i1 undef, label %if.then57, label %if.end58 + +if.then57: ; preds = %if.end52 + ret i32 1 + +if.end58: ; preds = %if.end52 + br i1 undef, label %if.then64, label %if.end65 + +if.then64: ; preds = %if.end58 + ret i32 1 + +if.end65: ; preds = %if.end58 + br i1 undef, label %if.then71, label %if.end72 + +if.then71: ; preds = %if.end65 + ret i32 1 + +if.end72: ; preds = %if.end65 + br i1 undef, label %if.then83, label %if.end84 + +if.then83: ; preds = %if.end72 + ret i32 1 + +if.end84: ; preds = %if.end72 + br i1 undef, label %if.then101, label %if.end102 + +if.then101: ; preds = %if.end84 + ret i32 1 + +if.end102: ; preds = %if.end84 + br i1 undef, label %if.then113, label %if.end114 + +if.then113: ; preds = %if.end102 + ret i32 1 + +if.end114: ; preds = %if.end102 + br i1 undef, label %if.then209, label %if.end210 + +if.then209: ; preds = %if.end114 + ret i32 1 + +if.end210: ; preds = %if.end114 + br i1 undef, label %if.then219, label %if.end220 + +if.then219: ; preds = %if.end210 + ret i32 1 + +if.end220: ; preds = %if.end210 + br i1 undef, label %if.end243, label %lor.lhs.false230 + +lor.lhs.false230: ; preds = %if.end220 + unreachable + +if.end243: ; preds = %if.end220 + br i1 undef, label %if.then249, label %if.end250 + +if.then249: ; preds = %if.end243 + ret i32 1 + +if.end250: ; preds = %if.end243 + br i1 undef, label %if.end261, label %if.then260 + +if.then260: ; preds = %if.end250 + ret i32 1 + +if.end261: ; preds = %if.end250 + br i1 undef, label %if.then270, label %if.end271 + +if.then270: ; preds = %if.end261 + ret i32 1 + +if.end271: ; preds = %if.end261 + %call.i = call i32 @arc4random() nounwind ; [#uses=1] + %rem.i = urem i32 %call.i, 16383 ; [#uses=1] + %rem1.i = trunc i32 %rem.i to i16 ; [#uses=1] + %conv2.i = or i16 %rem1.i, -16384 ; [#uses=1] + %0 = call i16 asm "xchgb ${0:h}, ${0:b}", "=Q,0,~{dirflag},~{fpsr},~{flags}"(i16 %conv2.i) nounwind ; [#uses=1] + store i16 %0, i16* undef + %call281 = call i32 @bind(i32 undef, %struct.sockaddr* undef, i32 16) nounwind ; [#uses=0] + unreachable +} + +declare i32 @bind(i32, %struct.sockaddr*, i32) + +declare i32 @arc4random() From evan.cheng at apple.com Mon Jul 6 16:47:45 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 6 Jul 2009 14:47:45 -0700 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction In-Reply-To: <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> Message-ID: We need to revisit the approach. Templatizing the CodeEmitter class is probably not the right way to go Sorry I didn't think hard about this when the patch landed back the end of May. Chris' recent "machine code" work is obsoleting at least object code emitter so I'll let him comment. Evan On Jul 6, 2009, at 12:53 PM, Bruno Cardoso Lopes wrote: > On Mon, Jul 6, 2009 at 4:11 PM, Evan Cheng > wrote: >> Sorry, I am missing some context. Why is each of the emitter a >> separate >> template instantiation in the first place? Why can't the code in > > This happens because ObjectCodeEmitter is a lot simpler than > JITCodeEmitter and > we don't need to deal with CurrBufferBegin, GVStub*, and so on. > >> X86CodeEmitter.cpp be shared across all 3? > > I agree with Evan, I don't see why this code shouldn't be shared, > besides that, putting > all that code in a header file doesn't seems like the right approach. > > -- > Bruno Cardoso Lopes > http://www.brunocardoso.cc From aaronngray.lists at googlemail.com Mon Jul 6 16:49:02 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 22:49:02 +0100 Subject: [llvm-commits] [llvm] r74814 - in /llvm/trunk: include/llvm/CodeGen/ObjectCodeEmitter.h lib/CodeGen/ObjectCodeEmitter.cpp In-Reply-To: <275e64e40907061416q7d1bfdd8g7f8d781104b0d462@mail.gmail.com> References: <200907060516.n665Gekx026755@zion.cs.uiuc.edu> <7669CA9A7D814D5DBD8507485499BCD5@HPLAPTOP> <275e64e40907061416q7d1bfdd8g7f8d781104b0d462@mail.gmail.com> Message-ID: <9719867c0907061449s146605cct18f07d4df91ec2e0@mail.gmail.com> 2009/7/6 Bruno Cardoso Lopes > On Mon, Jul 6, 2009 at 10:55 AM, Aaron > Gray wrote: > > The ObjectCodeEmitter was ment to be inline code to be used by the > > *CodeEmitter classes to end up with super fast code generation. Putting > them > > as noninline classes is a bad idea. Basically this is why I/we > parameterized > > the *CodeEmitter Classes in the first place. > > I had problems with this in the original patch, could you send a new > patch with this modifications? > Here we go. I only did the emit* methods. Aaron > Aaron > >> Author: bruno >> Date: Mon Jul 6 00:16:40 2009 >> New Revision: 74814 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=74814&view=rev >> Log: >> Just forgot to include the two new files >> >> Added: >> llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h >> llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp >> >> Added: llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h?rev=74814&view=auto >> >> ============================================================================== >> --- llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h (added) >> +++ llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h Mon Jul 6 >> 00:16:40 2009 >> @@ -0,0 +1,171 @@ >> +//===-- llvm/CodeGen/ObjectCodeEmitter.h - Object Code Emitter -*- >> C++ -*-===// >> +// >> +// The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> +//===----------------------------------------------------------------------===// >> +// >> +// Generalized Object Code Emitter, works with ObjectModule and >> BinaryObject. >> +// >> +//===----------------------------------------------------------------------===// >> + >> +#ifndef LLVM_CODEGEN_OBJECTCODEEMITTER_H >> +#define LLVM_CODEGEN_OBJECTCODEEMITTER_H >> + >> +#include "llvm/CodeGen/MachineCodeEmitter.h" >> + >> +namespace llvm { >> + >> +class BinaryObject; >> +class MachineBasicBlock; >> +class MachineCodeEmitter; >> +class MachineFunction; >> +class MachineConstantPool; >> +class MachineJumpTableInfo; >> +class MachineModuleInfo; >> + >> +class ObjectCodeEmitter : public MachineCodeEmitter { >> +protected: >> + >> + /// Binary Object (Section or Segment) we are emitting to. >> + BinaryObject *BO; >> + >> + /// MBBLocations - This vector is a mapping from MBB ID's to their >> address. >> + /// It is filled in by the StartMachineBasicBlock callback and queried >> by >> + /// the getMachineBasicBlockAddress callback. >> + std::vector MBBLocations; >> + >> + /// LabelLocations - This vector is a mapping from Label ID's to their >> + /// address. >> + std::vector LabelLocations; >> + >> + /// CPLocations - This is a map of constant pool indices to offsets >> from the >> + /// start of the section for that constant pool index. >> + std::vector CPLocations; >> + >> + /// CPSections - This is a map of constant pool indices to the Section >> + /// containing the constant pool entry for that index. >> + std::vector CPSections; >> + >> + /// JTLocations - This is a map of jump table indices to offsets from >> the >> + /// start of the section for that jump table index. >> + std::vector JTLocations; >> + >> +public: >> + ObjectCodeEmitter(); >> + ObjectCodeEmitter(BinaryObject *bo); >> + virtual ~ObjectCodeEmitter(); >> + >> + /// setBinaryObject - set the BinaryObject we are writting to >> + void setBinaryObject(BinaryObject *bo); >> + >> + /// emitByte - This callback is invoked when a byte needs to be >> + /// written to the data stream, without buffer overflow testing. >> + void emitByte(uint8_t B); >> + >> + /// emitWordLE - This callback is invoked when a 32-bit word needs to >> be >> + /// written to the data stream in little-endian format. >> + void emitWordLE(uint32_t W); >> + >> + /// emitWordBE - This callback is invoked when a 32-bit word needs to >> be >> + /// written to the data stream in big-endian format. >> + void emitWordBE(uint32_t W); >> + >> + /// emitDWordLE - This callback is invoked when a 64-bit word needs to >> be >> + /// written to the data stream in little-endian format. >> + void emitDWordLE(uint64_t W); >> + >> + /// emitDWordBE - This callback is invoked when a 64-bit word needs to >> be >> + /// written to the data stream in big-endian format. >> + void emitDWordBE(uint64_t W); >> + >> + /// emitAlignment - Move the CurBufferPtr pointer up the the specified >> + /// alignment (saturated to BufferEnd of course). >> + void emitAlignment(unsigned Alignment = 0, uint8_t fill = 0); >> + >> + /// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to >> be >> + /// written to the data stream. >> + void emitULEB128Bytes(uint64_t Value); >> + >> + /// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to >> be >> + /// written to the data stream. >> + void emitSLEB128Bytes(uint64_t Value); >> + >> + /// emitString - This callback is invoked when a String needs to be >> + /// written to the data stream. >> + void emitString(const std::string &String); >> + >> + /// getCurrentPCValue - This returns the address that the next emitted >> byte >> + /// will be output to. >> + uintptr_t getCurrentPCValue() const; >> + >> + /// getCurrentPCOffset - Return the offset from the start of the >> emitted >> + /// buffer that we are currently writing to. >> + uintptr_t getCurrentPCOffset() const; >> + >> + /// addRelocation - Whenever a relocatable address is needed, it should >> be >> + /// noted with this interface. >> + void addRelocation(const MachineRelocation& relocation); >> + >> + /// startFunction - This callback is invoked when the specified >> function is >> + /// about to be code generated. This initializes the >> BufferBegin/End/Ptr >> + /// fields. >> + virtual void startFunction(MachineFunction &F) = 0; >> + >> + /// finishFunction - This callback is invoked when the specified >> function has >> + /// finished code generation. If a buffer overflow has occurred, this >> method >> + /// returns true (the callee is required to try again), otherwise it >> returns >> + /// false. >> + virtual bool finishFunction(MachineFunction &F) = 0; >> + >> + /// StartMachineBasicBlock - This should be called by the target when a >> new >> + /// basic block is about to be emitted. This way the MCE knows where >> the >> + /// start of the block is, and can implement >> getMachineBasicBlockAddress. >> + virtual void StartMachineBasicBlock(MachineBasicBlock *MBB); >> + >> + /// getMachineBasicBlockAddress - Return the address of the specified >> + /// MachineBasicBlock, only usable after the label for the MBB has been >> + /// emitted. >> + virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) >> const; >> + >> + /// emitLabel - Emits a label >> + virtual void emitLabel(uint64_t LabelID) = 0; >> + >> + /// getLabelAddress - Return the address of the specified LabelID, only >> usable >> + /// after the LabelID has been emitted. >> + virtual uintptr_t getLabelAddress(uint64_t LabelID) const = 0; >> + >> + /// emitJumpTables - Emit all the jump tables for a given jump table >> info >> + /// record to the appropriate section. >> + virtual void emitJumpTables(MachineJumpTableInfo *MJTI) = 0; >> + >> + /// getJumpTableEntryAddress - Return the address of the jump table >> with index >> + /// 'Index' in the function that last called initJumpTableInfo. >> + virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const; >> + >> + /// emitConstantPool - For each constant pool entry, figure out which >> section >> + /// the constant should live in, allocate space for it, and emit it to >> the >> + /// Section data buffer. >> + virtual void emitConstantPool(MachineConstantPool *MCP) = 0; >> + >> + /// getConstantPoolEntryAddress - Return the address of the 'Index' >> entry in >> + /// the constant pool that was last emitted with the emitConstantPool >> method. >> + virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const; >> + >> + /// getConstantPoolEntrySection - Return the section of the 'Index' >> entry in >> + /// the constant pool that was last emitted with the emitConstantPool >> method. >> + virtual uintptr_t getConstantPoolEntrySection(unsigned Index) const; >> + >> + /// Specifies the MachineModuleInfo object. This is used for exception >> handling >> + /// purposes. >> + virtual void setModuleInfo(MachineModuleInfo* Info) = 0; >> + // to be implemented or depreciated with MachineModuleInfo >> + >> +}; // end class ObjectCodeEmitter >> + >> +} // end namespace llvm >> + >> +#endif >> + >> >> Added: llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp?rev=74814&view=auto >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp (added) >> +++ llvm/trunk/lib/CodeGen/ObjectCodeEmitter.cpp Mon Jul 6 00:16:40 2009 >> @@ -0,0 +1,142 @@ >> +//===-- llvm/CodeGen/ObjectCodeEmitter.cpp -------------------- -*- >> C++ -*-===// >> +// >> +// The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> +//===----------------------------------------------------------------------===// >> + >> +#include "llvm/CodeGen/BinaryObject.h" >> +#include "llvm/CodeGen/MachineBasicBlock.h" >> +#include "llvm/CodeGen/MachineRelocation.h" >> +#include "llvm/CodeGen/ObjectCodeEmitter.h" >> + >> +//===----------------------------------------------------------------------===// >> +// ObjectCodeEmitter Implementation >> +//===----------------------------------------------------------------------===// >> + >> +namespace llvm { >> + >> +ObjectCodeEmitter::ObjectCodeEmitter() : BO(0) {} >> +ObjectCodeEmitter::ObjectCodeEmitter(BinaryObject *bo) : BO(bo) {} >> +ObjectCodeEmitter::~ObjectCodeEmitter() {} >> + >> +/// setBinaryObject - set the BinaryObject we are writting to >> +void ObjectCodeEmitter::setBinaryObject(BinaryObject *bo) { BO = bo; } >> + >> +/// emitByte - This callback is invoked when a byte needs to be >> +/// written to the data stream, without buffer overflow testing. >> +void ObjectCodeEmitter::emitByte(uint8_t B) { >> + BO->emitByte(B); >> +} >> + >> +/// emitWordLE - This callback is invoked when a 32-bit word needs to be >> +/// written to the data stream in little-endian format. >> +void ObjectCodeEmitter::emitWordLE(uint32_t W) { >> + BO->emitWordLE(W); >> +} >> + >> +/// emitWordBE - This callback is invoked when a 32-bit word needs to be >> +/// written to the data stream in big-endian format. >> +void ObjectCodeEmitter::emitWordBE(uint32_t W) { >> + BO->emitWordBE(W); >> +} >> + >> +/// emitDWordLE - This callback is invoked when a 64-bit word needs to be >> +/// written to the data stream in little-endian format. >> +void ObjectCodeEmitter::emitDWordLE(uint64_t W) { >> + BO->emitDWordLE(W); >> +} >> + >> +/// emitDWordBE - This callback is invoked when a 64-bit word needs to be >> +/// written to the data stream in big-endian format. >> +void ObjectCodeEmitter::emitDWordBE(uint64_t W) { >> + BO->emitDWordBE(W); >> +} >> + >> +/// emitAlignment - Move the CurBufferPtr pointer up the the specified >> +/// alignment (saturated to BufferEnd of course). >> +void ObjectCodeEmitter::emitAlignment(unsigned Alignment /* 0 */, >> + uint8_t fill /* 0 */) { >> + BO->emitAlignment(Alignment, fill); >> +} >> + >> +/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to >> be >> +/// written to the data stream. >> +void ObjectCodeEmitter::emitULEB128Bytes(uint64_t Value) { >> + BO->emitULEB128Bytes(Value); >> +} >> + >> +/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to >> be >> +/// written to the data stream. >> +void ObjectCodeEmitter::emitSLEB128Bytes(uint64_t Value) { >> + BO->emitSLEB128Bytes(Value); >> +} >> + >> +/// emitString - This callback is invoked when a String needs to be >> +/// written to the data stream. >> +void ObjectCodeEmitter::emitString(const std::string &String) { >> + BO->emitString(String); >> +} >> + >> +/// getCurrentPCValue - This returns the address that the next emitted >> byte >> +/// will be output to. >> +uintptr_t ObjectCodeEmitter::getCurrentPCValue() const { >> + return BO->getCurrentPCOffset(); >> +} >> + >> +/// getCurrentPCOffset - Return the offset from the start of the emitted >> +/// buffer that we are currently writing to. >> +uintptr_t ObjectCodeEmitter::getCurrentPCOffset() const { >> + return BO->getCurrentPCOffset(); >> +} >> + >> +/// addRelocation - Whenever a relocatable address is needed, it should >> be >> +/// noted with this interface. >> +void ObjectCodeEmitter::addRelocation(const MachineRelocation& >> relocation) { >> + BO->addRelocation(relocation); >> +} >> + >> +/// StartMachineBasicBlock - This should be called by the target when a >> new >> +/// basic block is about to be emitted. This way the MCE knows where the >> +/// start of the block is, and can implement getMachineBasicBlockAddress. >> +void ObjectCodeEmitter::StartMachineBasicBlock(MachineBasicBlock *MBB) { >> + if (MBBLocations.size() <= (unsigned)MBB->getNumber()) >> + MBBLocations.resize((MBB->getNumber()+1)*2); >> + MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); >> +} >> + >> +/// getMachineBasicBlockAddress - Return the address of the specified >> +/// MachineBasicBlock, only usable after the label for the MBB has been >> +/// emitted. >> +uintptr_t >> +ObjectCodeEmitter::getMachineBasicBlockAddress(MachineBasicBlock *MBB) >> const { >> + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && >> + MBBLocations[MBB->getNumber()] && "MBB not emitted!"); >> + return MBBLocations[MBB->getNumber()]; >> +} >> + >> +/// getJumpTableEntryAddress - Return the address of the jump table with >> index >> +/// 'Index' in the function that last called initJumpTableInfo. >> +uintptr_t ObjectCodeEmitter::getJumpTableEntryAddress(unsigned Index) >> const { >> + assert(JTLocations.size() > Index && "JT not emitted!"); >> + return JTLocations[Index]; >> +} >> + >> +/// getConstantPoolEntryAddress - Return the address of the 'Index' entry >> in >> +/// the constant pool that was last emitted with the emitConstantPool >> method. >> +uintptr_t ObjectCodeEmitter::getConstantPoolEntryAddress(unsigned Index) >> const { >> + assert(CPLocations.size() > Index && "CP not emitted!"); >> + return CPLocations[Index]; >> +} >> + >> +/// getConstantPoolEntrySection - Return the section of the 'Index' entry >> in >> +/// the constant pool that was last emitted with the emitConstantPool >> method. >> +uintptr_t ObjectCodeEmitter::getConstantPoolEntrySection(unsigned Index) >> const { >> + assert(CPSections.size() > Index && "CP not emitted!"); >> + return CPSections[Index]; >> +} >> + >> +} // end namespace llvm >> + >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- > Bruno Cardoso Lopes > http://www.brunocardoso.cc > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090706/cd83b121/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: ObjectCodeEmitter.patch Type: application/octet-stream Size: 3893 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090706/cd83b121/attachment.obj From aaronngray.lists at googlemail.com Mon Jul 6 16:56:28 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 22:56:28 +0100 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> Message-ID: <0772BCC55D8C48209386001E95355240@HPLAPTOP> > We need to revisit the approach. Templatizing the CodeEmitter class is > probably not the right way to go Sorry I didn't think hard about this > when the patch landed back the end of May. Chris' recent "machine code" > work is obsoleting at least object code emitter so I'll let him comment. I have put alot of work into getting this far. My designs are really dependant upon this approach and it yeilds the fastest code emission at base level. All my subsequet code is really based on this approach. Chris know about the DOE development, and the designs have been on the Wiki for some time. Templating and using inline methods allow the fastest approach to the actual code emission. Its nice clean and efficient code, that allows bespoke usage of the code generator backend, for the JIT and Object Module emission. Aaron > Evan > > On Jul 6, 2009, at 12:53 PM, Bruno Cardoso Lopes wrote: > >> On Mon, Jul 6, 2009 at 4:11 PM, Evan Cheng wrote: >>> Sorry, I am missing some context. Why is each of the emitter a separate >>> template instantiation in the first place? Why can't the code in >> >> This happens because ObjectCodeEmitter is a lot simpler than >> JITCodeEmitter and >> we don't need to deal with CurrBufferBegin, GVStub*, and so on. >> >>> X86CodeEmitter.cpp be shared across all 3? >> >> I agree with Evan, I don't see why this code shouldn't be shared, >> besides that, putting >> all that code in a header file doesn't seems like the right approach. >> >> -- >> Bruno Cardoso Lopes >> http://www.brunocardoso.cc > From clattner at apple.com Mon Jul 6 16:59:01 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Jul 2009 14:59:01 -0700 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction In-Reply-To: References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> Message-ID: <160305E8-E713-49FD-9905-1792F398B34C@apple.com> On Jul 6, 2009, at 1:17 PM, Aaron Gray wrote: >>> >>> X86CodeEmitter.cpp be shared across all 3? >> >> I agree with Evan, I don't see why this code shouldn't be shared, >> besides that, putting >> all that code in a header file doesn't seems like the right approach. > > Its the right approach. > > It allows us to have separate object modules thus reducing memory > overheads > for other projects that at least one other person has been asking for. > > Putting templated code in headers and instatiating separately > in .cpp files > is quite common practice once you use templating alot. Hi Guys, I'm behind on code review, but why is this stuff templated at all? This seems very wrong. We *really* care about the JIT code size footprint and templating the whole emitter is not a good way to help footprint :) -Chris From clattner at apple.com Mon Jul 6 17:00:26 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Jul 2009 15:00:26 -0700 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction In-Reply-To: <0772BCC55D8C48209386001E95355240@HPLAPTOP> References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> <0772BCC55D8C48209386001E95355240@HPLAPTOP> Message-ID: <2754CA63-0EF0-41B7-8217-F464354C6A87@apple.com> On Jul 6, 2009, at 2:56 PM, Aaron Gray wrote: >> We need to revisit the approach. Templatizing the CodeEmitter class >> is probably not the right way to go Sorry I didn't think hard about >> this when the patch landed back the end of May. Chris' recent >> "machine code" work is obsoleting at least object code emitter so >> I'll let him comment. > > I have put alot of work into getting this far. My designs are really > dependant upon this approach and it yeilds the fastest code emission > at base level. All my subsequet code is really based on this > approach. Chris know about the DOE development, and the designs have > been on the Wiki for some time. > > Templating and using inline methods allow the fastest approach to > the actual code emission. Its nice clean and efficient code, that > allows bespoke usage of the code generator backend, for the JIT and > Object Module emission. Hi Aaron, what part of your design talks about this? What problem is templating this all solving? -Chris From clattner at apple.com Mon Jul 6 17:01:19 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Jul 2009 15:01:19 -0700 Subject: [llvm-commits] [llvm] r74844 - in /llvm/trunk: include/llvm/Analysis/ include/llvm/Support/ lib/Analysis/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ In-Reply-To: <200907061842.n66Igvqn032166@zion.cs.uiuc.edu> References: <200907061842.n66Igvqn032166@zion.cs.uiuc.edu> Message-ID: <47D9F5D9-7F5A-499A-B61F-1D0F87EB2EE5@apple.com> On Jul 6, 2009, at 11:42 AM, Owen Anderson wrote: > Author: resistor > Date: Mon Jul 6 13:42:36 2009 > New Revision: 74844 > > URL: http://llvm.org/viewvc/llvm-project?rev=74844&view=rev > Log: > Thread LLVMContext through the constant folding APIs, which touches > a lot of files. > -Constant *ConstantFoldInstruction(Instruction *I, const TargetData > *TD = 0); > +Constant *ConstantFoldInstruction(Instruction *I, LLVMContext* > Context, Owen, please use "LLVMContext *Context", not "LLVMContext* Context" as we previously discussed. -Chris From evan.cheng at apple.com Mon Jul 6 17:05:45 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 06 Jul 2009 22:05:45 -0000 Subject: [llvm-commits] [llvm] r74866 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td test/CodeGen/ARM/mls.ll Message-ID: <200907062205.n66M5jOF006218@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jul 6 17:05:45 2009 New Revision: 74866 URL: http://llvm.org/viewvc/llvm-project?rev=74866&view=rev Log: Added ARM::mls for armv6t2. Added: llvm/trunk/test/CodeGen/ARM/mls.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=74866&r1=74865&r2=74866&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon Jul 6 17:05:45 2009 @@ -93,6 +93,7 @@ def HasV5T : Predicate<"Subtarget->hasV5TOps()">; def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">; def HasV6 : Predicate<"Subtarget->hasV6Ops()">; +def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">; def HasV7 : Predicate<"Subtarget->hasV7Ops()">; def HasVFP2 : Predicate<"Subtarget->hasVFP2()">; def HasVFP3 : Predicate<"Subtarget->hasVFP3()">; @@ -1019,6 +1020,11 @@ "mla", " $dst, $a, $b, $c", [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>; +def MLS : AMul1I <0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), + "mls", " $dst, $a, $b, $c", + [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>, + Requires<[IsARM, HasV6T2]>; + // Extra precision multiplies with low / high results let neverHasSideEffects = 1 in { let isCommutable = 1 in { Added: llvm/trunk/test/CodeGen/ARM/mls.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/mls.ll?rev=74866&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/mls.ll (added) +++ llvm/trunk/test/CodeGen/ARM/mls.ll Mon Jul 6 17:05:45 2009 @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+v6t2 | grep {mls\\W*r\[0-9\],\\W*r\[0-9\],\\W*r\[0-9\],\\W*r\[0-9\]} | count 1 + +define i32 @f1(i32 %a, i32 %b, i32 %c) { + %tmp1 = mul i32 %a, %b + %tmp2 = sub i32 %c, %tmp1 + ret i32 %tmp2 +} + +; sub doesn't commute, so no mls for this one +define i32 @f2(i32 %a, i32 %b, i32 %c) { + %tmp1 = mul i32 %a, %b + %tmp2 = sub i32 %tmp1, %c + ret i32 %tmp2 +} From aaronngray.lists at googlemail.com Mon Jul 6 17:07:52 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Mon, 6 Jul 2009 23:07:52 +0100 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> <0772BCC55D8C48209386001E95355240@HPLAPTOP> <2754CA63-0EF0-41B7-8217-F464354C6A87@apple.com> Message-ID: <1DDE1F32B1CA4138A16F4434BF65EB36@HPLAPTOP> > On Jul 6, 2009, at 2:56 PM, Aaron Gray wrote: > >>> We need to revisit the approach. Templatizing the CodeEmitter class is >>> probably not the right way to go Sorry I didn't think hard about this >>> when the patch landed back the end of May. Chris' recent "machine >>> code" work is obsoleting at least object code emitter so I'll let him >>> comment. >> >> I have put alot of work into getting this far. My designs are really >> dependant upon this approach and it yeilds the fastest code emission at >> base level. All my subsequet code is really based on this approach. >> Chris know about the DOE development, and the designs have been on the >> Wiki for some time. >> >> Templating and using inline methods allow the fastest approach to the >> actual code emission. Its nice clean and efficient code, that allows >> bespoke usage of the code generator backend, for the JIT and Object >> Module emission. > > Hi Aaron, what part of your design talks about this? What problem is > templating this all solving? Templating allows us to have mutiple types of MachineCodeEmitters, the JITCodeEmitter, and the ObjectCodeEmitter, and any other kind of CodeEmitter we require in the future, e.g. Reid Kleckner' requirements to combine JIT and GDB. It allows these emiiters to be efficient and be inlined functions. If you study the code you will see what I mean. Aaron From clattner at apple.com Mon Jul 6 17:11:49 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Jul 2009 15:11:49 -0700 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction In-Reply-To: <1DDE1F32B1CA4138A16F4434BF65EB36@HPLAPTOP> References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> <0772BCC55D8C48209386001E95355240@HPLAPTOP> <2754CA63-0EF0-41B7-8217-F464354C6A87@apple.com> <1DDE1F32B1CA4138A16F4434BF65EB36@HPLAPTOP> Message-ID: <669DD8A2-E16D-4E48-9D13-3C2816E60722@apple.com> On Jul 6, 2009, at 3:07 PM, Aaron Gray wrote: >> >> Hi Aaron, what part of your design talks about this? What problem >> is templating this all solving? > > Templating allows us to have mutiple types of MachineCodeEmitters, > the JITCodeEmitter, and the ObjectCodeEmitter, and any other kind of > CodeEmitter we require in the future, e.g. Reid Kleckner' > requirements to combine JIT and GDB. It allows these emiiters to be > efficient and be inlined functions. If you study the code you will > see what I mean. There are many other ways to split this out. Emitting machine code should not need templates. This sounds like you have the wrong abstraction level here. Why can't virtual methods, containment, etc be used instead of templates? The X86 code that says "output an add as these 3 bytes" should be completely independent from the code that does something with the bytes. -Chris From evan.cheng at apple.com Mon Jul 6 17:23:47 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 06 Jul 2009 22:23:47 -0000 Subject: [llvm-commits] [llvm] r74868 - in /llvm/trunk: lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/bfc.ll Message-ID: <200907062223.n66MNlrU006805@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jul 6 17:23:46 2009 New Revision: 74868 URL: http://llvm.org/viewvc/llvm-project?rev=74868&view=rev Log: Add bfc to armv6t2. Added: llvm/trunk/test/CodeGen/ARM/bfc.ll Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=74868&r1=74867&r2=74868&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Mon Jul 6 17:23:46 2009 @@ -741,6 +741,11 @@ unsigned ImplicitRn) { const TargetInstrDesc &TID = MI.getDesc(); + if (TID.Opcode == ARM::BFC) { + cerr << "ERROR: ARMv6t2 JIT is not yet supported.\n"; + abort(); + } + // Part of binary is determined by TableGn. unsigned Binary = getBinaryCodeForInstr(MI); Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=74868&r1=74867&r2=74868&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon Jul 6 17:23:46 2009 @@ -170,6 +170,27 @@ return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17; }]>; +/// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield +/// e.g., 0xf000ffff +def bf_inv_mask_imm : Operand, + PatLeaf<(imm), [{ + uint32_t v = (uint32_t)N->getZExtValue(); + if (v == 0xffffffff) + return 0; + // naive checker. should do better, but simple is best for now since it's + // more likely to be correct. + while (v & 1) v >>= 1; // shift off the leading 1's + if (v) + { + while (!(v & 1)) v >>=1; // shift off the mask + while (v & 1) v >>= 1; // shift off the trailing 1's + } + // if this is a mask for clearing a bitfield, what's left should be zero. + return (v == 0); +}] > { + let PrintMethod = "printBitfieldInvMaskImmOperand"; +} + class BinOpFrag : PatFrag<(ops node:$LHS, node:$RHS), res>; class UnOpFrag : PatFrag<(ops node:$Src), res>; @@ -993,6 +1014,15 @@ defm BIC : AsI1_bin_irs<0b1110, "bic", BinOpFrag<(and node:$LHS, (not node:$RHS))>>; +def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm), + AddrMode1, Size4Bytes, IndexModeNone, DPFrm, + "bfc", " $dst, $imm", "$src = $dst", + [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>, + Requires<[IsARM, HasV6T2]> { + let Inst{27-21} = 0b0111110; + let Inst{6-0} = 0b0011111; +} + def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, "mvn", " $dst, $src", [(set GPR:$dst, (not GPR:$src))]>, UnaryDP; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=74868&r1=74867&r2=74868&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Jul 6 17:23:46 2009 @@ -89,27 +89,6 @@ return (uint32_t)N->getZExtValue() < 65536; }]>; -/// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield -/// e.g., 0xf000ffff -def bf_inv_mask_imm : Operand, - PatLeaf<(imm), [{ - uint32_t v = (uint32_t)N->getZExtValue(); - if (v == 0xffffffff) - return 0; - // naive checker. should do better, but simple is best for now since it's - // more likely to be correct. - while (v & 1) v >>= 1; // shift off the leading 1's - if (v) - { - while (!(v & 1)) v >>=1; // shift off the mask - while (v & 1) v >>= 1; // shift off the trailing 1's - } - // if this is a mask for clearing a bitfield, what's left should be zero. - return (v == 0); -}] > { - let PrintMethod = "printBitfieldInvMaskImmOperand"; -} - /// Split a 32-bit immediate into two 16 bit parts. def t2_lo16 : SDNodeXFormgetTargetConstant((uint32_t)N->getZExtValue() & 0xffff, @@ -820,29 +799,28 @@ defm t2BIC : T2I_bin_irs<"bic", BinOpFrag<(and node:$LHS, (not node:$RHS))>>; -def : T2Pat<(and GPR:$src, t2_so_imm_not:$imm), - (t2BICri GPR:$src, t2_so_imm_not:$imm)>; +let Constraints = "$src = $dst" in +def t2BFC : T2I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm), + "bfc", " $dst, $imm", + [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>; -defm t2ORN : T2I_bin_irs<"orn", BinOpFrag<(or node:$LHS, (not node:$RHS))>>; +// FIXME: A8.6.18 BFI - Bitfield insert (Encoding T1) -def : T2Pat<(or GPR:$src, t2_so_imm_not:$imm), - (t2ORNri GPR:$src, t2_so_imm_not:$imm)>; +defm t2ORN : T2I_bin_irs<"orn", BinOpFrag<(or node:$LHS, (not node:$RHS))>>; // Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version let AddedComplexity = 1 in defm t2MVN : T2I_un_irs <"mvn", UnOpFrag<(not node:$Src)>, 1, 1>; -def : T2Pat<(t2_so_imm_not:$src), - (t2MVNi t2_so_imm_not:$src)>; -// A8.6.17 BFC - Bitfield clear -// FIXME: Also available in ARM mode. -let Constraints = "$src = $dst" in -def t2BFC : T2I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm), - "bfc", " $dst, $imm", - [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>; +def : T2Pat<(and GPR:$src, t2_so_imm_not:$imm), + (t2BICri GPR:$src, t2_so_imm_not:$imm)>; -// FIXME: A8.6.18 BFI - Bitfield insert (Encoding T1) +def : T2Pat<(or GPR:$src, t2_so_imm_not:$imm), + (t2ORNri GPR:$src, t2_so_imm_not:$imm)>; + +def : T2Pat<(t2_so_imm_not:$src), + (t2MVNi t2_so_imm_not:$src)>; //===----------------------------------------------------------------------===// // Multiply Instructions. Added: llvm/trunk/test/CodeGen/ARM/bfc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/bfc.ll?rev=74868&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/bfc.ll (added) +++ llvm/trunk/test/CodeGen/ARM/bfc.ll Mon Jul 6 17:23:46 2009 @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+v6t2 | grep "bfc " | count 3 + +; 4278190095 = 0xff00000f +define i32 @f1(i32 %a) { + %tmp = and i32 %a, 4278190095 + ret i32 %tmp +} + +; 4286578688 = 0xff800000 +define i32 @f2(i32 %a) { + %tmp = and i32 %a, 4286578688 + ret i32 %tmp +} + +; 4095 = 0x00000fff +define i32 @f3(i32 %a) { + %tmp = and i32 %a, 4095 + ret i32 %tmp +} From sabre at nondot.org Mon Jul 6 17:24:16 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Jul 2009 22:24:16 -0000 Subject: [llvm-commits] [compiler-rt] r74869 - /compiler-rt/trunk/make/filter-inputs Message-ID: <200907062224.n66MOGAo006830@zion.cs.uiuc.edu> Author: lattner Date: Mon Jul 6 17:24:16 2009 New Revision: 74869 URL: http://llvm.org/viewvc/llvm-project?rev=74869&view=rev Log: improve portability to platforms that don't put python in /usr/bin. Patch by Pawel Worach! Modified: compiler-rt/trunk/make/filter-inputs Modified: compiler-rt/trunk/make/filter-inputs URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/filter-inputs?rev=74869&r1=74868&r2=74869&view=diff ============================================================================== --- compiler-rt/trunk/make/filter-inputs (original) +++ compiler-rt/trunk/make/filter-inputs Mon Jul 6 17:24:16 2009 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python #===- make/filter-inputs ---------------------------------------------------===# # From clattner at apple.com Mon Jul 6 17:24:38 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Jul 2009 15:24:38 -0700 Subject: [llvm-commits] [patch] Fix compiler_rt build system on FreeBSD In-Reply-To: References: Message-ID: On Jul 5, 2009, at 2:21 PM, Pawel Worach wrote: > Hi, > > Please use env(1) to call python, FreeBSD installs python in > /usr/local/bin and probably other systems behave the same way. Thanks, applied: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090706/080194.html -Chris > > Index: make/filter-inputs > =================================================================== > --- make/filter-inputs (revision 74795) > +++ make/filter-inputs (working copy) > @@ -1,4 +1,4 @@ > -#!/usr/bin/python > +#!/usr/bin/env python > > #===- make/filter-inputs > ---------------------------------------------------===# > # > > -- > Pawel > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Mon Jul 6 17:29:14 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 06 Jul 2009 22:29:14 -0000 Subject: [llvm-commits] [llvm] r74871 - /llvm/trunk/lib/Target/ARM/ARMSubtarget.h Message-ID: <200907062229.n66MTEet007009@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jul 6 17:29:14 2009 New Revision: 74871 URL: http://llvm.org/viewvc/llvm-project?rev=74871&view=rev Log: isThumb2 really should mean thumb2 only, not thumb2+. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=74871&r1=74870&r2=74871&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Mon Jul 6 17:29:14 2009 @@ -108,7 +108,7 @@ bool isThumb() const { return IsThumb; } bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); } - bool isThumb2() const { return IsThumb && (ThumbMode >= Thumb2); } + bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); } bool hasThumb2() const { return ThumbMode >= Thumb2; } bool isR9Reserved() const { return IsR9Reserved; } From resistor at mac.com Mon Jul 6 17:37:39 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 06 Jul 2009 22:37:39 -0000 Subject: [llvm-commits] [llvm] r74873 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolutionExpander.h include/llvm/Analysis/SparsePropagation.h include/llvm/Analysis/ValueTracking.h lib/Analysis/DebugInfo.cpp lib/Analysis/LoopVR.cpp lib/Analysis/ScalarEvolution.cpp lib/Analysis/ScalarEvolutionExpander.cpp lib/Analysis/SparsePropagation.cpp lib/Analysis/ValueTracking.cpp lib/Transforms/IPO/IPConstantPropagation.cpp lib/Transforms/Scalar/SCCP.cpp Message-ID: <200907062237.n66Mbdpg007256@zion.cs.uiuc.edu> Author: resistor Date: Mon Jul 6 17:37:39 2009 New Revision: 74873 URL: http://llvm.org/viewvc/llvm-project?rev=74873&view=rev Log: Finish LLVMContext-ing lib/Analysis. This required pushing LLVMContext's through the ValueTracking API. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h llvm/trunk/include/llvm/Analysis/SparsePropagation.h llvm/trunk/include/llvm/Analysis/ValueTracking.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/Analysis/LoopVR.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp llvm/trunk/lib/Analysis/SparsePropagation.cpp llvm/trunk/lib/Analysis/ValueTracking.cpp llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Mon Jul 6 17:37:39 2009 @@ -59,6 +59,8 @@ } private: + LLVMContext *getContext() const { return SE.getContext(); } + /// InsertBinop - Insert the specified binary operator, doing a small amount /// of work to avoid inserting an obviously redundant operation. Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS, Value *RHS); Modified: llvm/trunk/include/llvm/Analysis/SparsePropagation.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/SparsePropagation.h?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/SparsePropagation.h (original) +++ llvm/trunk/include/llvm/Analysis/SparsePropagation.h Mon Jul 6 17:37:39 2009 @@ -31,6 +31,7 @@ class BasicBlock; class Function; class SparseSolver; + class LLVMContext; template class SmallVectorImpl; @@ -113,6 +114,8 @@ /// compute transfer functions. AbstractLatticeFunction *LatticeFunc; + LLVMContext *Context; + DenseMap ValueState; // The state each value is in. SmallPtrSet BBExecutable; // The bbs that are executable. @@ -128,8 +131,8 @@ SparseSolver(const SparseSolver&); // DO NOT IMPLEMENT void operator=(const SparseSolver&); // DO NOT IMPLEMENT public: - explicit SparseSolver(AbstractLatticeFunction *Lattice) - : LatticeFunc(Lattice) {} + explicit SparseSolver(AbstractLatticeFunction *Lattice, LLVMContext* C) + : LatticeFunc(Lattice), Context(C) {} ~SparseSolver() { delete LatticeFunc; } Modified: llvm/trunk/include/llvm/Analysis/ValueTracking.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ValueTracking.h?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ValueTracking.h (original) +++ llvm/trunk/include/llvm/Analysis/ValueTracking.h Mon Jul 6 17:37:39 2009 @@ -23,6 +23,7 @@ class Instruction; class APInt; class TargetData; + class LLVMContext; /// ComputeMaskedBits - Determine which of the bits specified in Mask are /// known to be either zero or one and return them in the KnownZero/KnownOne @@ -64,14 +65,16 @@ Value *FindInsertedValue(Value *V, const unsigned *idx_begin, const unsigned *idx_end, + LLVMContext *Context, Instruction *InsertBefore = 0); /// This is a convenience wrapper for finding values indexed by a single index /// only. inline Value *FindInsertedValue(Value *V, const unsigned Idx, + LLVMContext *Context, Instruction *InsertBefore = 0) { const unsigned Idxs[1] = { Idx }; - return FindInsertedValue(V, &Idxs[0], &Idxs[1], InsertBefore); + return FindInsertedValue(V, &Idxs[0], &Idxs[1], Context, InsertBefore); } /// GetConstantStringInfo - This function computes the length of a Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Jul 6 17:37:39 2009 @@ -18,6 +18,7 @@ #include "llvm/Intrinsics.h" #include "llvm/IntrinsicInst.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Support/Dwarf.h" @@ -455,14 +456,15 @@ DIFactory::DIFactory(Module &m) : M(m), StopPointFn(0), FuncStartFn(0), RegionStartFn(0), RegionEndFn(0), DeclareFn(0) { - EmptyStructPtr = PointerType::getUnqual(StructType::get()); + EmptyStructPtr = + M.getContext().getPointerTypeUnqual(M.getContext().getStructType()); } /// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'. /// This is only valid when the descriptor is non-null. Constant *DIFactory::getCastToEmpty(DIDescriptor D) { - if (D.isNull()) return Constant::getNullValue(EmptyStructPtr); - return ConstantExpr::getBitCast(D.getGV(), EmptyStructPtr); + if (D.isNull()) return M.getContext().getNullValue(EmptyStructPtr); + return M.getContext().getConstantExprBitCast(D.getGV(), EmptyStructPtr); } Constant *DIFactory::GetTagConstant(unsigned TAG) { @@ -478,21 +480,21 @@ // Return Constant if previously defined. if (Slot) return Slot; - const PointerType *DestTy = PointerType::getUnqual(Type::Int8Ty); + const PointerType *DestTy = M.getContext().getPointerTypeUnqual(Type::Int8Ty); // If empty string then use a i8* null instead. if (String.empty()) - return Slot = ConstantPointerNull::get(DestTy); + return Slot = M.getContext().getConstantPointerNull(DestTy); // Construct string as an llvm constant. - Constant *ConstStr = ConstantArray::get(String); + Constant *ConstStr = M.getContext().getConstantArray(String); // Otherwise create and return a new string global. GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true, GlobalVariable::InternalLinkage, ConstStr, ".str", &M); StrGV->setSection("llvm.metadata"); - return Slot = ConstantExpr::getBitCast(StrGV, DestTy); + return Slot = M.getContext().getConstantExprBitCast(StrGV, DestTy); } //===----------------------------------------------------------------------===// @@ -504,10 +506,12 @@ DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) { SmallVector Elts; + LLVMContext& Ctxt = M.getContext(); + for (unsigned i = 0; i != NumTys; ++i) Elts.push_back(getCastToEmpty(Tys[i])); - Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr, + Constant *Init = Ctxt.getConstantArray(Ctxt.getArrayType(EmptyStructPtr, Elts.size()), Elts.data(), Elts.size()); // If we already have this array, just return the uniqued version. @@ -527,11 +531,12 @@ DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) { Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_subrange_type), - ConstantInt::get(Type::Int64Ty, Lo), - ConstantInt::get(Type::Int64Ty, Hi) + M.getContext().getConstantInt(Type::Int64Ty, Lo), + M.getContext().getConstantInt(Type::Int64Ty, Hi) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + M.getContext().getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); // If we already have this range, just return the uniqued version. DIDescriptor &Entry = SimpleConstantCache[Init]; @@ -559,20 +564,22 @@ bool isOptimized, const char *Flags, unsigned RunTimeVer) { + LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_compile_unit), - Constant::getNullValue(EmptyStructPtr), - ConstantInt::get(Type::Int32Ty, LangID), + Ctxt.getNullValue(EmptyStructPtr), + Ctxt.getConstantInt(Type::Int32Ty, LangID), GetStringConstant(Filename), GetStringConstant(Directory), GetStringConstant(Producer), - ConstantInt::get(Type::Int1Ty, isMain), - ConstantInt::get(Type::Int1Ty, isOptimized), + Ctxt.getConstantInt(Type::Int1Ty, isMain), + Ctxt.getConstantInt(Type::Int1Ty, isOptimized), GetStringConstant(Flags), - ConstantInt::get(Type::Int32Ty, RunTimeVer) + Ctxt.getConstantInt(Type::Int32Ty, RunTimeVer) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.compile_unit.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -587,10 +594,11 @@ Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_enumerator), GetStringConstant(Name), - ConstantInt::get(Type::Int64Ty, Val) + M.getContext().getConstantInt(Type::Int64Ty, Val) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + M.getContext().getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.enumerator.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -610,20 +618,23 @@ uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, unsigned Encoding) { + + LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_base_type), getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNumber), - ConstantInt::get(Type::Int64Ty, SizeInBits), - ConstantInt::get(Type::Int64Ty, AlignInBits), - ConstantInt::get(Type::Int64Ty, OffsetInBits), - ConstantInt::get(Type::Int32Ty, Flags), - ConstantInt::get(Type::Int32Ty, Encoding) + Ctxt.getConstantInt(Type::Int32Ty, LineNumber), + Ctxt.getConstantInt(Type::Int64Ty, SizeInBits), + Ctxt.getConstantInt(Type::Int64Ty, AlignInBits), + Ctxt.getConstantInt(Type::Int64Ty, OffsetInBits), + Ctxt.getConstantInt(Type::Int32Ty, Flags), + Ctxt.getConstantInt(Type::Int32Ty, Encoding) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.basictype.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -645,20 +656,23 @@ uint64_t OffsetInBits, unsigned Flags, DIType DerivedFrom) { + + LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(Tag), getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNumber), - ConstantInt::get(Type::Int64Ty, SizeInBits), - ConstantInt::get(Type::Int64Ty, AlignInBits), - ConstantInt::get(Type::Int64Ty, OffsetInBits), - ConstantInt::get(Type::Int32Ty, Flags), + Ctxt.getConstantInt(Type::Int32Ty, LineNumber), + Ctxt.getConstantInt(Type::Int64Ty, SizeInBits), + Ctxt.getConstantInt(Type::Int64Ty, AlignInBits), + Ctxt.getConstantInt(Type::Int64Ty, OffsetInBits), + Ctxt.getConstantInt(Type::Int32Ty, Flags), getCastToEmpty(DerivedFrom) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.derivedtype.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -681,23 +695,24 @@ DIType DerivedFrom, DIArray Elements, unsigned RuntimeLang) { - + LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(Tag), getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNumber), - ConstantInt::get(Type::Int64Ty, SizeInBits), - ConstantInt::get(Type::Int64Ty, AlignInBits), - ConstantInt::get(Type::Int64Ty, OffsetInBits), - ConstantInt::get(Type::Int32Ty, Flags), + Ctxt.getConstantInt(Type::Int32Ty, LineNumber), + Ctxt.getConstantInt(Type::Int64Ty, SizeInBits), + Ctxt.getConstantInt(Type::Int64Ty, AlignInBits), + Ctxt.getConstantInt(Type::Int64Ty, OffsetInBits), + Ctxt.getConstantInt(Type::Int32Ty, Flags), getCastToEmpty(DerivedFrom), getCastToEmpty(Elements), - ConstantInt::get(Type::Int32Ty, RuntimeLang) + Ctxt.getConstantInt(Type::Int32Ty, RuntimeLang) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.composite.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -720,21 +735,23 @@ bool isLocalToUnit, bool isDefinition) { + LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_subprogram), - Constant::getNullValue(EmptyStructPtr), + Ctxt.getNullValue(EmptyStructPtr), getCastToEmpty(Context), GetStringConstant(Name), GetStringConstant(DisplayName), GetStringConstant(LinkageName), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNo), + Ctxt.getConstantInt(Type::Int32Ty, LineNo), getCastToEmpty(Type), - ConstantInt::get(Type::Int1Ty, isLocalToUnit), - ConstantInt::get(Type::Int1Ty, isDefinition) + Ctxt.getConstantInt(Type::Int1Ty, isLocalToUnit), + Ctxt.getConstantInt(Type::Int1Ty, isDefinition) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.subprogram.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -752,22 +769,25 @@ DICompileUnit CompileUnit, unsigned LineNo, DIType Type,bool isLocalToUnit, bool isDefinition, llvm::GlobalVariable *Val) { + + LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_variable), - Constant::getNullValue(EmptyStructPtr), + Ctxt.getNullValue(EmptyStructPtr), getCastToEmpty(Context), GetStringConstant(Name), GetStringConstant(DisplayName), GetStringConstant(LinkageName), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNo), + Ctxt.getConstantInt(Type::Int32Ty, LineNo), getCastToEmpty(Type), - ConstantInt::get(Type::Int1Ty, isLocalToUnit), - ConstantInt::get(Type::Int1Ty, isDefinition), - ConstantExpr::getBitCast(Val, EmptyStructPtr) + Ctxt.getConstantInt(Type::Int1Ty, isLocalToUnit), + Ctxt.getConstantInt(Type::Int1Ty, isDefinition), + Ctxt.getConstantExprBitCast(Val, EmptyStructPtr) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.global_variable.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -783,16 +803,19 @@ const std::string &Name, DICompileUnit CompileUnit, unsigned LineNo, DIType Type) { + LLVMContext& Ctxt = M.getContext(); + Constant *Elts[] = { GetTagConstant(Tag), getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNo), + Ctxt.getConstantInt(Type::Int32Ty, LineNo), getCastToEmpty(Type) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.variable.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -811,7 +834,8 @@ getCastToEmpty(Context) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = + M.getContext().getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.block.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -838,8 +862,8 @@ // Invoke llvm.dbg.stoppoint Value *Args[] = { - llvm::ConstantInt::get(llvm::Type::Int32Ty, LineNo), - llvm::ConstantInt::get(llvm::Type::Int32Ty, ColNo), + M.getContext().getConstantInt(llvm::Type::Int32Ty, LineNo), + M.getContext().getConstantInt(llvm::Type::Int32Ty, ColNo), getCastToEmpty(CU) }; CallInst::Create(StopPointFn, Args, Args+3, "", BB); @@ -942,7 +966,7 @@ const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type"); if (!Ty) return 0; - Ty = PointerType::get(Ty, 0); + Ty = V->getParent()->getContext().getPointerType(Ty, 0); Value *Val = V->stripPointerCasts(); for (Value::use_iterator I = Val->use_begin(), E = Val->use_end(); Modified: llvm/trunk/lib/Analysis/LoopVR.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopVR.cpp?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopVR.cpp (original) +++ llvm/trunk/lib/Analysis/LoopVR.cpp Mon Jul 6 17:37:39 2009 @@ -15,6 +15,7 @@ #include "llvm/Analysis/LoopVR.h" #include "llvm/Constants.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CFG.h" @@ -71,8 +72,8 @@ ConstantRange X = getRange(Mul->getOperand(0), T, SE); if (X.isFullSet()) return FullSet; - const IntegerType *Ty = IntegerType::get(X.getBitWidth()); - const IntegerType *ExTy = IntegerType::get(X.getBitWidth() * + const IntegerType *Ty = Context->getIntegerType(X.getBitWidth()); + const IntegerType *ExTy = Context->getIntegerType(X.getBitWidth() * Mul->getNumOperands()); ConstantRange XExt = X.zeroExtend(ExTy->getBitWidth()); Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jul 6 17:37:39 2009 @@ -65,6 +65,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/GlobalVariable.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopInfo.h" @@ -3839,8 +3840,12 @@ return std::make_pair(CNC, CNC); } - ConstantInt *Solution1 = ConstantInt::get((NegB + SqrtVal).sdiv(TwoA)); - ConstantInt *Solution2 = ConstantInt::get((NegB - SqrtVal).sdiv(TwoA)); + LLVMContext *Context = SE.getContext(); + + ConstantInt *Solution1 = + Context->getConstantInt((NegB + SqrtVal).sdiv(TwoA)); + ConstantInt *Solution2 = + Context->getConstantInt((NegB - SqrtVal).sdiv(TwoA)); return std::make_pair(SE.getConstant(Solution1), SE.getConstant(Solution2)); @@ -3908,7 +3913,7 @@ #endif // Pick the smallest positive root value. if (ConstantInt *CB = - dyn_cast(ConstantExpr::getICmp(ICmpInst::ICMP_ULT, + dyn_cast(Context->getConstantExprICmp(ICmpInst::ICMP_ULT, R1->getValue(), R2->getValue()))) { if (CB->getZExtValue() == false) std::swap(R1, R2); // R1 is the minimum root now. @@ -4157,7 +4162,7 @@ // Check Add for unsigned overflow. // TODO: More sophisticated things could be done here. - const Type *WideTy = IntegerType::get(getTypeSizeInBits(Ty) + 1); + const Type *WideTy = Context->getIntegerType(getTypeSizeInBits(Ty) + 1); const SCEV* OperandExtendedAdd = getAddExpr(getZeroExtendExpr(Diff, WideTy), getZeroExtendExpr(RoundUp, WideTy)); @@ -4313,7 +4318,7 @@ // The exit value should be (End+A)/A. APInt ExitVal = (End + A).udiv(A); - ConstantInt *ExitValue = ConstantInt::get(ExitVal); + ConstantInt *ExitValue = SE.getContext()->getConstantInt(ExitVal); // Evaluate at the exit value. If we really did fall out of the valid // range, then we computed our trip count, otherwise wrap around or other @@ -4325,7 +4330,7 @@ // Ensure that the previous value is in the range. This is a sanity check. assert(Range.contains( EvaluateConstantChrecAtConstant(this, - ConstantInt::get(ExitVal - One), SE)->getValue()) && + SE.getContext()->getConstantInt(ExitVal - One), SE)->getValue()) && "Linear scev computation is off in a bad way!"); return SE.getConstant(ExitValue); } else if (isQuadratic()) { @@ -4345,8 +4350,9 @@ if (R1) { // Pick the smallest positive root value. if (ConstantInt *CB = - dyn_cast(ConstantExpr::getICmp(ICmpInst::ICMP_ULT, - R1->getValue(), R2->getValue()))) { + dyn_cast( + SE.getContext()->getConstantExprICmp(ICmpInst::ICMP_ULT, + R1->getValue(), R2->getValue()))) { if (CB->getZExtValue() == false) std::swap(R1, R2); // R1 is the minimum root now. @@ -4358,7 +4364,8 @@ SE); if (Range.contains(R1Val->getValue())) { // The next iteration must be out of the range... - ConstantInt *NextVal = ConstantInt::get(R1->getValue()->getValue()+1); + ConstantInt *NextVal = + SE.getContext()->getConstantInt(R1->getValue()->getValue()+1); R1Val = EvaluateConstantChrecAtConstant(this, NextVal, SE); if (!Range.contains(R1Val->getValue())) @@ -4368,7 +4375,8 @@ // If R1 was not in the range, then it is a good return value. Make // sure that R1-1 WAS in the range though, just in case. - ConstantInt *NextVal = ConstantInt::get(R1->getValue()->getValue()-1); + ConstantInt *NextVal = + SE.getContext()->getConstantInt(R1->getValue()->getValue()-1); R1Val = EvaluateConstantChrecAtConstant(this, NextVal, SE); if (Range.contains(R1Val->getValue())) return R1; Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Jul 6 17:37:39 2009 @@ -15,6 +15,7 @@ #include "llvm/Analysis/ScalarEvolutionExpander.h" #include "llvm/Analysis/LoopInfo.h" +#include "llvm/LLVMContext.h" #include "llvm/Target/TargetData.h" #include "llvm/ADT/STLExtras.h" using namespace llvm; @@ -54,7 +55,7 @@ // FIXME: keep track of the cast instruction. if (Constant *C = dyn_cast(V)) - return ConstantExpr::getCast(Op, C, Ty); + return getContext()->getConstantExprCast(Op, C, Ty); if (Argument *A = dyn_cast(V)) { // Check to see if there is already a cast! @@ -125,7 +126,7 @@ // Fold a binop with constant operands. if (Constant *CLHS = dyn_cast(LHS)) if (Constant *CRHS = dyn_cast(RHS)) - return ConstantExpr::get(Opcode, CLHS, CRHS); + return getContext()->getConstantExpr(Opcode, CLHS, CRHS); // Do a quick scan to see if we have this binop nearby. If so, reuse it. unsigned ScanLimit = 6; @@ -166,7 +167,7 @@ // For a Constant, check for a multiple of the given factor. if (const SCEVConstant *C = dyn_cast(S)) { ConstantInt *CI = - ConstantInt::get(C->getValue()->getValue().sdiv(Factor)); + SE.getContext()->getConstantInt(C->getValue()->getValue().sdiv(Factor)); // If the quotient is zero and the remainder is non-zero, reject // the value at this scale. It will be considered for subsequent // smaller scales. @@ -286,7 +287,7 @@ Ops = NewOps; AnyNonZeroIndices |= !ScaledOps.empty(); Value *Scaled = ScaledOps.empty() ? - Constant::getNullValue(Ty) : + getContext()->getNullValue(Ty) : expandCodeFor(SE.getAddExpr(ScaledOps), Ty); GepIndices.push_back(Scaled); @@ -299,7 +300,8 @@ uint64_t FullOffset = C->getValue()->getZExtValue(); if (FullOffset < SL.getSizeInBytes()) { unsigned ElIdx = SL.getElementContainingOffset(FullOffset); - GepIndices.push_back(ConstantInt::get(Type::Int32Ty, ElIdx)); + GepIndices.push_back( + getContext()->getConstantInt(Type::Int32Ty, ElIdx)); ElTy = STy->getTypeAtIndex(ElIdx); Ops[0] = SE.getConstant(Ty, FullOffset - SL.getElementOffset(ElIdx)); @@ -328,7 +330,7 @@ // Fold a GEP with constant operands. if (Constant *CLHS = dyn_cast(V)) if (Constant *CRHS = dyn_cast(Idx)) - return ConstantExpr::getGetElementPtr(CLHS, &CRHS, 1); + return getContext()->getConstantExprGetElementPtr(CLHS, &CRHS, 1); // Do a quick scan to see if we have this GEP nearby. If so, reuse it. unsigned ScanLimit = 6; @@ -400,7 +402,7 @@ // -1 * ... ---> 0 - ... if (FirstOp == 1) - V = InsertBinop(Instruction::Sub, Constant::getNullValue(Ty), V); + V = InsertBinop(Instruction::Sub, getContext()->getNullValue(Ty), V); return V; } @@ -412,7 +414,7 @@ const APInt &RHS = SC->getValue()->getValue(); if (RHS.isPowerOf2()) return InsertBinop(Instruction::LShr, LHS, - ConstantInt::get(Ty, RHS.logBase2())); + getContext()->getConstantInt(Ty, RHS.logBase2())); } Value *RHS = expandCodeFor(S->getRHS(), Ty); @@ -522,7 +524,7 @@ BasicBlock *Preheader = L->getLoopPreheader(); PHINode *PN = PHINode::Create(Ty, "indvar", Header->begin()); InsertedValues.insert(PN); - PN->addIncoming(Constant::getNullValue(Ty), Preheader); + PN->addIncoming(getContext()->getNullValue(Ty), Preheader); pred_iterator HPI = pred_begin(Header); assert(HPI != pred_end(Header) && "Loop with zero preds???"); @@ -532,7 +534,7 @@ // Insert a unit add instruction right before the terminator corresponding // to the back-edge. - Constant *One = ConstantInt::get(Ty, 1); + Constant *One = getContext()->getConstantInt(Ty, 1); Instruction *Add = BinaryOperator::CreateAdd(PN, One, "indvar.next", (*HPI)->getTerminator()); InsertedValues.insert(Add); Modified: llvm/trunk/lib/Analysis/SparsePropagation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/SparsePropagation.cpp?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/SparsePropagation.cpp (original) +++ llvm/trunk/lib/Analysis/SparsePropagation.cpp Mon Jul 6 17:37:39 2009 @@ -17,6 +17,7 @@ #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/Support/Debug.h" using namespace llvm; @@ -153,7 +154,7 @@ } // Constant condition variables mean the branch can only go a single way - Succs[C == ConstantInt::getFalse()] = true; + Succs[C == Context->getConstantIntFalse()] = true; return; } Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Jul 6 17:37:39 2009 @@ -17,6 +17,7 @@ #include "llvm/Instructions.h" #include "llvm/GlobalVariable.h" #include "llvm/IntrinsicInst.h" +#include "llvm/LLVMContext.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/MathExtras.h" @@ -834,6 +835,7 @@ Value *BuildSubAggregate(Value *From, Value* To, const Type *IndexedType, SmallVector &Idxs, unsigned IdxSkip, + LLVMContext* Context, Instruction *InsertBefore) { const llvm::StructType *STy = llvm::dyn_cast(IndexedType); if (STy) { @@ -845,7 +847,7 @@ Idxs.push_back(i); Value *PrevTo = To; To = BuildSubAggregate(From, To, STy->getElementType(i), Idxs, IdxSkip, - InsertBefore); + Context, InsertBefore); Idxs.pop_back(); if (!To) { // Couldn't find any inserted value for this index? Cleanup @@ -868,7 +870,7 @@ // we might be able to find the complete struct somewhere. // Find the value that is at that particular spot - Value *V = FindInsertedValue(From, Idxs.begin(), Idxs.end()); + Value *V = FindInsertedValue(From, Idxs.begin(), Idxs.end(), Context); if (!V) return NULL; @@ -891,16 +893,18 @@ // // All inserted insertvalue instructions are inserted before InsertBefore Value *BuildSubAggregate(Value *From, const unsigned *idx_begin, - const unsigned *idx_end, Instruction *InsertBefore) { + const unsigned *idx_end, LLVMContext *Context, + Instruction *InsertBefore) { assert(InsertBefore && "Must have someplace to insert!"); const Type *IndexedType = ExtractValueInst::getIndexedType(From->getType(), idx_begin, idx_end); - Value *To = UndefValue::get(IndexedType); + Value *To = Context->getUndef(IndexedType); SmallVector Idxs(idx_begin, idx_end); unsigned IdxSkip = Idxs.size(); - return BuildSubAggregate(From, To, IndexedType, Idxs, IdxSkip, InsertBefore); + return BuildSubAggregate(From, To, IndexedType, Idxs, IdxSkip, + Context, InsertBefore); } /// FindInsertedValue - Given an aggregrate and an sequence of indices, see if @@ -910,7 +914,8 @@ /// If InsertBefore is not null, this function will duplicate (modified) /// insertvalues when a part of a nested struct is extracted. Value *llvm::FindInsertedValue(Value *V, const unsigned *idx_begin, - const unsigned *idx_end, Instruction *InsertBefore) { + const unsigned *idx_end, LLVMContext* Context, + Instruction *InsertBefore) { // Nothing to index? Just return V then (this is useful at the end of our // recursion) if (idx_begin == idx_end) @@ -921,20 +926,20 @@ assert(ExtractValueInst::getIndexedType(V->getType(), idx_begin, idx_end) && "Invalid indices for type?"); const CompositeType *PTy = cast(V->getType()); - + if (isa(V)) - return UndefValue::get(ExtractValueInst::getIndexedType(PTy, + return Context->getUndef(ExtractValueInst::getIndexedType(PTy, idx_begin, idx_end)); else if (isa(V)) - return Constant::getNullValue(ExtractValueInst::getIndexedType(PTy, - idx_begin, - idx_end)); + return Context->getNullValue(ExtractValueInst::getIndexedType(PTy, + idx_begin, + idx_end)); else if (Constant *C = dyn_cast(V)) { if (isa(C) || isa(C)) // Recursively process this constant - return FindInsertedValue(C->getOperand(*idx_begin), idx_begin + 1, idx_end, - InsertBefore); + return FindInsertedValue(C->getOperand(*idx_begin), idx_begin + 1, + idx_end, Context, InsertBefore); } else if (InsertValueInst *I = dyn_cast(V)) { // Loop the indices for the insertvalue instruction in parallel with the // requested indices @@ -953,7 +958,8 @@ // %C = insertvalue {i32, i32 } %A, i32 11, 1 // which allows the unused 0,0 element from the nested struct to be // removed. - return BuildSubAggregate(V, idx_begin, req_idx, InsertBefore); + return BuildSubAggregate(V, idx_begin, req_idx, + Context, InsertBefore); else // We can't handle this without inserting insertvalues return 0; @@ -964,13 +970,13 @@ // looking for, then. if (*req_idx != *i) return FindInsertedValue(I->getAggregateOperand(), idx_begin, idx_end, - InsertBefore); + Context, InsertBefore); } // If we end up here, the indices of the insertvalue match with those // requested (though possibly only partially). Now we recursively look at // the inserted value, passing any remaining indices. return FindInsertedValue(I->getInsertedValueOperand(), req_idx, idx_end, - InsertBefore); + Context, InsertBefore); } else if (ExtractValueInst *I = dyn_cast(V)) { // If we're extracting a value from an aggregrate that was extracted from // something else, we can extract from that something else directly instead. @@ -994,7 +1000,7 @@ && "Number of indices added not correct?"); return FindInsertedValue(I->getAggregateOperand(), Idxs.begin(), Idxs.end(), - InsertBefore); + Context, InsertBefore); } // Otherwise, we don't know (such as, extracting from a function return value // or load instruction) Modified: llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp Mon Jul 6 17:37:39 2009 @@ -183,7 +183,7 @@ if (!STy) V = RI->getOperand(i); else - V = FindInsertedValue(RI->getOperand(0), i); + V = FindInsertedValue(RI->getOperand(0), i, Context); if (V) { // Ignore undefs, we can change them into anything Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=74873&r1=74872&r2=74873&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Jul 6 17:37:39 2009 @@ -642,7 +642,7 @@ DenseMap, LatticeVal>::iterator It = TrackedMultipleRetVals.find(std::make_pair(F, i)); if (It == TrackedMultipleRetVals.end()) break; - if (Value *Val = FindInsertedValue(I.getOperand(0), i)) + if (Value *Val = FindInsertedValue(I.getOperand(0), i, Context)) mergeInValue(It->second, F, getValueState(Val)); } } From isanbard at gmail.com Mon Jul 6 17:59:40 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 6 Jul 2009 15:59:40 -0700 Subject: [llvm-commits] [llvm] r74829 - /llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp In-Reply-To: <200907061536.n66FaOBo026070@zion.cs.uiuc.edu> References: <200907061536.n66FaOBo026070@zion.cs.uiuc.edu> Message-ID: <16e5fdf90907061559v4bc0be72o705cd41156820ad1@mail.gmail.com> Thanks, Stuart! -bw On Mon, Jul 6, 2009 at 8:36 AM, Stuart Hastings wrote: > Author: stuart > Date: Mon Jul ?6 10:36:23 2009 > New Revision: 74829 > > URL: http://llvm.org/viewvc/llvm-project?rev=74829&view=rev > Log: > Mark this test as Darwin only. ?Patch by Bill Wendling. > > Modified: > ? ?llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp > > Modified: llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2009-06-30-ByrefBlock.cpp?rev=74829&r1=74828&r2=74829&view=diff > > ============================================================================== > --- llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp (original) > +++ llvm/trunk/test/FrontendC++/2009-06-30-ByrefBlock.cpp Mon Jul ?6 10:36:23 2009 > @@ -1,6 +1,9 @@ > -// Insure __block_holder_tmp is allocated on the stack. > +// Insure __block_holder_tmp is allocated on the stack. ?Darwin only. > ?// RUN: %llvmgxx %s -S -O2 -o - | egrep {__block_holder_tmp.*alloca} > +// XFAIL: * > +// XTARGET: darwin > ?// > +// END. > ?extern void fubar_dispatch_sync(void (^PP)(void)); > ?void fubar() { > ? __block void *voodoo; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From resistor at mac.com Mon Jul 6 18:00:20 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 06 Jul 2009 23:00:20 -0000 Subject: [llvm-commits] [llvm] r74878 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ include/llvm/Support/ include/llvm/Transforms/Utils/ lib/Analysis/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ Message-ID: <200907062300.n66N0M8g007987@zion.cs.uiuc.edu> Author: resistor Date: Mon Jul 6 18:00:19 2009 New Revision: 74878 URL: http://llvm.org/viewvc/llvm-project?rev=74878&view=rev Log: "LLVMContext* " --> "LLVMContext *" Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/include/llvm/Analysis/SparsePropagation.h llvm/trunk/include/llvm/BasicBlock.h llvm/trunk/include/llvm/Function.h llvm/trunk/include/llvm/Pass.h llvm/trunk/include/llvm/Support/TargetFolder.h llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Analysis/ValueTracking.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp llvm/trunk/lib/Transforms/Utils/Local.cpp llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp llvm/trunk/lib/VMCore/BasicBlock.cpp llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ConstantFolding.h?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ConstantFolding.h (original) +++ llvm/trunk/include/llvm/Analysis/ConstantFolding.h Mon Jul 6 18:00:19 2009 @@ -29,13 +29,13 @@ /// is returned. Note that this function can only fail when attempting to fold /// instructions like loads and stores, which have no constant expression form. /// -Constant *ConstantFoldInstruction(Instruction *I, LLVMContext* Context, +Constant *ConstantFoldInstruction(Instruction *I, LLVMContext *Context, const TargetData *TD = 0); /// ConstantFoldConstantExpression - Attempt to fold the constant expression /// using the specified TargetData. If successful, the constant result is /// result is returned, if not, null is returned. -Constant *ConstantFoldConstantExpression(ConstantExpr *CE, LLVMContext* Context, +Constant *ConstantFoldConstantExpression(ConstantExpr *CE, LLVMContext *Context, const TargetData *TD = 0); /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the @@ -46,7 +46,7 @@ /// Constant *ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, Constant*const * Ops, unsigned NumOps, - LLVMContext* Context, + LLVMContext *Context, const TargetData *TD = 0); /// ConstantFoldCompareInstOperands - Attempt to constant fold a compare @@ -55,7 +55,7 @@ /// Constant *ConstantFoldCompareInstOperands(unsigned Predicate, Constant*const * Ops, unsigned NumOps, - LLVMContext* Context, + LLVMContext *Context, const TargetData *TD = 0); @@ -63,7 +63,7 @@ /// getelementptr constantexpr, return the constant value being addressed by the /// constant expression, or null if something is funny and we can't decide. Constant *ConstantFoldLoadThroughGEPConstantExpr(Constant *C, ConstantExpr *CE, - LLVMContext* Context); + LLVMContext *Context); /// canConstantFoldCallTo - Return true if its even possible to fold a call to /// the specified function. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon Jul 6 18:00:19 2009 @@ -355,7 +355,7 @@ static char ID; // Pass identification, replacement for typeid ScalarEvolution(); - LLVMContext* getContext() const { return Context; } + LLVMContext *getContext() const { return Context; } /// isSCEVable - Test if values of the given type are analyzable within /// the SCEV framework. This primarily includes integer types, and it Modified: llvm/trunk/include/llvm/Analysis/SparsePropagation.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/SparsePropagation.h?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/SparsePropagation.h (original) +++ llvm/trunk/include/llvm/Analysis/SparsePropagation.h Mon Jul 6 18:00:19 2009 @@ -131,7 +131,7 @@ SparseSolver(const SparseSolver&); // DO NOT IMPLEMENT void operator=(const SparseSolver&); // DO NOT IMPLEMENT public: - explicit SparseSolver(AbstractLatticeFunction *Lattice, LLVMContext* C) + explicit SparseSolver(AbstractLatticeFunction *Lattice, LLVMContext *C) : LatticeFunc(Lattice), Context(C) {} ~SparseSolver() { delete LatticeFunc; Modified: llvm/trunk/include/llvm/BasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/include/llvm/BasicBlock.h (original) +++ llvm/trunk/include/llvm/BasicBlock.h Mon Jul 6 18:00:19 2009 @@ -88,7 +88,7 @@ public: /// getContext - Get the context in which this basic block lives, /// or null if it is not currently attached to a function. - LLVMContext* getContext() const; + LLVMContext *getContext() const; /// Instruction iterators... typedef InstListType::iterator iterator; Modified: llvm/trunk/include/llvm/Function.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/include/llvm/Function.h (original) +++ llvm/trunk/include/llvm/Function.h Mon Jul 6 18:00:19 2009 @@ -129,7 +129,7 @@ /// getContext - Return a pointer to the LLVMContext associated with this /// function, or NULL if this function is not bound to a context yet. - LLVMContext* getContext() const; + LLVMContext *getContext() const; /// isVarArg - Return true if this function takes a variable number of /// arguments. Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Mon Jul 6 18:00:19 2009 @@ -79,7 +79,7 @@ Pass(const Pass &); // DO NOT IMPLEMENT protected: - LLVMContext* Context; + LLVMContext *Context; public: explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) { Modified: llvm/trunk/include/llvm/Support/TargetFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetFolder.h (original) +++ llvm/trunk/include/llvm/Support/TargetFolder.h Mon Jul 6 18:00:19 2009 @@ -30,7 +30,7 @@ /// TargetFolder - Create constants with target dependent folding. class TargetFolder { const TargetData *TD; - LLVMContext* Context; + LLVMContext *Context; /// Fold - Fold the constant using target specific information. Constant *Fold(Constant *C) const { @@ -41,7 +41,7 @@ } public: - explicit TargetFolder(const TargetData *TheTD, LLVMContext* C) : + explicit TargetFolder(const TargetData *TheTD, LLVMContext *C) : TD(TheTD), Context(C) {} //===--------------------------------------------------------------------===// Modified: llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h Mon Jul 6 18:00:19 2009 @@ -40,7 +40,7 @@ /// void PromoteMemToReg(const std::vector &Allocas, DominatorTree &DT, DominanceFrontier &DF, - LLVMContext* Context, + LLVMContext *Context, AliasSetTracker *AST = 0); } // End llvm namespace Modified: llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h Mon Jul 6 18:00:19 2009 @@ -23,7 +23,7 @@ class LLVMContext; typedef DenseMap ValueMapTy; - Value *MapValue(const Value *V, ValueMapTy &VM, LLVMContext* Context); + Value *MapValue(const Value *V, ValueMapTy &VM, LLVMContext *Context); void RemapInstruction(Instruction *I, ValueMapTy &VM); } // End llvm namespace Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Mon Jul 6 18:00:19 2009 @@ -499,7 +499,7 @@ // This function is used to determine if the indices of two GEP instructions are // equal. V1 and V2 are the indices. -static bool IndexOperandsEqual(Value *V1, Value *V2, LLVMContext* Context) { +static bool IndexOperandsEqual(Value *V1, Value *V2, LLVMContext *Context) { if (V1->getType() == V2->getType()) return V1 == V2; if (Constant *C1 = dyn_cast(V1)) Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Mon Jul 6 18:00:19 2009 @@ -94,7 +94,7 @@ /// otherwise TD is null. static Constant *SymbolicallyEvaluateBinop(unsigned Opc, Constant *Op0, Constant *Op1, const TargetData *TD, - LLVMContext* Context){ + LLVMContext *Context){ // SROA // Fold (and 0xffffffff00000000, (shl x, 32)) -> shl. @@ -123,7 +123,7 @@ /// constant expression, do so. static Constant *SymbolicallyEvaluateGEP(Constant* const* Ops, unsigned NumOps, const Type *ResultTy, - LLVMContext* Context, + LLVMContext *Context, const TargetData *TD) { Constant *Ptr = Ops[0]; if (!TD || !cast(Ptr->getType())->getElementType()->isSized()) @@ -157,7 +157,7 @@ /// FoldBitCast - Constant fold bitcast, symbolically evaluating it with /// targetdata. Return 0 if unfoldable. static Constant *FoldBitCast(Constant *C, const Type *DestTy, - const TargetData &TD, LLVMContext* Context) { + const TargetData &TD, LLVMContext *Context) { // If this is a bitcast from constant vector -> vector, fold it. if (ConstantVector *CV = dyn_cast(C)) { if (const VectorType *DestVTy = dyn_cast(DestTy)) { @@ -281,7 +281,7 @@ /// is returned. Note that this function can only fail when attempting to fold /// instructions like loads and stores, which have no constant expression form. /// -Constant *llvm::ConstantFoldInstruction(Instruction *I, LLVMContext* Context, +Constant *llvm::ConstantFoldInstruction(Instruction *I, LLVMContext *Context, const TargetData *TD) { if (PHINode *PN = dyn_cast(I)) { if (PN->getNumIncomingValues() == 0) @@ -321,7 +321,7 @@ /// using the specified TargetData. If successful, the constant result is /// result is returned, if not, null is returned. Constant *llvm::ConstantFoldConstantExpression(ConstantExpr *CE, - LLVMContext* Context, + LLVMContext *Context, const TargetData *TD) { SmallVector Ops; for (User::op_iterator i = CE->op_begin(), e = CE->op_end(); i != e; ++i) @@ -344,7 +344,7 @@ /// Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, Constant* const* Ops, unsigned NumOps, - LLVMContext* Context, + LLVMContext *Context, const TargetData *TD) { // Handle easy binops first. if (Instruction::isBinaryOp(Opcode)) { @@ -470,7 +470,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate, Constant*const * Ops, unsigned NumOps, - LLVMContext* Context, + LLVMContext *Context, const TargetData *TD) { // fold: icmp (inttoptr x), null -> icmp x, 0 // fold: icmp (ptrtoint x), 0 -> icmp x, null @@ -543,7 +543,7 @@ /// constant expression, or null if something is funny and we can't decide. Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, ConstantExpr *CE, - LLVMContext* Context) { + LLVMContext *Context) { if (CE->getOperand(1) != Context->getNullValue(CE->getOperand(1)->getType())) return 0; // Do not allow stepping over the value! @@ -680,7 +680,7 @@ } static Constant *ConstantFoldFP(double (*NativeFP)(double), double V, - const Type *Ty, LLVMContext* Context) { + const Type *Ty, LLVMContext *Context) { errno = 0; V = NativeFP(V); if (errno != 0) { @@ -699,7 +699,7 @@ static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double), double V, double W, const Type *Ty, - LLVMContext* Context) { + LLVMContext *Context) { errno = 0; V = NativeFP(V, W); if (errno != 0) { @@ -722,7 +722,7 @@ llvm::ConstantFoldCall(Function *F, Constant* const* Operands, unsigned NumOperands) { if (!F->hasName()) return 0; - LLVMContext* Context = F->getContext(); + LLVMContext *Context = F->getContext(); const char *Str = F->getNameStart(); unsigned Len = F->getNameLen(); Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jul 6 18:00:19 2009 @@ -3421,7 +3421,7 @@ if (Constant *C = dyn_cast(V)) return C; if (GlobalValue *GV = dyn_cast(V)) return GV; Instruction *I = cast(V); - LLVMContext* Context = I->getParent()->getContext(); + LLVMContext *Context = I->getParent()->getContext(); std::vector Operands; Operands.resize(I->getNumOperands()); Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Jul 6 18:00:19 2009 @@ -835,7 +835,7 @@ Value *BuildSubAggregate(Value *From, Value* To, const Type *IndexedType, SmallVector &Idxs, unsigned IdxSkip, - LLVMContext* Context, + LLVMContext *Context, Instruction *InsertBefore) { const llvm::StructType *STy = llvm::dyn_cast(IndexedType); if (STy) { @@ -914,7 +914,7 @@ /// If InsertBefore is not null, this function will duplicate (modified) /// insertvalues when a part of a nested struct is extracted. Value *llvm::FindInsertedValue(Value *V, const unsigned *idx_begin, - const unsigned *idx_end, LLVMContext* Context, + const unsigned *idx_end, LLVMContext *Context, Instruction *InsertBefore) { // Nothing to index? Just return V then (this is useful at the end of our // recursion) Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Jul 6 18:00:19 2009 @@ -246,7 +246,7 @@ } static Constant *getAggregateConstantElement(Constant *Agg, Constant *Idx, - LLVMContext* Context) { + LLVMContext *Context) { ConstantInt *CI = dyn_cast(Idx); if (!CI) return 0; unsigned IdxV = CI->getZExtValue(); @@ -283,7 +283,7 @@ /// quick scan over the use list to clean up the easy and obvious cruft. This /// returns true if it made a change. static bool CleanupConstantGlobalUsers(Value *V, Constant *Init, - LLVMContext* Context) { + LLVMContext *Context) { bool Changed = false; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;) { User *U = *UI++; @@ -465,7 +465,7 @@ /// this transformation is safe already. We return the first global variable we /// insert so that the caller can reprocess it. static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD, - LLVMContext* Context) { + LLVMContext *Context) { // Make sure this global only has simple uses that we can SRA. if (!GlobalUsersSafeToSRA(GV)) return 0; @@ -674,7 +674,7 @@ } static bool OptimizeAwayTrappingUsesOfValue(Value *V, Constant *NewV, - LLVMContext* Context) { + LLVMContext *Context) { bool Changed = false; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ) { Instruction *I = cast(*UI++); @@ -742,7 +742,7 @@ /// if the loaded value is dynamically null, then we know that they cannot be /// reachable with a null optimize away the load. static bool OptimizeAwayTrappingUsesOfLoads(GlobalVariable *GV, Constant *LV, - LLVMContext* Context) { + LLVMContext *Context) { bool Changed = false; // Keep track of whether we are able to remove all the uses of the global @@ -796,7 +796,7 @@ /// ConstantPropUsersOf - Walk the use list of V, constant folding all of the /// instructions that are foldable. -static void ConstantPropUsersOf(Value *V, LLVMContext* Context) { +static void ConstantPropUsersOf(Value *V, LLVMContext *Context) { for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ) if (Instruction *I = dyn_cast(*UI++)) if (Constant *NewC = ConstantFoldInstruction(I, Context)) { @@ -817,7 +817,7 @@ /// malloc into a global, and any loads of GV as uses of the new global. static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, MallocInst *MI, - LLVMContext* Context) { + LLVMContext *Context) { DOUT << "PROMOTING MALLOC GLOBAL: " << *GV << " MALLOC = " << *MI; ConstantInt *NElements = cast(MI->getArraySize()); @@ -1131,7 +1131,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo, DenseMap > &InsertedScalarizedValues, std::vector > &PHIsToRewrite, - LLVMContext* Context) { + LLVMContext *Context) { std::vector &FieldVals = InsertedScalarizedValues[V]; if (FieldNo >= FieldVals.size()) @@ -1174,7 +1174,7 @@ static void RewriteHeapSROALoadUser(Instruction *LoadUser, DenseMap > &InsertedScalarizedValues, std::vector > &PHIsToRewrite, - LLVMContext* Context) { + LLVMContext *Context) { // If this is a comparison against null, handle it. if (ICmpInst *SCI = dyn_cast(LoadUser)) { assert(isa(SCI->getOperand(1))); @@ -1245,7 +1245,7 @@ static void RewriteUsesOfLoadForHeapSRoA(LoadInst *Load, DenseMap > &InsertedScalarizedValues, std::vector > &PHIsToRewrite, - LLVMContext* Context) { + LLVMContext *Context) { for (Value::use_iterator UI = Load->use_begin(), E = Load->use_end(); UI != E; ) { Instruction *User = cast(*UI++); @@ -1262,7 +1262,7 @@ /// PerformHeapAllocSRoA - MI is an allocation of an array of structures. Break /// it up into multiple allocations of arrays of the fields. static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI, - LLVMContext* Context){ + LLVMContext *Context){ DOUT << "SROA HEAP ALLOC: " << *GV << " MALLOC = " << *MI; const StructType *STy = cast(MI->getAllocatedType()); @@ -1442,7 +1442,7 @@ MallocInst *MI, Module::global_iterator &GVI, TargetData &TD, - LLVMContext* Context) { + LLVMContext *Context) { // If this is a malloc of an abstract type, don't touch it. if (!MI->getAllocatedType()->isSized()) return false; @@ -1526,7 +1526,7 @@ // that only one value (besides its initializer) is ever stored to the global. static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal, Module::global_iterator &GVI, - TargetData &TD, LLVMContext* Context) { + TargetData &TD, LLVMContext *Context) { // Ignore no-op GEPs and bitcasts. StoredOnceVal = StoredOnceVal->stripPointerCasts(); @@ -1558,7 +1558,7 @@ /// can shrink the global into a boolean and select between the two values /// whenever it is used. This exposes the values to other scalar optimizations. static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal, - LLVMContext* Context) { + LLVMContext *Context) { const Type *GVElType = GV->getType()->getElementType(); // If GVElType is already i1, it is already shrunk. If the type of the GV is @@ -1941,7 +1941,7 @@ /// specified array, returning the new global to use. static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, const std::vector &Ctors, - LLVMContext* Context) { + LLVMContext *Context) { // If we made a change, reassemble the initializer list. std::vector CSVals; CSVals.push_back(Context->getConstantInt(Type::Int32Ty, 65535)); @@ -2009,7 +2009,7 @@ /// enough for us to understand. In particular, if it is a cast of something, /// we punt. We basically just support direct accesses to globals and GEP's of /// globals. This should be kept up to date with CommitValueTo. -static bool isSimpleEnoughPointerToCommit(Constant *C, LLVMContext* Context) { +static bool isSimpleEnoughPointerToCommit(Constant *C, LLVMContext *Context) { if (GlobalVariable *GV = dyn_cast(C)) { if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage()) return false; // do not allow weak/linkonce/dllimport/dllexport linkage. @@ -2034,7 +2034,7 @@ /// At this point, the GEP operands of Addr [0, OpNo) have been stepped into. static Constant *EvaluateStoreInto(Constant *Init, Constant *Val, ConstantExpr *Addr, unsigned OpNo, - LLVMContext* Context) { + LLVMContext *Context) { // Base case of the recursion. if (OpNo == Addr->getNumOperands()) { assert(Val->getType() == Init->getType() && "Type mismatch!"); @@ -2097,7 +2097,7 @@ /// CommitValueTo - We have decided that Addr (which satisfies the predicate /// isSimpleEnoughPointerToCommit) should get Val as its value. Make it happen. static void CommitValueTo(Constant *Val, Constant *Addr, - LLVMContext* Context) { + LLVMContext *Context) { if (GlobalVariable *GV = dyn_cast(Addr)) { assert(GV->hasInitializer()); GV->setInitializer(Val); @@ -2117,7 +2117,7 @@ /// decide, return null. static Constant *ComputeLoadResult(Constant *P, const DenseMap &Memory, - LLVMContext* Context) { + LLVMContext *Context) { // If this memory location has been recently stored, use the stored value: it // is the most up-to-date. DenseMap::const_iterator I = Memory.find(P); @@ -2156,7 +2156,7 @@ if (std::find(CallStack.begin(), CallStack.end(), F) != CallStack.end()) return false; - LLVMContext* Context = F->getContext(); + LLVMContext *Context = F->getContext(); CallStack.push_back(F); Modified: llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp Mon Jul 6 18:00:19 2009 @@ -23,7 +23,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, GlobalValue *Array) { - LLVMContext* Context = MainFn->getContext(); + LLVMContext *Context = MainFn->getContext(); const Type *ArgVTy = Context->getPointerTypeUnqual(Context->getPointerTypeUnqual(Type::Int8Ty)); const PointerType *UIntPtr = Context->getPointerTypeUnqual(Type::Int32Ty); @@ -101,7 +101,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, GlobalValue *CounterArray) { - LLVMContext* Context = BB->getContext(); + LLVMContext *Context = BB->getContext(); // Insert the increment after any alloca or PHI instructions... BasicBlock::iterator InsertPos = BB->getFirstNonPHI(); Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Mon Jul 6 18:00:19 2009 @@ -208,7 +208,7 @@ void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) { BranchInst* t = cast(bb->getTerminator()); - LLVMContext* Context = bb->getContext(); + LLVMContext *Context = bb->getContext(); //decrement counter LoadInst* l = new LoadInst(Counter, "counter", t); @@ -282,7 +282,7 @@ void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) { BranchInst* t = cast(bb->getTerminator()); - LLVMContext* Context = bb->getContext(); + LLVMContext *Context = bb->getContext(); //decrement counter LoadInst* l = new LoadInst(AI, "counter", t); @@ -317,7 +317,7 @@ void CycleCounter::ProcessChoicePoint(BasicBlock* bb) { BranchInst* t = cast(bb->getTerminator()); - LLVMContext* Context = bb->getContext(); + LLVMContext *Context = bb->getContext(); CallInst* c = CallInst::Create(F, "rdcc", t); BinaryOperator* b = Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jul 6 18:00:19 2009 @@ -83,7 +83,7 @@ static char ID; // Pass identification, replacement for typeid InstCombiner() : FunctionPass(&ID) {} - LLVMContext* getContext() { return Context; } + LLVMContext *getContext() { return Context; } /// AddToWorkList - Add the specified instruction to the worklist if it /// isn't already in it. @@ -568,7 +568,7 @@ // dyn_castNegVal - Given a 'sub' instruction, return the RHS of the instruction // if the LHS is a constant zero (which is the 'negate' form). // -static inline Value *dyn_castNegVal(Value *V, LLVMContext* Context) { +static inline Value *dyn_castNegVal(Value *V, LLVMContext *Context) { if (BinaryOperator::isNeg(V)) return BinaryOperator::getNegArgument(V); @@ -587,7 +587,7 @@ // instruction if the LHS is a constant negative zero (which is the 'negate' // form). // -static inline Value *dyn_castFNegVal(Value *V, LLVMContext* Context) { +static inline Value *dyn_castFNegVal(Value *V, LLVMContext *Context) { if (BinaryOperator::isFNeg(V)) return BinaryOperator::getFNegArgument(V); @@ -602,7 +602,7 @@ return 0; } -static inline Value *dyn_castNotVal(Value *V, LLVMContext* Context) { +static inline Value *dyn_castNotVal(Value *V, LLVMContext *Context) { if (BinaryOperator::isNot(V)) return BinaryOperator::getNotArgument(V); @@ -618,7 +618,7 @@ // Otherwise, return null. // static inline Value *dyn_castFoldableMul(Value *V, ConstantInt *&CST, - LLVMContext* Context) { + LLVMContext *Context) { if (V->hasOneUse() && V->getType()->isInteger()) if (Instruction *I = dyn_cast(V)) { if (I->getOpcode() == Instruction::Mul) @@ -658,19 +658,19 @@ } /// AddOne - Add one to a ConstantInt -static Constant *AddOne(Constant *C, LLVMContext* Context) { +static Constant *AddOne(Constant *C, LLVMContext *Context) { return Context->getConstantExprAdd(C, Context->getConstantInt(C->getType(), 1)); } /// SubOne - Subtract one from a ConstantInt -static Constant *SubOne(ConstantInt *C, LLVMContext* Context) { +static Constant *SubOne(ConstantInt *C, LLVMContext *Context) { return Context->getConstantExprSub(C, Context->getConstantInt(C->getType(), 1)); } /// MultiplyOverflows - True if the multiply can not be expressed in an int /// this size. static bool MultiplyOverflows(ConstantInt *C1, ConstantInt *C2, bool sign, - LLVMContext* Context) { + LLVMContext *Context) { uint32_t W = C1->getBitWidth(); APInt LHSExt = C1->getValue(), RHSExt = C2->getValue(); if (sign) { @@ -697,7 +697,7 @@ /// are any bits set in the constant that are not demanded. If so, shrink the /// constant and return true. static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo, - APInt Demanded, LLVMContext* Context) { + APInt Demanded, LLVMContext *Context) { assert(I && "No instruction?"); assert(OpNo < I->getNumOperands() && "Operand index too large"); @@ -1800,7 +1800,7 @@ /// template static Instruction *AssociativeOpt(BinaryOperator &Root, const Functor &F, - LLVMContext* Context) { + LLVMContext *Context) { unsigned Opcode = Root.getOpcode(); Value *LHS = Root.getOperand(0); @@ -1872,8 +1872,8 @@ // AddRHS - Implements: X + X --> X << 1 struct AddRHS { Value *RHS; - LLVMContext* Context; - AddRHS(Value *rhs, LLVMContext* C) : RHS(rhs), Context(C) {} + LLVMContext *Context; + AddRHS(Value *rhs, LLVMContext *C) : RHS(rhs), Context(C) {} bool shouldApply(Value *LHS) const { return LHS == RHS; } Instruction *apply(BinaryOperator &Add) const { return BinaryOperator::CreateShl(Add.getOperand(0), @@ -1885,8 +1885,8 @@ // iff C1&C2 == 0 struct AddMaskingAnd { Constant *C2; - LLVMContext* Context; - AddMaskingAnd(Constant *c, LLVMContext* C) : C2(c), Context(C) {} + LLVMContext *Context; + AddMaskingAnd(Constant *c, LLVMContext *C) : C2(c), Context(C) {} bool shouldApply(Value *LHS) const { ConstantInt *C1; return match(LHS, m_And(m_Value(), m_ConstantInt(C1))) && @@ -1901,7 +1901,7 @@ static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO, InstCombiner *IC) { - LLVMContext* Context = IC->getContext(); + LLVMContext *Context = IC->getContext(); if (CastInst *CI = dyn_cast(&I)) { return IC->InsertCastBefore(CI->getOpcode(), SO, I.getType(), I); @@ -3389,7 +3389,7 @@ /// new ICmp instruction. The sign is passed in to determine which kind /// of predicate to use in the new icmp instruction. static Value *getICmpValue(bool sign, unsigned code, Value *LHS, Value *RHS, - LLVMContext* Context) { + LLVMContext *Context) { switch (code) { default: assert(0 && "Illegal ICmp code!"); case 0: return Context->getConstantIntFalse(); @@ -3423,7 +3423,7 @@ /// opcode and two operands into either a FCmp instruction. isordered is passed /// in to determine which kind of predicate to use in the new fcmp instruction. static Value *getFCmpValue(bool isordered, unsigned code, - Value *LHS, Value *RHS, LLVMContext* Context) { + Value *LHS, Value *RHS, LLVMContext *Context) { switch (code) { default: assert(0 && "Illegal FCmp code!"); case 0: @@ -5271,7 +5271,7 @@ } static ConstantInt *ExtractElement(Constant *V, Constant *Idx, - LLVMContext* Context) { + LLVMContext *Context) { return cast(Context->getConstantExprExtractElement(V, Idx)); } @@ -5290,7 +5290,7 @@ /// AddWithOverflow - Compute Result = In1+In2, returning true if the result /// overflowed for this type. static bool AddWithOverflow(Constant *&Result, Constant *In1, - Constant *In2, LLVMContext* Context, + Constant *In2, LLVMContext *Context, bool IsSigned = false) { Result = Context->getConstantExprAdd(In1, In2); @@ -5326,7 +5326,7 @@ /// SubWithOverflow - Compute Result = In1-In2, returning true if the result /// overflowed for this type. static bool SubWithOverflow(Constant *&Result, Constant *In1, - Constant *In2, LLVMContext* Context, + Constant *In2, LLVMContext *Context, bool IsSigned = false) { Result = Context->getConstantExprSub(In1, In2); @@ -5354,7 +5354,7 @@ TargetData &TD = IC.getTargetData(); gep_type_iterator GTI = gep_type_begin(GEP); const Type *IntPtrTy = TD.getIntPtrType(); - LLVMContext* Context = IC.getContext(); + LLVMContext *Context = IC.getContext(); Value *Result = Context->getNullValue(IntPtrTy); // Build a mask for high order bits. @@ -7718,7 +7718,7 @@ /// X*Scale+Offset. /// static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale, - int &Offset, LLVMContext* Context) { + int &Offset, LLVMContext *Context) { assert(Val->getType() == Type::Int32Ty && "Unexpected allocation size type!"); if (ConstantInt *CI = dyn_cast(Val)) { Offset = CI->getZExtValue(); @@ -8089,7 +8089,7 @@ static const Type *FindElementAtOffset(const Type *Ty, int64_t Offset, SmallVectorImpl &NewIndices, const TargetData *TD, - LLVMContext* Context) { + LLVMContext *Context) { if (!Ty->isSized()) return 0; // Start with the index over the outer type. Note that the type size @@ -8742,7 +8742,7 @@ /// FitsInFPType - Return a Constant* for the specified FP constant if it fits /// in the specified FP type without changing its value. static Constant *FitsInFPType(ConstantFP *CFP, const fltSemantics &Sem, - LLVMContext* Context) { + LLVMContext *Context) { bool losesInfo; APFloat F = CFP->getValueAPF(); (void)F.convert(Sem, APFloat::rmNearestTiesToEven, &losesInfo); @@ -8753,7 +8753,7 @@ /// LookThroughFPExtensions - If this is an fp extension instruction, look /// through it until we get the source value. -static Value *LookThroughFPExtensions(Value *V, LLVMContext* Context) { +static Value *LookThroughFPExtensions(Value *V, LLVMContext *Context) { if (Instruction *I = dyn_cast(V)) if (I->getOpcode() == Instruction::FPExt) return LookThroughFPExtensions(I->getOperand(0), Context); @@ -9076,7 +9076,7 @@ /// GetSelectFoldableConstant - For the same transformation as the previous /// function, return the identity constant that goes into the select. static Constant *GetSelectFoldableConstant(Instruction *I, - LLVMContext* Context) { + LLVMContext *Context) { switch (I->getOpcode()) { default: assert(0 && "This cannot happen!"); abort(); case Instruction::Add: @@ -11450,7 +11450,7 @@ const TargetData *TD) { User *CI = cast(LI.getOperand(0)); Value *CastOp = CI->getOperand(0); - LLVMContext* Context = IC.getContext(); + LLVMContext *Context = IC.getContext(); if (TD) { if (ConstantExpr *CE = dyn_cast(CI)) { @@ -11675,7 +11675,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { User *CI = cast(SI.getOperand(1)); Value *CastOp = CI->getOperand(0); - LLVMContext* Context = IC.getContext(); + LLVMContext *Context = IC.getContext(); const Type *DestPTy = cast(CI->getType())->getElementType(); const PointerType *SrcTy = dyn_cast(CastOp->getType()); @@ -12304,7 +12304,7 @@ /// value is already around as a register, for example if it were inserted then /// extracted from the vector. static Value *FindScalarElement(Value *V, unsigned EltNo, - LLVMContext* Context) { + LLVMContext *Context) { assert(isa(V->getType()) && "Not looking at a vector?"); const VectorType *PTy = cast(V->getType()); unsigned Width = PTy->getNumElements(); @@ -12480,7 +12480,7 @@ /// Otherwise, return false. static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS, std::vector &Mask, - LLVMContext* Context) { + LLVMContext *Context) { assert(V->getType() == LHS->getType() && V->getType() == RHS->getType() && "Invalid CollectSingleShuffleElements"); unsigned NumElts = cast(V->getType())->getNumElements(); @@ -12550,7 +12550,7 @@ /// RHS of the shuffle instruction, if it is not null. Return a shuffle mask /// that computes V and the LHS value of the shuffle. static Value *CollectShuffleElements(Value *V, std::vector &Mask, - Value *&RHS, LLVMContext* Context) { + Value *&RHS, LLVMContext *Context) { assert(isa(V->getType()) && (RHS == 0 || V->getType() == RHS->getType()) && "Invalid shuffle!"); Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Jul 6 18:00:19 2009 @@ -795,7 +795,7 @@ /// result can not be determined, a null pointer is returned. static Constant *GetResultOfComparison(CmpInst::Predicate pred, Value *LHS, Value *RHS, - LLVMContext* Context) { + LLVMContext *Context) { if (Constant *CLHS = dyn_cast(LHS)) if (Constant *CRHS = dyn_cast(RHS)) return Context->getConstantExprCompare(pred, CLHS, CRHS); Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Mon Jul 6 18:00:19 2009 @@ -294,14 +294,14 @@ // Return V+1 static Value *getPlusOne(Value *V, bool Sign, Instruction *InsertPt, - LLVMContext* Context) { + LLVMContext *Context) { Constant *One = Context->getConstantInt(V->getType(), 1, Sign); return BinaryOperator::CreateAdd(V, One, "lsp", InsertPt); } // Return V-1 static Value *getMinusOne(Value *V, bool Sign, Instruction *InsertPt, - LLVMContext* Context) { + LLVMContext *Context) { Constant *One = Context->getConstantInt(V->getType(), 1, Sign); return BinaryOperator::CreateSub(V, One, "lsp", InsertPt); } Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Mon Jul 6 18:00:19 2009 @@ -200,7 +200,7 @@ /// static Instruction *LowerNegateToMultiply(Instruction *Neg, std::map, unsigned> &ValueRankMap, - LLVMContext* Context) { + LLVMContext *Context) { Constant *Cst = Context->getConstantIntAllOnesValue(Neg->getType()); Instruction *Res = BinaryOperator::CreateMul(Neg->getOperand(1), Cst, "",Neg); @@ -458,7 +458,7 @@ /// reassociation. static Instruction *ConvertShiftToMul(Instruction *Shl, std::map, unsigned> &ValueRankMap, - LLVMContext* Context) { + LLVMContext *Context) { // If an operand of this shift is a reassociable multiply, or if the shift // is used by a reassociable multiply or add, turn into a multiply. if (isReassociableOp(Shl->getOperand(0), Instruction::Mul) || Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Jul 6 18:00:19 2009 @@ -139,7 +139,7 @@ /// Constant Propagation. /// class SCCPSolver : public InstVisitor { - LLVMContext* Context; + LLVMContext *Context; DenseSet BBExecutable;// The basic blocks that are executable std::map ValueState; // The state each value is in. @@ -179,7 +179,7 @@ typedef std::pair Edge; DenseSet KnownFeasibleEdges; public: - void setContext(LLVMContext* C) { Context = C; } + void setContext(LLVMContext *C) { Context = C; } /// MarkBlockExecutable - This method can be used by clients to mark all of /// the blocks that are known to be intrinsically live in the processed unit. Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Mon Jul 6 18:00:19 2009 @@ -1261,7 +1261,7 @@ /// and stores would mutate the memory. static void MergeInType(const Type *In, uint64_t Offset, const Type *&VecTy, unsigned AllocaSize, const TargetData &TD, - LLVMContext* Context) { + LLVMContext *Context) { // If this could be contributing to a vector, analyze it. if (VecTy != Type::VoidTy) { // either null or a vector type. Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp Mon Jul 6 18:00:19 2009 @@ -58,7 +58,7 @@ /// ChangeToUnreachable - Insert an unreachable instruction before the specified /// instruction, making it and the rest of the code in the block dead. -static void ChangeToUnreachable(Instruction *I, LLVMContext* Context) { +static void ChangeToUnreachable(Instruction *I, LLVMContext *Context) { BasicBlock *BB = I->getParent(); // Loop over all of the successors, removing BB's entry from any PHI // nodes. @@ -97,7 +97,7 @@ static bool MarkAliveBlocks(BasicBlock *BB, SmallPtrSet &Reachable, - LLVMContext* Context) { + LLVMContext *Context) { SmallVector Worklist; Worklist.push_back(BB); Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Mon Jul 6 18:00:19 2009 @@ -325,7 +325,7 @@ /// mapping its operands through ValueMap if they are available. Constant *PruningFunctionCloner:: ConstantFoldMappedInstruction(const Instruction *I) { - LLVMContext* Context = I->getParent()->getContext(); + LLVMContext *Context = I->getParent()->getContext(); SmallVector Ops; for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) @@ -367,7 +367,7 @@ ClonedCodeInfo *CodeInfo, const TargetData *TD) { assert(NameSuffix && "NameSuffix cannot be null!"); - LLVMContext* Context = OldFunc->getContext(); + LLVMContext *Context = OldFunc->getContext(); #ifndef NDEBUG for (Function::const_arg_iterator II = OldFunc->arg_begin(), Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Jul 6 18:00:19 2009 @@ -238,7 +238,7 @@ DOUT << "inputs: " << inputs.size() << "\n"; DOUT << "outputs: " << outputs.size() << "\n"; - LLVMContext* Context = header->getContext(); + LLVMContext *Context = header->getContext(); // This function returns unsigned, outputs will go back by reference. switch (NumExitBlocks) { @@ -352,7 +352,7 @@ void CodeExtractor:: emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, Values &inputs, Values &outputs) { - LLVMContext* Context = codeReplacer->getContext(); + LLVMContext *Context = codeReplacer->getContext(); // Emit a call to the new function, passing in: *pointer to struct (if // aggregating parameters), or plan inputs and allocated memory for outputs Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Mon Jul 6 18:00:19 2009 @@ -263,7 +263,7 @@ /// too, recursively. void llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) { - LLVMContext* Context = PN->getParent()->getContext(); + LLVMContext *Context = PN->getParent()->getContext(); // We can remove a PHI if it is on a cycle in the def-use graph // where each node in the cycle has degree one, i.e. only one use, Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Mon Jul 6 18:00:19 2009 @@ -183,7 +183,7 @@ /// AliasSetTracker *AST; - LLVMContext* Context; + LLVMContext *Context; /// AllocaLookup - Reverse mapping of Allocas. /// @@ -216,7 +216,7 @@ public: PromoteMem2Reg(const std::vector &A, DominatorTree &dt, DominanceFrontier &df, AliasSetTracker *ast, - LLVMContext* C) + LLVMContext *C) : Allocas(A), DT(dt), DF(df), AST(ast), Context(C) {} void run(); @@ -999,7 +999,7 @@ /// void llvm::PromoteMemToReg(const std::vector &Allocas, DominatorTree &DT, DominanceFrontier &DF, - LLVMContext* Context, AliasSetTracker *AST) { + LLVMContext *Context, AliasSetTracker *AST) { // If there is nothing to do, bail out... if (Allocas.empty()) return; Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Jul 6 18:00:19 2009 @@ -1178,7 +1178,7 @@ /// ultimate destination. static bool FoldCondBranchOnPHI(BranchInst *BI) { BasicBlock *BB = BI->getParent(); - LLVMContext* Context = BB->getContext(); + LLVMContext *Context = BB->getContext(); PHINode *PN = dyn_cast(BI->getCondition()); // NOTE: we currently cannot transform this case if the PHI node is used // outside of the block. @@ -1276,7 +1276,7 @@ /// FoldTwoEntryPHINode - Given a BB that starts with the specified two-entry /// PHI node, see if we can eliminate it. static bool FoldTwoEntryPHINode(PHINode *PN) { - LLVMContext* Context = PN->getParent()->getContext(); + LLVMContext *Context = PN->getParent()->getContext(); // Ok, this is a two entry PHI node. Check to see if this is a simple "if // statement", which has a very simple dominance structure. Basically, we @@ -1609,7 +1609,7 @@ static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) { assert(PBI->isConditional() && BI->isConditional()); BasicBlock *BB = BI->getParent(); - LLVMContext* Context = BB->getContext(); + LLVMContext *Context = BB->getContext(); // If this block ends with a branch instruction, and if there is a // predecessor that ends on a branch of the same condition, make Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Mon Jul 6 18:00:19 2009 @@ -22,7 +22,7 @@ #include "llvm/ADT/SmallVector.h" using namespace llvm; -Value *llvm::MapValue(const Value *V, ValueMapTy &VM, LLVMContext* Context) { +Value *llvm::MapValue(const Value *V, ValueMapTy &VM, LLVMContext *Context) { Value *&VMSlot = VM[V]; if (VMSlot) return VMSlot; // Does it exist in the map yet? Modified: llvm/trunk/lib/VMCore/BasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/BasicBlock.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/BasicBlock.cpp (original) +++ llvm/trunk/lib/VMCore/BasicBlock.cpp Mon Jul 6 18:00:19 2009 @@ -29,7 +29,7 @@ return 0; } -LLVMContext* BasicBlock::getContext() const { +LLVMContext *BasicBlock::getContext() const { return Parent ? Parent->getContext() : 0; } Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=74878&r1=74877&r2=74878&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Mon Jul 6 18:00:19 2009 @@ -114,7 +114,7 @@ // Helper Methods in Function //===----------------------------------------------------------------------===// -LLVMContext* Function::getContext() const { +LLVMContext *Function::getContext() const { const Module* M = getParent(); if (M) return &M->getContext(); return 0; From dpatel at apple.com Mon Jul 6 18:11:08 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 06 Jul 2009 23:11:08 -0000 Subject: [llvm-commits] [llvm] r74879 - /llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Message-ID: <200907062311.n66NB9Q6008275@zion.cs.uiuc.edu> Author: dpatel Date: Mon Jul 6 18:11:08 2009 New Revision: 74879 URL: http://llvm.org/viewvc/llvm-project?rev=74879&view=rev Log: Add FIXMEs. Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=74879&r1=74878&r2=74879&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Mon Jul 6 18:11:08 2009 @@ -200,6 +200,7 @@ /// required initializations. void PIC16DbgInfo::BeginModule(Module &M) { // Emit file directive for module. + // FIXME : What if more then one CUs are present in a module ? GlobalVariable *CU = M.getNamedGlobal("llvm.dbg.compile_unit"); if (CU) { EmitDebugDirectives = true; @@ -321,6 +322,7 @@ E = M.getGlobalList().end(); I != E; I++) { // Structures and union declaration's debug info has llvm.dbg.composite // in its name. + // FIXME: Checking and relying on llvm.dbg.composite name is not a good idea. if(I->getName().find("llvm.dbg.composite") != std::string::npos) { GlobalVariable *GV = cast(I); DICompositeType CTy(GV); @@ -425,6 +427,7 @@ /// EmitVarDebugInfo - Emit debug information for all variables. /// void PIC16DbgInfo::EmitVarDebugInfo(Module &M) { + // FIXME : This anchor has been removed. GlobalVariable *Root = M.getGlobalVariable("llvm.dbg.global_variables"); if (!Root) return; From dpatel at apple.com Mon Jul 6 18:28:39 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 06 Jul 2009 23:28:39 -0000 Subject: [llvm-commits] [llvm] r74880 - /llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Message-ID: <200907062328.n66NSdab008802@zion.cs.uiuc.edu> Author: dpatel Date: Mon Jul 6 18:28:36 2009 New Revision: 74880 URL: http://llvm.org/viewvc/llvm-project?rev=74880&view=rev Log: Avoid directly relying on llvm.dbg.compile_unit and llvm.dbg.global_variables. PIC16 developers, please verify. Thanks. Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=74880&r1=74879&r2=74880&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Mon Jul 6 18:28:36 2009 @@ -200,9 +200,13 @@ /// required initializations. void PIC16DbgInfo::BeginModule(Module &M) { // Emit file directive for module. - // FIXME : What if more then one CUs are present in a module ? - GlobalVariable *CU = M.getNamedGlobal("llvm.dbg.compile_unit"); - if (CU) { + SmallVector CUs; + SmallVector GVs; + SmallVector SPs; + CollectDebugInfoAnchors(M, CUs, GVs, SPs); + if (!CUs.empty()) { + // FIXME : What if more then one CUs are present in a module ? + GlobalVariable *CU = CUs[0]; EmitDebugDirectives = true; SwitchToCU(CU); } @@ -427,32 +431,30 @@ /// EmitVarDebugInfo - Emit debug information for all variables. /// void PIC16DbgInfo::EmitVarDebugInfo(Module &M) { - // FIXME : This anchor has been removed. - GlobalVariable *Root = M.getGlobalVariable("llvm.dbg.global_variables"); - if (!Root) + SmallVector CUs; + SmallVector GVs; + SmallVector SPs; + CollectDebugInfoAnchors(M, CUs, GVs, SPs); + if (GVs.empty()) return; - Constant *RootC = cast(*Root->use_begin()); - for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end(); - UI != UE; ++UI) { - for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end(); - UUI != UUE; ++UUI) { - DIGlobalVariable DIGV(cast(*UUI)); - DIType Ty = DIGV.getType(); - unsigned short TypeNo = 0; - bool HasAux = false; - int Aux[PIC16Dbg::AuxSize] = { 0 }; - std::string TagName = ""; - std::string VarName = TAI->getGlobalPrefix()+DIGV.getGlobal()->getName(); - PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName); - // Emit debug info only if type information is availaible. - if (TypeNo != PIC16Dbg::T_NULL) { - O << "\n\t.type " << VarName << ", " << TypeNo; - short ClassNo = getStorageClass(DIGV); - O << "\n\t.class " << VarName << ", " << ClassNo; - if (HasAux) - EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName); - } + for (SmallVector::iterator I = GVs.begin(), + E = GVs.end(); I != E; ++I) { + DIGlobalVariable DIGV(*I); + DIType Ty = DIGV.getType(); + unsigned short TypeNo = 0; + bool HasAux = false; + int Aux[PIC16Dbg::AuxSize] = { 0 }; + std::string TagName = ""; + std::string VarName = TAI->getGlobalPrefix()+DIGV.getGlobal()->getName(); + PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName); + // Emit debug info only if type information is availaible. + if (TypeNo != PIC16Dbg::T_NULL) { + O << "\n\t.type " << VarName << ", " << TypeNo; + short ClassNo = getStorageClass(DIGV); + O << "\n\t.class " << VarName << ", " << ClassNo; + if (HasAux) + EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName); } } O << "\n"; From dpatel at apple.com Mon Jul 6 18:40:50 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 06 Jul 2009 23:40:50 -0000 Subject: [llvm-commits] [llvm] r74881 - /llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Message-ID: <200907062340.n66NeobY009171@zion.cs.uiuc.edu> Author: dpatel Date: Mon Jul 6 18:40:48 2009 New Revision: 74881 URL: http://llvm.org/viewvc/llvm-project?rev=74881&view=rev Log: !"i" is a valid MDString. Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=74881&r1=74880&r2=74881&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 6 18:40:48 2009 @@ -1010,7 +1010,6 @@ break; } case bitc::CST_CODE_MDSTRING: { - if (Record.size() < 2) return Error("Invalid MDSTRING record"); unsigned MDStringLength = Record.size(); SmallString<8> String; String.resize(MDStringLength); From dpatel at apple.com Mon Jul 6 18:44:33 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 06 Jul 2009 23:44:33 -0000 Subject: [llvm-commits] [llvm] r74882 - in /llvm/trunk: include/llvm/CodeGen/ValueTypes.h include/llvm/CodeGen/ValueTypes.td utils/TableGen/CodeGenTarget.cpp utils/TableGen/IntrinsicEmitter.cpp Message-ID: <200907062344.n66NiXQ3009273@zion.cs.uiuc.edu> Author: dpatel Date: Mon Jul 6 18:44:32 2009 New Revision: 74882 URL: http://llvm.org/viewvc/llvm-project?rev=74882&view=rev Log: Add new ValueType for metadata. Modified: llvm/trunk/include/llvm/CodeGen/ValueTypes.h llvm/trunk/include/llvm/CodeGen/ValueTypes.td llvm/trunk/utils/TableGen/CodeGenTarget.cpp llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/ValueTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ValueTypes.h?rev=74882&r1=74881&r2=74882&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ValueTypes.h (original) +++ llvm/trunk/include/llvm/CodeGen/ValueTypes.h Mon Jul 6 18:44:32 2009 @@ -83,6 +83,9 @@ // This value must be a multiple of 32. MAX_ALLOWED_VALUETYPE = 64, + // Metadata - This is MDNode or MDString. + Metadata = 251, + // iPTRAny - An int value the size of the pointer of the current // target to any address space. This must only be used internal to // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR. Modified: llvm/trunk/include/llvm/CodeGen/ValueTypes.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ValueTypes.td?rev=74882&r1=74881&r2=74882&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ValueTypes.td (original) +++ llvm/trunk/include/llvm/CodeGen/ValueTypes.td Mon Jul 6 18:44:32 2009 @@ -57,7 +57,9 @@ def v8f32 : ValueType<256, 33>; // 8 x f32 vector value def v2f64 : ValueType<128, 34>; // 2 x f64 vector value def v4f64 : ValueType<256, 35>; // 4 x f64 vector value - + +def MetadataVT: ValueType<0, 251>; // Metadata + // Pseudo valuetype mapped to the current pointer size to any address space. // Should only be used in TableGen. def iPTRAny : ValueType<0, 252>; Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=74882&r1=74881&r2=74882&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Mon Jul 6 18:44:32 2009 @@ -118,6 +118,7 @@ case MVT::v4f64: return "MVT::v4f64"; case MVT::v3i32: return "MVT::v3i32"; case MVT::v3f32: return "MVT::v3f32"; + case MVT::Metadata: return "MVT::Metadata"; case MVT::iPTR: return "MVT::iPTR"; case MVT::iPTRAny: return "MVT::iPTRAny"; default: assert(0 && "ILLEGAL VALUE TYPE!"); return ""; Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=74882&r1=74881&r2=74882&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Mon Jul 6 18:44:32 2009 @@ -159,6 +159,8 @@ OS << "Type::PPC_FP128Ty"; } else if (VT == MVT::isVoid) { OS << "Type::VoidTy"; + } else if (VT == MVT::Metadata) { + OS << "Type::MetadataTy"; } else { assert(false && "Unsupported ValueType!"); } From dpatel at apple.com Mon Jul 6 18:46:03 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 06 Jul 2009 23:46:03 -0000 Subject: [llvm-commits] [llvm] r74883 - /llvm/trunk/include/llvm/CodeGen/MachineOperand.h Message-ID: <200907062346.n66Nk4Zo009321@zion.cs.uiuc.edu> Author: dpatel Date: Mon Jul 6 18:46:02 2009 New Revision: 74883 URL: http://llvm.org/viewvc/llvm-project?rev=74883&view=rev Log: Add isMetadata() to check metadata operand. Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=74883&r1=74882&r2=74883&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Mon Jul 6 18:46:02 2009 @@ -164,6 +164,8 @@ bool isGlobal() const { return OpKind == MO_GlobalAddress; } /// isSymbol - Tests if this is a MO_ExternalSymbol operand. bool isSymbol() const { return OpKind == MO_ExternalSymbol; } + /// isMetadata - Tests if this is a MO_Metadata operand. + bool isMetadata() const { return OpKind == MO_Metadata; } //===--------------------------------------------------------------------===// // Accessors for Register Operands @@ -325,7 +327,7 @@ } void setOffset(int64_t Offset) { - assert((isGlobal() || isSymbol() || isCPI()) && + assert((isGlobal() || isSymbol() || isCPI() || isMetadata()) && "Wrong MachineOperand accessor"); Contents.OffsetedInfo.Offset = Offset; } From dalej at apple.com Mon Jul 6 19:18:55 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 07 Jul 2009 00:18:55 -0000 Subject: [llvm-commits] [llvm] r74886 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200907070018.n670IvCH010224@zion.cs.uiuc.edu> Author: johannes Date: Mon Jul 6 19:18:49 2009 New Revision: 74886 URL: http://llvm.org/viewvc/llvm-project?rev=74886&view=rev Log: Don't accept globals as matching 'i' constraint in PIC modes (in accordance with existing comment). gcc.apple/asm-block-25.c Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=74886&r1=74885&r2=74886&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Jul 6 19:18:49 2009 @@ -8803,10 +8803,15 @@ continue; } } - + // Otherwise, this isn't something we can handle, reject it. return; } + // If we require an extra load to get this address, as in PIC mode, we + // can't accept it. + if (Subtarget->GVRequiresExtraLoad(GA->getGlobal(), + getTargetMachine(), false)) + return; if (hasMemory) Op = LowerGlobalAddress(GA->getGlobal(), Op.getDebugLoc(), Offset, DAG); From rnk at mit.edu Mon Jul 6 17:45:57 2009 From: rnk at mit.edu (Reid Kleckner) Date: Mon, 6 Jul 2009 15:45:57 -0700 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction In-Reply-To: <1DDE1F32B1CA4138A16F4434BF65EB36@HPLAPTOP> References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> <0772BCC55D8C48209386001E95355240@HPLAPTOP> <2754CA63-0EF0-41B7-8217-F464354C6A87@apple.com> <1DDE1F32B1CA4138A16F4434BF65EB36@HPLAPTOP> Message-ID: <9a9942200907061545l60ac78aamfda65ead1e479916@mail.gmail.com> > Templating allows us to have mutiple types of MachineCodeEmitters, the > JITCodeEmitter, and the ObjectCodeEmitter, and any other kind of CodeEmitter > we require in the future, e.g. Reid Kleckner' requirements to combine JIT > and GDB. It allows these emiiters to be efficient and be inlined functions. > If you study the code you will see what I mean. FWIW, I've hacked my way around any awkwardnesses in the current API. This whole JIT-to-GDB-through-ELF thing is a hack, and I wouldn't consider my use case too much in designing the API. Besides, I'm learning that the right way to do this might be to implement a custom binary file descriptor for GDB to use so that I don't actually have to generate ELF. Reid From clattner at apple.com Mon Jul 6 20:09:32 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Jul 2009 18:09:32 -0700 Subject: [llvm-commits] [llvm] r74883 - /llvm/trunk/include/llvm/CodeGen/MachineOperand.h In-Reply-To: <200907062346.n66Nk4Zo009321@zion.cs.uiuc.edu> References: <200907062346.n66Nk4Zo009321@zion.cs.uiuc.edu> Message-ID: On Jul 6, 2009, at 4:46 PM, Devang Patel wrote: > Author: dpatel > Date: Mon Jul 6 18:46:02 2009 > New Revision: 74883 > > URL: http://llvm.org/viewvc/llvm-project?rev=74883&view=rev > Log: > Add isMetadata() to check metadata operand. Hey Devang, What is your plan to use MetaData MachineInstr operands? Can you elaborate on how you plan to use these? -Chris > > Modified: > llvm/trunk/include/llvm/CodeGen/MachineOperand.h > > Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=74883&r1=74882&r2=74883&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) > +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Mon Jul 6 > 18:46:02 2009 > @@ -164,6 +164,8 @@ > bool isGlobal() const { return OpKind == MO_GlobalAddress; } > /// isSymbol - Tests if this is a MO_ExternalSymbol operand. > bool isSymbol() const { return OpKind == MO_ExternalSymbol; } > + /// isMetadata - Tests if this is a MO_Metadata operand. > + bool isMetadata() const { return OpKind == MO_Metadata; } > > // > = > = > =-------------------------------------------------------------------- > ===// > // Accessors for Register Operands > @@ -325,7 +327,7 @@ > } > > void setOffset(int64_t Offset) { > - assert((isGlobal() || isSymbol() || isCPI()) && > + assert((isGlobal() || isSymbol() || isCPI() || isMetadata()) && > "Wrong MachineOperand accessor"); > Contents.OffsetedInfo.Offset = Offset; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Mon Jul 6 20:16:42 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Jul 2009 01:16:42 -0000 Subject: [llvm-commits] [llvm] r74888 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200907070116.n671GgMm011973@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jul 6 20:16:41 2009 New Revision: 74888 URL: http://llvm.org/viewvc/llvm-project?rev=74888&view=rev Log: 80 col violation. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=74888&r1=74887&r2=74888&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Jul 6 20:16:41 2009 @@ -590,8 +590,8 @@ // Note the new unconditional branch is not being recorded. // There doesn't seem to be meaningful DebugInfo available; this doesn't // correspond to anything in the source. - BuildMI(OrigBB, DebugLoc::getUnknownLoc(), - TII->get(isThumb ? ((isThumb2) ? ARM::t2B : ARM::tB) : ARM::B)).addMBB(NewBB); + unsigned Opc = isThumb ? (isThumb2 ? ARM::t2B : ARM::tB) : ARM::B; + BuildMI(OrigBB, DebugLoc::getUnknownLoc(), TII->get(Opc)).addMBB(NewBB); NumSplit++; // Update the CFG. All succs of OrigBB are now succs of NewBB. From evan.cheng at apple.com Mon Jul 6 20:17:28 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Jul 2009 01:17:28 -0000 Subject: [llvm-commits] [llvm] r74889 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/Thumb2/thumb2-mulhi.ll test/CodeGen/Thumb2/thumb2-smla.ll test/CodeGen/Thumb2/thumb2-smul.ll Message-ID: <200907070117.n671HSFE012012@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jul 6 20:17:28 2009 New Revision: 74889 URL: http://llvm.org/viewvc/llvm-project?rev=74889&view=rev Log: Add some more Thumb2 multiplication instructions. Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-mulhi.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-smla.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-smul.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=74889&r1=74888&r2=74889&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Mon Jul 6 20:17:28 2009 @@ -923,7 +923,7 @@ break; } case ISD::MUL: - if (Subtarget->isThumb()) + if (Subtarget->isThumb1Only()) break; if (ConstantSDNode *C = dyn_cast(Op.getOperand(1))) { unsigned RHSV = C->getZExtValue(); @@ -953,20 +953,37 @@ Op.getOperand(0), getAL(CurDAG), CurDAG->getRegister(0, MVT::i32)); case ISD::UMUL_LOHI: { - SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1), + if (Subtarget->isThumb1Only()) + break; + if (Subtarget->isThumb()) { + SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1), + getAL(CurDAG), CurDAG->getRegister(0, MVT::i32), + CurDAG->getRegister(0, MVT::i32) }; + return CurDAG->getTargetNode(ARM::t2UMULL, dl, MVT::i32, MVT::i32, Ops,4); + } else { + SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1), getAL(CurDAG), CurDAG->getRegister(0, MVT::i32), CurDAG->getRegister(0, MVT::i32) }; - return CurDAG->getTargetNode(ARM::UMULL, dl, MVT::i32, MVT::i32, Ops, 5); + return CurDAG->getTargetNode(ARM::UMULL, dl, MVT::i32, MVT::i32, Ops, 5); + } } case ISD::SMUL_LOHI: { - SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1), + if (Subtarget->isThumb1Only()) + break; + if (Subtarget->isThumb()) { + SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1), + getAL(CurDAG), CurDAG->getRegister(0, MVT::i32) }; + return CurDAG->getTargetNode(ARM::t2SMULL, dl, MVT::i32, MVT::i32, Ops,4); + } else { + SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1), getAL(CurDAG), CurDAG->getRegister(0, MVT::i32), CurDAG->getRegister(0, MVT::i32) }; - return CurDAG->getTargetNode(ARM::SMULL, dl, MVT::i32, MVT::i32, Ops, 5); + return CurDAG->getTargetNode(ARM::SMULL, dl, MVT::i32, MVT::i32, Ops, 5); + } } case ISD::LOAD: { SDNode *ResNode = 0; - if (Subtarget->isThumb2()) + if (Subtarget->isThumb() && Subtarget->hasThumb2()) ResNode = SelectT2IndexedLoad(Op); else ResNode = SelectARMIndexedLoad(Op); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=74889&r1=74888&r2=74889&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Jul 6 20:17:28 2009 @@ -246,7 +246,7 @@ } // i64 operation support. - if (Subtarget->isThumb()) { + if (Subtarget->isThumb1Only()) { setOperationAction(ISD::MUL, MVT::i64, Expand); setOperationAction(ISD::MULHU, MVT::i32, Expand); setOperationAction(ISD::MULHS, MVT::i32, Expand); @@ -255,7 +255,7 @@ } else { setOperationAction(ISD::MUL, MVT::i64, Expand); setOperationAction(ISD::MULHU, MVT::i32, Expand); - if (!Subtarget->hasV6Ops()) + if (!Subtarget->isThumb() && !Subtarget->hasV6Ops()) setOperationAction(ISD::MULHS, MVT::i32, Expand); } setOperationAction(ISD::SHL_PARTS, MVT::i32, Expand); @@ -3034,7 +3034,7 @@ bool isInc; bool isLegal = false; - if (Subtarget->isThumb2()) + if (Subtarget->isThumb() && Subtarget->hasThumb2()) isLegal = getT2IndexedAddressParts(Ptr.getNode(), VT, isSEXTLoad, Base, Offset, isInc, DAG); else @@ -3071,7 +3071,7 @@ bool isInc; bool isLegal = false; - if (Subtarget->isThumb2()) + if (Subtarget->isThumb() && Subtarget->hasThumb2()) isLegal = getT2IndexedAddressParts(Op, VT, isSEXTLoad, Base, Offset, isInc, DAG); else Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=74889&r1=74888&r2=74889&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Jul 6 20:17:28 2009 @@ -838,7 +838,113 @@ "mls", " $dst, $a, $b, $c", [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>; -// FIXME: SMULL, etc. +// Extra precision multiplies with low / high results +let neverHasSideEffects = 1 in { +let isCommutable = 1 in { +def t2SMULL : T2I<(outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b), + "smull", " $ldst, $hdst, $a, $b", []>; + +def t2UMULL : T2I<(outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b), + "umull", " $ldst, $hdst, $a, $b", []>; +} + +// Multiply + accumulate +def t2SMLAL : T2I<(outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b), + "smlal", " $ldst, $hdst, $a, $b", []>; + +def t2UMLAL : T2I<(outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b), + "umlal", " $ldst, $hdst, $a, $b", []>; + +def t2UMAAL : T2I<(outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b), + "umaal", " $ldst, $hdst, $a, $b", []>; +} // neverHasSideEffects + +// Most significant word multiply +def t2SMMUL : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), + "smmul", " $dst, $a, $b", + [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>; + +def t2SMMLA : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), + "smmla", " $dst, $a, $b, $c", + [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>; + + +def t2SMMLS : T2I <(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), + "smmls", " $dst, $a, $b, $c", + [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>; + +multiclass T2I_smul { + def BB : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), + !strconcat(opc, "bb"), " $dst, $a, $b", + [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16), + (sext_inreg GPR:$b, i16)))]>; + + def BT : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), + !strconcat(opc, "bt"), " $dst, $a, $b", + [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16), + (sra GPR:$b, (i32 16))))]>; + + def TB : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), + !strconcat(opc, "tb"), " $dst, $a, $b", + [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)), + (sext_inreg GPR:$b, i16)))]>; + + def TT : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), + !strconcat(opc, "tt"), " $dst, $a, $b", + [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)), + (sra GPR:$b, (i32 16))))]>; + + def WB : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), + !strconcat(opc, "wb"), " $dst, $a, $b", + [(set GPR:$dst, (sra (opnode GPR:$a, + (sext_inreg GPR:$b, i16)), (i32 16)))]>; + + def WT : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), + !strconcat(opc, "wt"), " $dst, $a, $b", + [(set GPR:$dst, (sra (opnode GPR:$a, + (sra GPR:$b, (i32 16))), (i32 16)))]>; +} + + +multiclass T2I_smla { + def BB : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), + !strconcat(opc, "bb"), " $dst, $a, $b, $acc", + [(set GPR:$dst, (add GPR:$acc, + (opnode (sext_inreg GPR:$a, i16), + (sext_inreg GPR:$b, i16))))]>; + + def BT : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), + !strconcat(opc, "bt"), " $dst, $a, $b, $acc", + [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16), + (sra GPR:$b, (i32 16)))))]>; + + def TB : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), + !strconcat(opc, "tb"), " $dst, $a, $b, $acc", + [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)), + (sext_inreg GPR:$b, i16))))]>; + + def TT : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), + !strconcat(opc, "tt"), " $dst, $a, $b, $acc", + [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)), + (sra GPR:$b, (i32 16)))))]>; + + def WB : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), + !strconcat(opc, "wb"), " $dst, $a, $b, $acc", + [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a, + (sext_inreg GPR:$b, i16)), (i32 16))))]>; + + def WT : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), + !strconcat(opc, "wt"), " $dst, $a, $b, $acc", + [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a, + (sra GPR:$b, (i32 16))), (i32 16))))]>; +} + +defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>; +defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>; + +// TODO: Halfword multiple accumulate long: SMLAL +// TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD + //===----------------------------------------------------------------------===// // Misc. Arithmetic Instructions. Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-mulhi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-mulhi.ll?rev=74889&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-mulhi.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-mulhi.ll Mon Jul 6 20:17:28 2009 @@ -0,0 +1,20 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep smmul | count 1 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep umull | count 1 + +define i32 @smulhi(i32 %x, i32 %y) { + %tmp = sext i32 %x to i64 ; [#uses=1] + %tmp1 = sext i32 %y to i64 ; [#uses=1] + %tmp2 = mul i64 %tmp1, %tmp ; [#uses=1] + %tmp3 = lshr i64 %tmp2, 32 ; [#uses=1] + %tmp3.upgrd.1 = trunc i64 %tmp3 to i32 ; [#uses=1] + ret i32 %tmp3.upgrd.1 +} + +define i32 @umulhi(i32 %x, i32 %y) { + %tmp = zext i32 %x to i64 ; [#uses=1] + %tmp1 = zext i32 %y to i64 ; [#uses=1] + %tmp2 = mul i64 %tmp1, %tmp ; [#uses=1] + %tmp3 = lshr i64 %tmp2, 32 ; [#uses=1] + %tmp3.upgrd.2 = trunc i64 %tmp3 to i32 ; [#uses=1] + ret i32 %tmp3.upgrd.2 +} Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-smla.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-smla.ll?rev=74889&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-smla.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-smla.ll Mon Jul 6 20:17:28 2009 @@ -0,0 +1,10 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | \ +; RUN: grep smlabt | count 1 + +define i32 @f3(i32 %a, i16 %x, i32 %y) { + %tmp = sext i16 %x to i32 ; [#uses=1] + %tmp2 = ashr i32 %y, 16 ; [#uses=1] + %tmp3 = mul i32 %tmp2, %tmp ; [#uses=1] + %tmp5 = add i32 %tmp3, %a ; [#uses=1] + ret i32 %tmp5 +} Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-smul.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-smul.ll?rev=74889&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-smul.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-smul.ll Mon Jul 6 20:17:28 2009 @@ -0,0 +1,23 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | \ +; RUN: grep smulbt | count 1 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | \ +; RUN: grep smultt | count 1 + + at x = weak global i16 0 ; [#uses=1] + at y = weak global i16 0 ; [#uses=0] + +define i32 @f1(i32 %y) { + %tmp = load i16* @x ; [#uses=1] + %tmp1 = add i16 %tmp, 2 ; [#uses=1] + %tmp2 = sext i16 %tmp1 to i32 ; [#uses=1] + %tmp3 = ashr i32 %y, 16 ; [#uses=1] + %tmp4 = mul i32 %tmp2, %tmp3 ; [#uses=1] + ret i32 %tmp4 +} + +define i32 @f2(i32 %x, i32 %y) { + %tmp1 = ashr i32 %x, 16 ; [#uses=1] + %tmp3 = ashr i32 %y, 16 ; [#uses=1] + %tmp4 = mul i32 %tmp3, %tmp1 ; [#uses=1] + ret i32 %tmp4 +} From devang.patel at gmail.com Mon Jul 6 20:34:01 2009 From: devang.patel at gmail.com (Devang Patel) Date: Mon, 6 Jul 2009 18:34:01 -0700 Subject: [llvm-commits] [llvm] r74883 - /llvm/trunk/include/llvm/CodeGen/MachineOperand.h In-Reply-To: References: <200907062346.n66Nk4Zo009321@zion.cs.uiuc.edu> Message-ID: <352a1fb20907061834m1e2f102m851dc27d592105d1@mail.gmail.com> Chris, On Mon, Jul 6, 2009 at 6:09 PM, Chris Lattner wrote: > > On Jul 6, 2009, at 4:46 PM, Devang Patel wrote: > >> Author: dpatel >> Date: Mon Jul ?6 18:46:02 2009 >> New Revision: 74883 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=74883&view=rev >> Log: >> Add isMetadata() to check metadata operand. > > Hey Devang, > > What is your plan to use MetaData MachineInstr operands? ?Can you > elaborate on how you plan to use these? My near term goal is to replace all Global Variables used to encode debug info (llvm.dbg.*) by MDNodes. As a step towards this goal, I need MetaData as machine instruction operand to handle printDeclare(). - Devang From mai4 at uiuc.edu Mon Jul 6 22:42:28 2009 From: mai4 at uiuc.edu (Haohui Mai) Date: Tue, 07 Jul 2009 03:42:28 -0000 Subject: [llvm-commits] [poolalloc] r74891 - /poolalloc/trunk/include/dsa/DataStructure.h Message-ID: <200907070342.n673gTXp016001@zion.cs.uiuc.edu> Author: mai4 Date: Mon Jul 6 22:42:27 2009 New Revision: 74891 URL: http://llvm.org/viewvc/llvm-project?rev=74891&view=rev Log: Add the declaration of Steensgaard DSA pass. Modified: poolalloc/trunk/include/dsa/DataStructure.h Modified: poolalloc/trunk/include/dsa/DataStructure.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=74891&r1=74890&r2=74891&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DataStructure.h (original) +++ poolalloc/trunk/include/dsa/DataStructure.h Mon Jul 6 22:42:27 2009 @@ -410,6 +410,46 @@ {} }; +/// SteensgaardsDataStructures - Analysis that computes a context-insensitive +/// data structure graphs for the whole program. +/// +class SteensgaardDataStructures : public DataStructures { + DSGraph * ResultGraph; + DataStructures * DS; + void ResolveFunctionCall(const Function *F, const DSCallSite &Call, + DSNodeHandle &RetVal); + bool runOnModuleInternal(Module &M); + +public: + static char ID; + SteensgaardDataStructures() : + DataStructures((intptr_t)&ID, "steensgaard."), + ResultGraph(NULL) {} + ~SteensgaardDataStructures(); + virtual bool runOnModule(Module &M); + virtual void releaseMyMemory(); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + AU.setPreservesAll(); + } + + /// getDSGraph - Return the data structure graph for the specified function. + /// + DSGraph *getDSGraph(const Function &F) const { + return ResultGraph; + } + + /// getDSGraph - Return the data structure graph for the whole program. + /// + DSGraph *getResultGraph() const { + return ResultGraph; + } + + void print(OStream O, const Module *M) const; + void print(std::ostream &O, const Module *M) const; + +}; } // End llvm namespace From mai4 at uiuc.edu Mon Jul 6 23:18:07 2009 From: mai4 at uiuc.edu (Haohui Mai) Date: Tue, 07 Jul 2009 04:18:07 -0000 Subject: [llvm-commits] [poolalloc] r74892 - in /poolalloc/trunk: include/poolalloc/PoolAllocate.h lib/PoolAllocate/PAMultipleGlobalPool.cpp Message-ID: <200907070418.n674I8ix017137@zion.cs.uiuc.edu> Author: mai4 Date: Mon Jul 6 23:18:07 2009 New Revision: 74892 URL: http://llvm.org/viewvc/llvm-project?rev=74892&view=rev Log: Context-insensitive pool allocation. Added: poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=74892&r1=74891&r2=74892&view=diff ============================================================================== --- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original) +++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Mon Jul 6 23:18:07 2009 @@ -25,7 +25,9 @@ #include "llvm/Support/CallSite.h" #include "llvm/ADT/EquivalenceClasses.h" #include "llvm/ADT/VectorExtras.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/Support/CommandLine.h" + #include "dsa/DataStructure.h" #include "poolalloc/ADT/HashExtras.h" #include "poolalloc/Config/config.h" @@ -461,6 +463,36 @@ } }; -} +/// PoolAllocateMultipleGlobalPool +/// Context-insensitive pool allocation. It pool allocates objects into multiple +/// global pools. It does not need to rewrite the functions declarations, which +/// simplifies the implementation a lot. Technically, PoolAllocateSimple, which +/// pool allocates everything into a single global pool, is a +/// special case of PoolAllocateMultipleGlobalPool. +/// +/// It requires some work on code clean up to make these two pass integrate +/// nicely. +class PoolAllocateMultipleGlobalPool : public PoolAllocate { + TargetData * TD; + void ProcessFunctionBodySimple(Function& F, TargetData & TD); + /// Mapping between DSNodes and Pool descriptors. For this pass, it is a + /// one-to-one relationship. + DenseMap PoolMap; +public: + static char ID; + PoolAllocateMultipleGlobalPool(bool passAllArgs=false, bool SAFECode = true) + : PoolAllocate (passAllArgs, SAFECode, (intptr_t)&ID) {} + ~PoolAllocateMultipleGlobalPool(); + virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual bool runOnModule(Module &M); + void CreateGlobalPool(unsigned RecSize, unsigned Align, + Module& M); + + virtual Value * getGlobalPool (const DSNode * Node); + virtual Value * getPool (const DSNode * N, Function & F); + +}; + +} #endif Added: poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp?rev=74892&view=auto ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp (added) +++ poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp Mon Jul 6 23:18:07 2009 @@ -0,0 +1,352 @@ +//===-- PAMultipleGlobalPool.cpp - Multiple Global Pool Allocation Pass ---===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// A minimal poolallocator that assignes all allocation to multiple global +// pools. +// +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "poolalloc" + +#include "dsa/DataStructure.h" +#include "dsa/DSGraph.h" +#include "dsa/CallTargets.h" +#include "poolalloc/PoolAllocate.h" +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Constants.h" +#include "llvm/Support/CFG.h" +#include "llvm/Target/TargetData.h" +#include "llvm/Transforms/Utils/BasicBlockUtils.h" +#include "llvm/Transforms/Utils/Cloning.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/Timer.h" + +#include + +using namespace llvm; +using namespace PA; + +char llvm::PoolAllocateMultipleGlobalPool::ID = 0; + +namespace { + RegisterPass + X("poolalloc-multi-global-pool", "Pool allocate objects into multiple global pools"); + + RegisterAnalysisGroup PAGroup1(X); +} + +static inline Value * +castTo (Value * V, const Type * Ty, std::string Name, Instruction * InsertPt) { + // + // Don't bother creating a cast if it's already the correct type. + // + if (V->getType() == Ty) + return V; + + // + // If it's a constant, just create a constant expression. + // + if (Constant * C = dyn_cast(V)) { + Constant * CE = ConstantExpr::getZExtOrBitCast (C, Ty); + return CE; + } + + // + // Otherwise, insert a cast instruction. + // + return CastInst::CreateZExtOrBitCast (V, Ty, Name, InsertPt); +} + +void PoolAllocateMultipleGlobalPool::getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + AU.addRequired(); + // It is a big lie. + AU.setPreservesAll(); +} + +bool PoolAllocateMultipleGlobalPool::runOnModule(Module &M) { + if (M.begin() == M.end()) return false; + Graphs = &getAnalysis(); + assert (Graphs && "No DSA pass available!\n"); + + TargetData & TD = getAnalysis(); + + // Add the pool* prototypes to the module + AddPoolPrototypes(&M); + + // + // Create the global pool. + // + CreateGlobalPool(32, 1, M); + + // + // Now that all call targets are available, rewrite the function bodies of the + // clones. + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { + std::string name = I->getName(); + if (name == "poolalloc.init") continue; + if (!(I->isDeclaration())) + ProcessFunctionBodySimple(*I, TD); + } + + return true; +} + +void +PoolAllocateMultipleGlobalPool::ProcessFunctionBodySimple (Function& F, TargetData & TD) { + std::vector toDelete; + std::vector Returns; + + // + // Create a silly Function Info structure for this function. + // + FuncInfo FInfo(F); + FunctionInfo.insert (std::make_pair(&F, FInfo)); + + // + // Get the DSGraph for this function. + // + DSGraph* ECG = Graphs->getDSGraph(F); + + for (Function::iterator i = F.begin(), e = F.end(); i != e; ++i) + for (BasicBlock::iterator ii = i->begin(), ee = i->end(); ii != ee; ++ii) { + if (MallocInst * MI = dyn_cast(ii)) { + // Associate the global pool decriptor with the DSNode + DSNode * Node = ECG->getNodeForValue(MI).getNode(); + GlobalVariable * Pool = PoolMap[Node]; + FInfo.PoolDescriptors.insert(std::make_pair(Node,Pool)); + + // Mark the malloc as an instruction to delete + toDelete.push_back(ii); + + // Create instructions to calculate the size of the allocation in + // bytes + Value * AllocSize; + if (MI->isArrayAllocation()) { + Value * NumElements = MI->getArraySize(); + Value * ElementSize = ConstantInt::get (Type::Int32Ty, + TD.getTypeAllocSize(MI->getAllocatedType())); + AllocSize = BinaryOperator::Create (Instruction::Mul, + ElementSize, + NumElements, + "sizetmp", + MI); + } else { + AllocSize = ConstantInt::get (Type::Int32Ty, + TD.getTypeAllocSize(MI->getAllocatedType())); + } + + Value* args[] = {Pool, AllocSize}; + Instruction* x = CallInst::Create(PoolAlloc, &args[0], &args[2], MI->getName(), ii); + ii->replaceAllUsesWith(CastInst::CreatePointerCast(x, ii->getType(), "", ii)); + } else if (CallInst * CI = dyn_cast(ii)) { + CallSite CS(CI); + Function *CF = CS.getCalledFunction(); + if (ConstantExpr *CE = dyn_cast(CS.getCalledValue())) + if (CE->getOpcode() == Instruction::BitCast && + isa(CE->getOperand(0))) + CF = cast(CE->getOperand(0)); + if (CF && (CF->isDeclaration()) && (CF->getName() == "realloc")) { + // Associate the global pool decriptor with the DSNode + DSNode * Node = ECG->getNodeForValue(CI).getNode(); + GlobalVariable * Pool = PoolMap[Node]; + + FInfo.PoolDescriptors.insert(std::make_pair(Node,Pool)); + + // Mark the realloc as an instruction to delete + toDelete.push_back(ii); + + // Insertion point - Instruction before which all our instructions go + Instruction *InsertPt = CI; + Value *OldPtr = CS.getArgument(0); + Value *Size = CS.getArgument(1); + + // Ensure the size and pointer arguments are of the correct type + if (Size->getType() != Type::Int32Ty) + Size = CastInst::CreateIntegerCast (Size, + Type::Int32Ty, + false, + Size->getName(), + InsertPt); + + static Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty); + if (OldPtr->getType() != VoidPtrTy) + OldPtr = CastInst::CreatePointerCast (OldPtr, + VoidPtrTy, + OldPtr->getName(), + InsertPt); + + std::string Name = CI->getName(); CI->setName(""); + Value* Opts[3] = {Pool, OldPtr, Size}; + Instruction *V = CallInst::Create (PoolRealloc, + Opts, + Opts + 3, + Name, + InsertPt); + Instruction *Casted = V; + if (V->getType() != CI->getType()) + Casted = CastInst::CreatePointerCast (V, CI->getType(), V->getName(), InsertPt); + + // Update def-use info + CI->replaceAllUsesWith(Casted); + } else if (CF && (CF->isDeclaration()) && (CF->getName() == "calloc")) { + // Associate the global pool decriptor with the DSNode + DSNode * Node = ECG->getNodeForValue(CI).getNode(); + GlobalVariable * Pool = PoolMap[Node]; + FInfo.PoolDescriptors.insert(std::make_pair(Node,Pool)); + + // Mark the realloc as an instruction to delete + toDelete.push_back(ii); + + // Insertion point - Instruction before which all our instructions go + Instruction *InsertPt = CI; + Value *NumElements = CS.getArgument(0); + Value *Size = CS.getArgument(1); + + // Ensure the size and pointer arguments are of the correct type + if (Size->getType() != Type::Int32Ty) + Size = CastInst::CreateIntegerCast (Size, + Type::Int32Ty, + false, + Size->getName(), + InsertPt); + + if (NumElements->getType() != Type::Int32Ty) + NumElements = CastInst::CreateIntegerCast (Size, + Type::Int32Ty, + false, + NumElements->getName(), + InsertPt); + + std::string Name = CI->getName(); CI->setName(""); + Value* Opts[3] = {Pool, NumElements, Size}; + Instruction *V = CallInst::Create (PoolCalloc, + Opts, + Opts + 3, + Name, + InsertPt); + + Instruction *Casted = V; + if (V->getType() != CI->getType()) + Casted = CastInst::CreatePointerCast (V, CI->getType(), V->getName(), InsertPt); + + // Update def-use info + CI->replaceAllUsesWith(Casted); + } else if (CF && (CF->isDeclaration()) && (CF->getName() == "strdup")) { + // Associate the global pool decriptor with the DSNode + DSNode * Node = ECG->getNodeForValue(CI).getNode(); + GlobalVariable * Pool = PoolMap[Node]; + FInfo.PoolDescriptors.insert(std::make_pair(Node, Pool)); + + // Mark the realloc as an instruction to delete + toDelete.push_back(ii); + + // Insertion point - Instruction before which all our instructions go + Instruction *InsertPt = CI; + Value *OldPtr = CS.getArgument(0); + + // Ensure the size and pointer arguments are of the correct type + static Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty); + if (OldPtr->getType() != VoidPtrTy) + OldPtr = CastInst::CreatePointerCast (OldPtr, + VoidPtrTy, + OldPtr->getName(), + InsertPt); + + std::string Name = CI->getName(); CI->setName(""); + Value* Opts[2] = {Pool, OldPtr}; + Instruction *V = CallInst::Create (PoolStrdup, + Opts, + Opts + 2, + Name, + InsertPt); + Instruction *Casted = V; + if (V->getType() != CI->getType()) + Casted = CastInst::CreatePointerCast (V, CI->getType(), V->getName(), InsertPt); + + // Update def-use info + CI->replaceAllUsesWith(Casted); + } + } else if (FreeInst * FI = dyn_cast(ii)) { + Type * VoidPtrTy = PointerType::getUnqual(Type::Int8Ty); + Value * FreedNode = castTo (FI->getPointerOperand(), VoidPtrTy, "cast", ii); + DSNode * Node = ECG->getNodeForValue(FreedNode).getNode(); + GlobalVariable * Pool = PoolMap[Node]; + toDelete.push_back(ii); + Value* args[] = {Pool, FreedNode}; + CallInst::Create(PoolFree, &args[0], &args[2], "", ii); + } else if (isa(ii)) { + Returns.push_back(cast(ii)); + } + } + + //delete malloc and alloca insts + for (unsigned x = 0; x < toDelete.size(); ++x) + toDelete[x]->eraseFromParent(); +} + +/// CreateGlobalPool - Create a global pool descriptor object, and insert a +/// poolinit for it into poolalloc.init +void +PoolAllocateMultipleGlobalPool::CreateGlobalPool (unsigned RecSize, + unsigned Align, + Module& M) { + + Function *InitFunc = Function::Create + (FunctionType::get(Type::VoidTy, std::vector(), false), + GlobalValue::InternalLinkage, "poolalloc.init", &M); + + BasicBlock * BB = BasicBlock::Create("entry", InitFunc); + + SteensgaardDataStructures * DS = dynamic_cast(Graphs); + + assert (DS && "PoolAllocateMultipleGlobalPools requires Steensgaard Data Structure!"); + + DSGraph * G = DS->getResultGraph(); + for(DSGraph::node_const_iterator I = G->node_begin(), + E = G->node_end(); I != E; ++I) { + + GlobalVariable *GV = + new GlobalVariable(getPoolType(), false, GlobalValue::ExternalLinkage, + Constant::getNullValue(getPoolType()), + "__poolalloc_GlobalPool", + &M); + + Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize); + Value *AlignV = ConstantInt::get(Type::Int32Ty, Align); + Value* Opts[3] = {GV, ElSize, AlignV}; + + CallInst::Create(PoolInit, Opts, Opts + 3, "", BB); + PoolMap[&(*I)] = GV; + } + + ReturnInst::Create(BB); +} + +Value * +PoolAllocateMultipleGlobalPool::getGlobalPool (const DSNode * Node) { + Value * Pool = PoolMap[Node]; + assert (Pool && "Every DSNode corresponds to a pool handle!"); + return Pool; +} + +Value * +PoolAllocateMultipleGlobalPool::getPool (const DSNode * N, Function & F) { + return getGlobalPool(N); +} + +PoolAllocateMultipleGlobalPool::~PoolAllocateMultipleGlobalPool() {} From clattner at apple.com Mon Jul 6 23:37:38 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Jul 2009 21:37:38 -0700 Subject: [llvm-commits] [llvm] r74883 - /llvm/trunk/include/llvm/CodeGen/MachineOperand.h In-Reply-To: <352a1fb20907061834m1e2f102m851dc27d592105d1@mail.gmail.com> References: <200907062346.n66Nk4Zo009321@zion.cs.uiuc.edu> <352a1fb20907061834m1e2f102m851dc27d592105d1@mail.gmail.com> Message-ID: <40BDA519-E5B7-4081-A095-6A5C6739D661@apple.com> On Jul 6, 2009, at 6:34 PM, Devang Patel wrote: > Chris, > > On Mon, Jul 6, 2009 at 6:09 PM, Chris Lattner > wrote: >> >> On Jul 6, 2009, at 4:46 PM, Devang Patel wrote: >> >>> Author: dpatel >>> Date: Mon Jul 6 18:46:02 2009 >>> New Revision: 74883 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=74883&view=rev >>> Log: >>> Add isMetadata() to check metadata operand. >> >> Hey Devang, >> >> What is your plan to use MetaData MachineInstr operands? Can you >> elaborate on how you plan to use these? > > My near term goal is to replace all Global Variables used to encode > debug info (llvm.dbg.*) by MDNodes. As a step towards this goal, I > need MetaData as machine instruction operand to handle printDeclare(). Do we really want to propagate llvm.declare intrinsics into machineinstrs? Why not have ISel tag the stack slot with the MDNode instead of lowering to a machineinstr? -Chris From sabre at nondot.org Mon Jul 6 23:55:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 6 Jul 2009 23:55:58 -0500 Subject: [llvm-commits] CVS: llvm-www/Users.html Message-ID: <200907070455.n674tw7P018334@zion.cs.uiuc.edu> Changes in directory llvm-www: Users.html updated: 1.50 -> 1.51 --- Log message: Mention NVIDIA's OpenCL implementation, ok'd by Christopher Lamb. --- Diffs of the changes: (+8 -1) Users.html | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletion(-) Index: llvm-www/Users.html diff -u llvm-www/Users.html:1.50 llvm-www/Users.html:1.51 --- llvm-www/Users.html:1.50 Sun Mar 29 13:47:42 2009 +++ llvm-www/Users.html Mon Jul 6 23:54:48 2009 @@ -108,6 +108,13 @@ Compiler for stack machine architecture + + + NVIDIA + OpenCL runtime compiler (Clang + LLVM) + + + Rapidmind @@ -440,6 +447,6 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!">
LLVM Development List
- Last modified: $Date: 2009/03/29 18:47:42 $ + Last modified: $Date: 2009/07/07 04:54:48 $ From evan.cheng at apple.com Tue Jul 7 00:35:53 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Jul 2009 05:35:53 -0000 Subject: [llvm-commits] [llvm] r74895 - in /llvm/trunk: lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/Thumb2/thumb2-pack.ll Message-ID: <200907070535.n675ZrrN019683@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jul 7 00:35:52 2009 New Revision: 74895 URL: http://llvm.org/viewvc/llvm-project?rev=74895&view=rev Log: Add Thumb2 pkhbt / pkhtb. Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-pack.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=74895&r1=74894&r2=74895&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Jul 7 00:35:52 2009 @@ -966,9 +966,6 @@ (or (and (srl GPR:$src, (i32 8)), 0xFF0000), (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>; -///// -/// A8.6.137 REVSH -///// def t2REVSH : T2I<(outs GPR:$dst), (ins GPR:$src), "revsh", " $dst, $src", [(set GPR:$dst, @@ -976,7 +973,31 @@ (or (srl (and GPR:$src, 0xFFFF), (i32 8)), (shl GPR:$src, (i32 8))), i16))]>; -// FIXME: PKHxx etc. +def t2PKHBT : T2I<(outs GPR:$dst), (ins GPR:$src1, GPR:$src2, i32imm:$shamt), + "pkhbt", " $dst, $src1, $src2, LSL $shamt", + [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF), + (and (shl GPR:$src2, (i32 imm:$shamt)), + 0xFFFF0000)))]>; + +// Alternate cases for PKHBT where identities eliminate some nodes. +def : T2Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)), + (t2PKHBT GPR:$src1, GPR:$src2, 0)>; +def : T2Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)), + (t2PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>; + +def t2PKHTB : T2I<(outs GPR:$dst), (ins GPR:$src1, GPR:$src2, i32imm:$shamt), + "pkhtb", " $dst, $src1, $src2, ASR $shamt", + [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000), + (and (sra GPR:$src2, imm16_31:$shamt), + 0xFFFF)))]>; + +// Alternate cases for PKHTB where identities eliminate some nodes. Note that +// a shift amount of 0 is *not legal* here, it is PKHBT instead. +def : T2Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, (i32 16))), + (t2PKHTB GPR:$src1, GPR:$src2, 16)>; +def : T2Pat<(or (and GPR:$src1, 0xFFFF0000), + (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)), + (t2PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>; //===----------------------------------------------------------------------===// // Comparison Instructions... Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-pack.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-pack.ll?rev=74895&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-pack.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-pack.ll Tue Jul 7 00:35:52 2009 @@ -0,0 +1,73 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | \ +; RUN: grep pkhbt | count 5 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | \ +; RUN: grep pkhtb | count 4 + +define i32 @test1(i32 %X, i32 %Y) { + %tmp1 = and i32 %X, 65535 ; [#uses=1] + %tmp4 = shl i32 %Y, 16 ; [#uses=1] + %tmp5 = or i32 %tmp4, %tmp1 ; [#uses=1] + ret i32 %tmp5 +} + +define i32 @test1a(i32 %X, i32 %Y) { + %tmp19 = and i32 %X, 65535 ; [#uses=1] + %tmp37 = shl i32 %Y, 16 ; [#uses=1] + %tmp5 = or i32 %tmp37, %tmp19 ; [#uses=1] + ret i32 %tmp5 +} + +define i32 @test2(i32 %X, i32 %Y) { + %tmp1 = and i32 %X, 65535 ; [#uses=1] + %tmp3 = shl i32 %Y, 12 ; [#uses=1] + %tmp4 = and i32 %tmp3, -65536 ; [#uses=1] + %tmp57 = or i32 %tmp4, %tmp1 ; [#uses=1] + ret i32 %tmp57 +} + +define i32 @test3(i32 %X, i32 %Y) { + %tmp19 = and i32 %X, 65535 ; [#uses=1] + %tmp37 = shl i32 %Y, 18 ; [#uses=1] + %tmp5 = or i32 %tmp37, %tmp19 ; [#uses=1] + ret i32 %tmp5 +} + +define i32 @test4(i32 %X, i32 %Y) { + %tmp1 = and i32 %X, 65535 ; [#uses=1] + %tmp3 = and i32 %Y, -65536 ; [#uses=1] + %tmp46 = or i32 %tmp3, %tmp1 ; [#uses=1] + ret i32 %tmp46 +} + +define i32 @test5(i32 %X, i32 %Y) { + %tmp17 = and i32 %X, -65536 ; [#uses=1] + %tmp2 = bitcast i32 %Y to i32 ; [#uses=1] + %tmp4 = lshr i32 %tmp2, 16 ; [#uses=2] + %tmp5 = or i32 %tmp4, %tmp17 ; [#uses=1] + ret i32 %tmp5 +} + +define i32 @test5a(i32 %X, i32 %Y) { + %tmp110 = and i32 %X, -65536 ; [#uses=1] + %tmp37 = lshr i32 %Y, 16 ; [#uses=1] + %tmp39 = bitcast i32 %tmp37 to i32 ; [#uses=1] + %tmp5 = or i32 %tmp39, %tmp110 ; [#uses=1] + ret i32 %tmp5 +} + +define i32 @test6(i32 %X, i32 %Y) { + %tmp1 = and i32 %X, -65536 ; [#uses=1] + %tmp37 = lshr i32 %Y, 12 ; [#uses=1] + %tmp38 = bitcast i32 %tmp37 to i32 ; [#uses=1] + %tmp4 = and i32 %tmp38, 65535 ; [#uses=1] + %tmp59 = or i32 %tmp4, %tmp1 ; [#uses=1] + ret i32 %tmp59 +} + +define i32 @test7(i32 %X, i32 %Y) { + %tmp1 = and i32 %X, -65536 ; [#uses=1] + %tmp3 = ashr i32 %Y, 18 ; [#uses=1] + %tmp4 = and i32 %tmp3, 65535 ; [#uses=1] + %tmp57 = or i32 %tmp4, %tmp1 ; [#uses=1] + ret i32 %tmp57 +} From sanjiv.gupta at microchip.com Tue Jul 7 03:04:53 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Tue, 07 Jul 2009 08:04:53 -0000 Subject: [llvm-commits] [llvm] r74898 - /llvm/trunk/lib/CodeGen/PHIElimination.cpp Message-ID: <200907070804.n6784sHX030896@zion.cs.uiuc.edu> Author: sgupta Date: Tue Jul 7 03:04:51 2009 New Revision: 74898 URL: http://llvm.org/viewvc/llvm-project?rev=74898&view=rev Log: if the terminator is a branch depending upon the side effects of a previous cmp; a copy can not be inserted here if the copy insn also has side effects. We don't have access to the attributes of copy insn here; so just play safe by finding a safe locations for branch terminators. Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=74898&r1=74897&r2=74898&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Tue Jul 7 03:04:51 2009 @@ -169,9 +169,15 @@ return MBB.begin(); // If this basic block does not contain an invoke, then control flow always - // reaches the end of it, so place the copy there. The logic below works in - // this case too, but is more expensive. - if (!isa(MBB.getBasicBlock()->getTerminator())) + // reaches the end of it, so place the copy there. + // If the terminator is a branch depending upon the side effects of a + // previous cmp; a copy can not be inserted here if the copy insn also + // side effects. We don't have access to the attributes of copy insn here; + // so just play safe by finding a safe locations for branch terminators. + // + // The logic below works in this case too, but is more expensive. + const TerminatorInst *TermInst = MBB.getBasicBlock()->getTerminator(); + if (!(isa(TermInst) || isa(TermInst))) return MBB.getFirstTerminator(); // Discover any definition/uses in this basic block. From aaronngray.lists at googlemail.com Tue Jul 7 10:27:47 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Tue, 7 Jul 2009 16:27:47 +0100 Subject: [llvm-commits] [patch] JITCodeEmitter speedup patch Message-ID: <9719867c0907070827r60eb90c2q52c6a3fa52b933d7@mail.gmail.com> You probably won't want this patch, premature optmization and all that, but I will send it anyway as I had ti ready to send once the ObjectCodeEmitter patch when in removing the cruft that was standing in the way in MachineCodeEmitter. It also has a extend() method for extending the buffer and continuing if th buffer overfolws. And a reserveBytes that can be used in conjunction with the raw*emit methods to allow a whole instruction to be output without any buffer checking. This patch relies on the generically parameterized *CodeEmitters for its performance. And would its performance would be overridded buy the use of vitutal methods for the emit methods. Aaaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090707/4d56bb8a/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: JITCodeEmitter.patch Type: application/octet-stream Size: 9012 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090707/4d56bb8a/attachment.obj From foldr at codedgers.com Tue Jul 7 11:07:47 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 07 Jul 2009 16:07:47 -0000 Subject: [llvm-commits] [llvm] r74903 - /llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200907071607.n67G7m1P019006@zion.cs.uiuc.edu> Author: foldr Date: Tue Jul 7 11:07:36 2009 New Revision: 74903 URL: http://llvm.org/viewvc/llvm-project?rev=74903&view=rev Log: Comment fix. Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=74903&r1=74902&r2=74903&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Tue Jul 7 11:07:36 2009 @@ -81,11 +81,10 @@ } // checkNumberOfArguments - Ensure that the number of args in d is -// less than or equal to min_arguments, otherwise throw an exception. +// greater than or equal to min_arguments, otherwise throw an exception. void checkNumberOfArguments (const DagInit* d, unsigned min_arguments) { if (!d || d->getNumArgs() < min_arguments) - throw d->getOperator()->getAsString() - + ": too few arguments!"; + throw d->getOperator()->getAsString() + ": too few arguments!"; } // isDagEmpty - is this DAG marked with an empty marker? From foldr at codedgers.com Tue Jul 7 11:08:11 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 07 Jul 2009 16:08:11 -0000 Subject: [llvm-commits] [llvm] r74904 - /llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200907071608.n67G8BeX019029@zion.cs.uiuc.edu> Author: foldr Date: Tue Jul 7 11:08:11 2009 New Revision: 74904 URL: http://llvm.org/viewvc/llvm-project?rev=74904&view=rev Log: Refactoring. Make isList(), isSwitch() and isParameter() member functions of OptionDescription. Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=74904&r1=74903&r2=74904&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Tue Jul 7 11:08:11 2009 @@ -138,20 +138,21 @@ /// OptionType - One of six different option types. See the /// documentation for detailed description of differences. namespace OptionType { + enum OptionType { Alias, Switch, Parameter, ParameterList, Prefix, PrefixList}; -bool IsList (OptionType t) { - return (t == ParameterList || t == PrefixList); -} + bool IsList (OptionType t) { + return (t == ParameterList || t == PrefixList); + } -bool IsSwitch (OptionType t) { - return (t == Switch); -} + bool IsSwitch (OptionType t) { + return (t == Switch); + } -bool IsParameter (OptionType t) { - return (t == Parameter || t == Prefix); -} + bool IsParameter (OptionType t) { + return (t == Parameter || t == Prefix); + } } @@ -228,6 +229,15 @@ bool isReallyHidden() const; void setReallyHidden(); + bool isParameter() const + { return OptionType::IsParameter(this->Type); } + + bool isSwitch() const + { return OptionType::IsSwitch(this->Type); } + + bool isList() const + { return OptionType::IsList(this->Type); } + }; void OptionDescription::Merge (const OptionDescription& other) @@ -960,7 +970,7 @@ if (TestName == "switch_on") { const OptionDescription& OptDesc = OptDescs.FindOption(OptName); - if (!OptionType::IsSwitch(OptDesc.Type)) + if (!OptDesc.isSwitch()) throw OptName + ": incorrect option type - should be a switch!"; O << OptDesc.GenVariableName(); return true; @@ -983,7 +993,7 @@ } else { const OptionDescription& OptDesc = OptDescs.FindOption(OptName); - if (OptionType::IsSwitch(OptDesc.Type)) + if (OptDesc.isSwitch()) throw OptName + ": incorrect option type - should be a list or parameter!"; O << Test << OptDesc.GenVariableName() << ".empty()"; @@ -1007,13 +1017,13 @@ const OptionDescription& OptDesc = OptDescs.FindOption(OptName); if (TestName == "parameter_equals") { - if (!OptionType::IsParameter(OptDesc.Type)) + if (!OptDesc.isParameter()) throw OptName + ": incorrect option type - should be a parameter!"; O << OptDesc.GenVariableName() << " == \"" << OptArg << "\""; return true; } else if (TestName == "element_in_list") { - if (!OptionType::IsList(OptDesc.Type)) + if (!OptDesc.isList()) throw OptName + ": incorrect option type - should be a list!"; const std::string& VarName = OptDesc.GenVariableName(); O << "std::find(" << VarName << ".begin(),\n" @@ -1463,14 +1473,14 @@ if (D.isMultiVal()) throw std::string("Can't use unpack_values with multi-valued options!"); - if (OptionType::IsList(D.Type)) { + if (D.isList()) { O << IndentLevel << "for (" << D.GenTypeDeclaration() << "::iterator B = " << D.GenVariableName() << ".begin(),\n" << IndentLevel << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n" << IndentLevel << Indent1 << "llvm::SplitString(*B, vec, \",\");\n"; } - else if (OptionType::IsParameter(D.Type)){ + else if (D.isParameter()){ O << Indent3 << "llvm::SplitString(" << D.GenVariableName() << ", vec, \",\");\n"; } @@ -1686,15 +1696,15 @@ O << ", cl::Prefix"; if (val.isRequired()) { - if (OptionType::IsList(val.Type) && !val.isMultiVal()) + if (val.isList() && !val.isMultiVal()) O << ", cl::OneOrMore"; else O << ", cl::Required"; } - else if (val.isOneOrMore() && OptionType::IsList(val.Type)) { + else if (val.isOneOrMore() && val.isList()) { O << ", cl::OneOrMore"; } - else if (val.isZeroOrOne() && OptionType::IsList(val.Type)) { + else if (val.isZeroOrOne() && val.isList()) { O << ", cl::ZeroOrOne"; } From foldr at codedgers.com Tue Jul 7 11:08:41 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 07 Jul 2009 16:08:41 -0000 Subject: [llvm-commits] [llvm] r74905 - in /llvm/trunk: include/llvm/CompilerDriver/Common.td utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200907071608.n67G8fvx019058@zion.cs.uiuc.edu> Author: foldr Date: Tue Jul 7 11:08:41 2009 New Revision: 74905 URL: http://llvm.org/viewvc/llvm-project?rev=74905&view=rev Log: Add an 'init' option property. Makes possible to provide default values for options defined in plugins (same as cl::init). Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Common.td?rev=74905&r1=74904&r2=74905&view=diff ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/Common.td (original) +++ llvm/trunk/include/llvm/CompilerDriver/Common.td Tue Jul 7 11:08:41 2009 @@ -39,6 +39,7 @@ def extern; def help; def hidden; +def init; def multi_val; def one_or_more; def really_hidden; @@ -51,6 +52,10 @@ // The 'case' construct. def case; +// Boolean constants. +def true; +def false; + // Boolean operators. def and; def or; Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=74905&r1=74904&r2=74905&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Tue Jul 7 11:08:41 2009 @@ -187,11 +187,12 @@ unsigned Flags; std::string Help; unsigned MultiVal; + Init* InitVal; OptionDescription(OptionType::OptionType t = OptionType::Switch, const std::string& n = "", const std::string& h = DefaultHelpString) - : Type(t), Name(n), Flags(0x0), Help(h), MultiVal(1) + : Type(t), Name(n), Flags(0x0), Help(h), MultiVal(1), InitVal(0) {} /// GenTypeDeclaration - Returns the C++ variable type of this @@ -447,6 +448,7 @@ AddHandler("extern", &CollectOptionProperties::onExtern); AddHandler("help", &CollectOptionProperties::onHelp); AddHandler("hidden", &CollectOptionProperties::onHidden); + AddHandler("init", &CollectOptionProperties::onInit); AddHandler("multi_val", &CollectOptionProperties::onMultiVal); AddHandler("one_or_more", &CollectOptionProperties::onOneOrMore); AddHandler("really_hidden", &CollectOptionProperties::onReallyHidden); @@ -490,6 +492,20 @@ optDesc_.setRequired(); } + void onInit (const DagInit* d) { + checkNumberOfArguments(d, 1); + Init* i = d->getArg(0); + const std::string& str = i->getAsString(); + + bool correct = optDesc_.isParameter() && dynamic_cast(i); + correct |= (optDesc_.isSwitch() && (str == "true" || str == "false")); + + if (!correct) + throw std::string("Incorrect usage of the 'init' option property!"); + + optDesc_.InitVal = i; + } + void onOneOrMore (const DagInit* d) { checkNumberOfArguments(d, 0); if (optDesc_.isRequired() || optDesc_.isZeroOrOne()) @@ -1716,7 +1732,12 @@ } if (val.MultiVal > 1) - O << ", cl::multi_val(" << val.MultiVal << ")"; + O << ", cl::multi_val(" << val.MultiVal << ')'; + + if (val.InitVal) { + const std::string& str = val.InitVal->getAsString(); + O << ", cl::init(" << str << ')'; + } if (!val.Help.empty()) O << ", cl::desc(\"" << val.Help << "\")"; From foldr at codedgers.com Tue Jul 7 11:09:06 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 07 Jul 2009 16:09:06 -0000 Subject: [llvm-commits] [llvm] r74906 - /llvm/trunk/include/llvm/CompilerDriver/Common.td Message-ID: <200907071609.n67G96iS019082@zion.cs.uiuc.edu> Author: foldr Date: Tue Jul 7 11:09:05 2009 New Revision: 74906 URL: http://llvm.org/viewvc/llvm-project?rev=74906&view=rev Log: s/llvmc2/llvmc/ Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Common.td?rev=74906&r1=74905&r2=74906&view=diff ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/Common.td (original) +++ llvm/trunk/include/llvm/CompilerDriver/Common.td Tue Jul 7 11:09:05 2009 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file contains common definitions used in llvmc2 tool description files. +// This file contains common definitions used in llvmc tool description files. // //===----------------------------------------------------------------------===// From foldr at codedgers.com Tue Jul 7 11:09:29 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 07 Jul 2009 16:09:29 -0000 Subject: [llvm-commits] [llvm] r74907 - /llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Message-ID: <200907071609.n67G9Ujs019102@zion.cs.uiuc.edu> Author: foldr Date: Tue Jul 7 11:09:29 2009 New Revision: 74907 URL: http://llvm.org/viewvc/llvm-project?rev=74907&view=rev Log: Documentation update. Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst?rev=74907&r1=74906&r2=74907&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst (original) +++ llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Tue Jul 7 11:09:29 2009 @@ -347,6 +347,12 @@ 3))``. Only list options can have this attribute; you can, however, use the ``one_or_more`` and ``zero_or_one`` properties. + - ``init`` - this option has a default value, either a string (if it is a + parameter), or a boolean (if it is a switch; boolean constants are called + ``true`` and ``false``). List options can't have this attribute. Usage + examples: ``(switch_option "foo", (init true))``; ``(prefix_option "bar", + (init "baz"))``. + - ``extern`` - this option is defined in some other plugin, see below. External options From foldr at codedgers.com Tue Jul 7 11:09:49 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 07 Jul 2009 16:09:49 -0000 Subject: [llvm-commits] [llvm] r74908 - /llvm/trunk/docs/CompilerDriver.html Message-ID: <200907071609.n67G9nVJ019123@zion.cs.uiuc.edu> Author: foldr Date: Tue Jul 7 11:09:48 2009 New Revision: 74908 URL: http://llvm.org/viewvc/llvm-project?rev=74908&view=rev Log: Regenerate. Modified: llvm/trunk/docs/CompilerDriver.html Modified: llvm/trunk/docs/CompilerDriver.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CompilerDriver.html?rev=74908&r1=74907&r2=74908&view=diff ============================================================================== --- llvm/trunk/docs/CompilerDriver.html (original) +++ llvm/trunk/docs/CompilerDriver.html Tue Jul 7 11:09:48 2009 @@ -341,6 +341,11 @@ special cases). Usage example: (parameter_list_option "foo", (multi_val 3)). Only list options can have this attribute; you can, however, use the one_or_more and zero_or_one properties. +
  • init - this option has a default value, either a string (if it is a +parameter), or a boolean (if it is a switch; boolean constants are called +true and false). List options can't have this attribute. Usage +examples: (switch_option "foo", (init true)); (prefix_option "bar", +(init "baz")).
  • extern - this option is defined in some other plugin, see below.
  • From parseerror at gmail.com Tue Jul 7 09:46:19 2009 From: parseerror at gmail.com (Ryan Flynn) Date: Tue, 7 Jul 2009 10:46:19 -0400 Subject: [llvm-commits] patch: CodeGen/BinaryObject.h explicit typecast Message-ID: BinaryObject.h was implicitly converting between uint{16,32,64}_t to uint8_t (via 'foo & 255'), i replaced this with an explicit (uint8_t) cast which is equivalent, faster and more correct (silences type-related warnings). Also, following coding standards I replaced post-increment with pre-increment. Ryan -------------- next part -------------- A non-text attachment was scrubbed... Name: CodeGen-BinaryObject-explicit-typecast.patch Type: application/octet-stream Size: 7850 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090707/0b5f58f0/attachment.obj From andrelct at dcc.ufmg.br Tue Jul 7 11:25:06 2009 From: andrelct at dcc.ufmg.br (Andre Tavares) Date: Tue, 07 Jul 2009 13:25:06 -0300 Subject: [llvm-commits] SSI bug fix Message-ID: <4A5376E2.2000804@dcc.ufmg.br> Hello, I have fixed the bug found by Nick on the SSI code. The attachment contains the patch for that code. The bug is described here: http://llvm.org/bugs/show_bug.cgi?id=4511 Regards, -- Andre Tavares Master Student in Computer Science - UFMG - Brasil http://dcc.ufmg.br/~andrelct -------------- next part -------------- A non-text attachment was scrubbed... Name: ssi.patch Type: text/x-patch Size: 13323 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090707/48377df0/attachment.bin From resistor at mac.com Tue Jul 7 11:31:28 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Jul 2009 16:31:28 -0000 Subject: [llvm-commits] [llvm] r74910 - /llvm/trunk/lib/Analysis/DebugInfo.cpp Message-ID: <200907071631.n67GVS8h019766@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 11:31:25 2009 New Revision: 74910 URL: http://llvm.org/viewvc/llvm-project?rev=74910&view=rev Log: Revert part of r74873 that broke Clang's debug info generation. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=74910&r1=74909&r2=74910&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Jul 7 11:31:25 2009 @@ -18,7 +18,6 @@ #include "llvm/Intrinsics.h" #include "llvm/IntrinsicInst.h" #include "llvm/Instructions.h" -#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Support/Dwarf.h" @@ -456,15 +455,14 @@ DIFactory::DIFactory(Module &m) : M(m), StopPointFn(0), FuncStartFn(0), RegionStartFn(0), RegionEndFn(0), DeclareFn(0) { - EmptyStructPtr = - M.getContext().getPointerTypeUnqual(M.getContext().getStructType()); + EmptyStructPtr = PointerType::getUnqual(StructType::get()); } /// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'. /// This is only valid when the descriptor is non-null. Constant *DIFactory::getCastToEmpty(DIDescriptor D) { - if (D.isNull()) return M.getContext().getNullValue(EmptyStructPtr); - return M.getContext().getConstantExprBitCast(D.getGV(), EmptyStructPtr); + if (D.isNull()) return Constant::getNullValue(EmptyStructPtr); + return ConstantExpr::getBitCast(D.getGV(), EmptyStructPtr); } Constant *DIFactory::GetTagConstant(unsigned TAG) { @@ -480,21 +478,21 @@ // Return Constant if previously defined. if (Slot) return Slot; - const PointerType *DestTy = M.getContext().getPointerTypeUnqual(Type::Int8Ty); + const PointerType *DestTy = PointerType::getUnqual(Type::Int8Ty); // If empty string then use a i8* null instead. if (String.empty()) - return Slot = M.getContext().getConstantPointerNull(DestTy); + return Slot = ConstantPointerNull::get(DestTy); // Construct string as an llvm constant. - Constant *ConstStr = M.getContext().getConstantArray(String); + Constant *ConstStr = ConstantArray::get(String); // Otherwise create and return a new string global. GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true, GlobalVariable::InternalLinkage, ConstStr, ".str", &M); StrGV->setSection("llvm.metadata"); - return Slot = M.getContext().getConstantExprBitCast(StrGV, DestTy); + return Slot = ConstantExpr::getBitCast(StrGV, DestTy); } //===----------------------------------------------------------------------===// @@ -506,12 +504,10 @@ DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) { SmallVector Elts; - LLVMContext& Ctxt = M.getContext(); - for (unsigned i = 0; i != NumTys; ++i) Elts.push_back(getCastToEmpty(Tys[i])); - Constant *Init = Ctxt.getConstantArray(Ctxt.getArrayType(EmptyStructPtr, + Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr, Elts.size()), Elts.data(), Elts.size()); // If we already have this array, just return the uniqued version. @@ -531,12 +527,11 @@ DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) { Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_subrange_type), - M.getContext().getConstantInt(Type::Int64Ty, Lo), - M.getContext().getConstantInt(Type::Int64Ty, Hi) + ConstantInt::get(Type::Int64Ty, Lo), + ConstantInt::get(Type::Int64Ty, Hi) }; - Constant *Init = - M.getContext().getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); // If we already have this range, just return the uniqued version. DIDescriptor &Entry = SimpleConstantCache[Init]; @@ -564,22 +559,20 @@ bool isOptimized, const char *Flags, unsigned RunTimeVer) { - LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_compile_unit), - Ctxt.getNullValue(EmptyStructPtr), - Ctxt.getConstantInt(Type::Int32Ty, LangID), + Constant::getNullValue(EmptyStructPtr), + ConstantInt::get(Type::Int32Ty, LangID), GetStringConstant(Filename), GetStringConstant(Directory), GetStringConstant(Producer), - Ctxt.getConstantInt(Type::Int1Ty, isMain), - Ctxt.getConstantInt(Type::Int1Ty, isOptimized), + ConstantInt::get(Type::Int1Ty, isMain), + ConstantInt::get(Type::Int1Ty, isOptimized), GetStringConstant(Flags), - Ctxt.getConstantInt(Type::Int32Ty, RunTimeVer) + ConstantInt::get(Type::Int32Ty, RunTimeVer) }; - Constant *Init = - Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.compile_unit.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -594,11 +587,10 @@ Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_enumerator), GetStringConstant(Name), - M.getContext().getConstantInt(Type::Int64Ty, Val) + ConstantInt::get(Type::Int64Ty, Val) }; - Constant *Init = - M.getContext().getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.enumerator.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -618,23 +610,20 @@ uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, unsigned Encoding) { - - LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_base_type), getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - Ctxt.getConstantInt(Type::Int32Ty, LineNumber), - Ctxt.getConstantInt(Type::Int64Ty, SizeInBits), - Ctxt.getConstantInt(Type::Int64Ty, AlignInBits), - Ctxt.getConstantInt(Type::Int64Ty, OffsetInBits), - Ctxt.getConstantInt(Type::Int32Ty, Flags), - Ctxt.getConstantInt(Type::Int32Ty, Encoding) + ConstantInt::get(Type::Int32Ty, LineNumber), + ConstantInt::get(Type::Int64Ty, SizeInBits), + ConstantInt::get(Type::Int64Ty, AlignInBits), + ConstantInt::get(Type::Int64Ty, OffsetInBits), + ConstantInt::get(Type::Int32Ty, Flags), + ConstantInt::get(Type::Int32Ty, Encoding) }; - Constant *Init = - Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.basictype.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -656,23 +645,20 @@ uint64_t OffsetInBits, unsigned Flags, DIType DerivedFrom) { - - LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(Tag), getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - Ctxt.getConstantInt(Type::Int32Ty, LineNumber), - Ctxt.getConstantInt(Type::Int64Ty, SizeInBits), - Ctxt.getConstantInt(Type::Int64Ty, AlignInBits), - Ctxt.getConstantInt(Type::Int64Ty, OffsetInBits), - Ctxt.getConstantInt(Type::Int32Ty, Flags), + ConstantInt::get(Type::Int32Ty, LineNumber), + ConstantInt::get(Type::Int64Ty, SizeInBits), + ConstantInt::get(Type::Int64Ty, AlignInBits), + ConstantInt::get(Type::Int64Ty, OffsetInBits), + ConstantInt::get(Type::Int32Ty, Flags), getCastToEmpty(DerivedFrom) }; - Constant *Init = - Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.derivedtype.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -695,24 +681,23 @@ DIType DerivedFrom, DIArray Elements, unsigned RuntimeLang) { - LLVMContext& Ctxt = M.getContext(); + Constant *Elts[] = { GetTagConstant(Tag), getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - Ctxt.getConstantInt(Type::Int32Ty, LineNumber), - Ctxt.getConstantInt(Type::Int64Ty, SizeInBits), - Ctxt.getConstantInt(Type::Int64Ty, AlignInBits), - Ctxt.getConstantInt(Type::Int64Ty, OffsetInBits), - Ctxt.getConstantInt(Type::Int32Ty, Flags), + ConstantInt::get(Type::Int32Ty, LineNumber), + ConstantInt::get(Type::Int64Ty, SizeInBits), + ConstantInt::get(Type::Int64Ty, AlignInBits), + ConstantInt::get(Type::Int64Ty, OffsetInBits), + ConstantInt::get(Type::Int32Ty, Flags), getCastToEmpty(DerivedFrom), getCastToEmpty(Elements), - Ctxt.getConstantInt(Type::Int32Ty, RuntimeLang) + ConstantInt::get(Type::Int32Ty, RuntimeLang) }; - Constant *Init = - Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.composite.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -735,23 +720,21 @@ bool isLocalToUnit, bool isDefinition) { - LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_subprogram), - Ctxt.getNullValue(EmptyStructPtr), + Constant::getNullValue(EmptyStructPtr), getCastToEmpty(Context), GetStringConstant(Name), GetStringConstant(DisplayName), GetStringConstant(LinkageName), getCastToEmpty(CompileUnit), - Ctxt.getConstantInt(Type::Int32Ty, LineNo), + ConstantInt::get(Type::Int32Ty, LineNo), getCastToEmpty(Type), - Ctxt.getConstantInt(Type::Int1Ty, isLocalToUnit), - Ctxt.getConstantInt(Type::Int1Ty, isDefinition) + ConstantInt::get(Type::Int1Ty, isLocalToUnit), + ConstantInt::get(Type::Int1Ty, isDefinition) }; - Constant *Init = - Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.subprogram.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -769,25 +752,22 @@ DICompileUnit CompileUnit, unsigned LineNo, DIType Type,bool isLocalToUnit, bool isDefinition, llvm::GlobalVariable *Val) { - - LLVMContext& Ctxt = M.getContext(); Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_variable), - Ctxt.getNullValue(EmptyStructPtr), + Constant::getNullValue(EmptyStructPtr), getCastToEmpty(Context), GetStringConstant(Name), GetStringConstant(DisplayName), GetStringConstant(LinkageName), getCastToEmpty(CompileUnit), - Ctxt.getConstantInt(Type::Int32Ty, LineNo), + ConstantInt::get(Type::Int32Ty, LineNo), getCastToEmpty(Type), - Ctxt.getConstantInt(Type::Int1Ty, isLocalToUnit), - Ctxt.getConstantInt(Type::Int1Ty, isDefinition), - Ctxt.getConstantExprBitCast(Val, EmptyStructPtr) + ConstantInt::get(Type::Int1Ty, isLocalToUnit), + ConstantInt::get(Type::Int1Ty, isDefinition), + ConstantExpr::getBitCast(Val, EmptyStructPtr) }; - Constant *Init = - Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.global_variable.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -803,19 +783,16 @@ const std::string &Name, DICompileUnit CompileUnit, unsigned LineNo, DIType Type) { - LLVMContext& Ctxt = M.getContext(); - Constant *Elts[] = { GetTagConstant(Tag), getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - Ctxt.getConstantInt(Type::Int32Ty, LineNo), + ConstantInt::get(Type::Int32Ty, LineNo), getCastToEmpty(Type) }; - Constant *Init = - Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.variable.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -834,8 +811,7 @@ getCastToEmpty(Context) }; - Constant *Init = - M.getContext().getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.block.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -862,8 +838,8 @@ // Invoke llvm.dbg.stoppoint Value *Args[] = { - M.getContext().getConstantInt(llvm::Type::Int32Ty, LineNo), - M.getContext().getConstantInt(llvm::Type::Int32Ty, ColNo), + llvm::ConstantInt::get(llvm::Type::Int32Ty, LineNo), + llvm::ConstantInt::get(llvm::Type::Int32Ty, ColNo), getCastToEmpty(CU) }; CallInst::Create(StopPointFn, Args, Args+3, "", BB); @@ -966,7 +942,7 @@ const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type"); if (!Ty) return 0; - Ty = V->getParent()->getContext().getPointerType(Ty, 0); + Ty = PointerType::get(Ty, 0); Value *Val = V->stripPointerCasts(); for (Value::use_iterator I = Val->use_begin(), E = Val->use_end(); From foldr at codedgers.com Tue Jul 7 11:39:35 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 07 Jul 2009 16:39:35 -0000 Subject: [llvm-commits] [llvm] r74912 - /llvm/trunk/tools/llvmc/example/mcc16/driver/Main.cpp Message-ID: <200907071639.n67GdaGU020068@zion.cs.uiuc.edu> Author: foldr Date: Tue Jul 7 11:39:33 2009 New Revision: 74912 URL: http://llvm.org/viewvc/llvm-project?rev=74912&view=rev Log: Show how to modify built-in options. Sanjiv complained about the need to maintain local changes to lib/CompilerDriver. Modified: llvm/trunk/tools/llvmc/example/mcc16/driver/Main.cpp Modified: llvm/trunk/tools/llvmc/example/mcc16/driver/Main.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/example/mcc16/driver/Main.cpp?rev=74912&r1=74911&r2=74912&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/example/mcc16/driver/Main.cpp (original) +++ llvm/trunk/tools/llvmc/example/mcc16/driver/Main.cpp Tue Jul 7 11:39:33 2009 @@ -7,8 +7,25 @@ // //===----------------------------------------------------------------------===// // -// Just include CompilerDriver/Main.inc. +// Usually this file just includes CompilerDriver/Main.inc, but here we apply +// some trickery to make the built-in '-save-temps' option hidden and enabled +// by default. // //===----------------------------------------------------------------------===// -#include "llvm/CompilerDriver/Main.inc" +#include "llvm/CompilerDriver/BuiltinOptions.h" +#include "llvm/CompilerDriver/ForceLinkage.h" + +namespace llvmc { + int Main(int argc, char** argv); +} + +int main(int argc, char** argv) { + + // HACK + SaveTemps = SaveTempsEnum::Obj; + SaveTemps.setHiddenFlag(llvm::cl::Hidden); + + llvmc::ForceLinkage(); + return llvmc::Main(argc, argv); +} From foldr at codedgers.com Tue Jul 7 11:43:49 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 07 Jul 2009 16:43:49 -0000 Subject: [llvm-commits] [llvm] r74913 - /llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Message-ID: <200907071643.n67Ghnjg020205@zion.cs.uiuc.edu> Author: foldr Date: Tue Jul 7 11:43:49 2009 New Revision: 74913 URL: http://llvm.org/viewvc/llvm-project?rev=74913&view=rev Log: Documentation update. Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst?rev=74913&r1=74912&r2=74913&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst (original) +++ llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Tue Jul 7 11:43:49 2009 @@ -368,7 +368,8 @@ (switch_option "E", (extern)) ... -See also the section on plugin `priorities`__. +If an external option has additional attributes besides 'extern', they are +ignored. See also the section on plugin `priorities`__. __ priorities_ From foldr at codedgers.com Tue Jul 7 11:44:22 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 07 Jul 2009 16:44:22 -0000 Subject: [llvm-commits] [llvm] r74914 - /llvm/trunk/docs/CompilerDriver.html Message-ID: <200907071644.n67GiN89020260@zion.cs.uiuc.edu> Author: foldr Date: Tue Jul 7 11:44:20 2009 New Revision: 74914 URL: http://llvm.org/viewvc/llvm-project?rev=74914&view=rev Log: Regenerate. Modified: llvm/trunk/docs/CompilerDriver.html Modified: llvm/trunk/docs/CompilerDriver.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CompilerDriver.html?rev=74914&r1=74913&r2=74914&view=diff ============================================================================== --- llvm/trunk/docs/CompilerDriver.html (original) +++ llvm/trunk/docs/CompilerDriver.html Tue Jul 7 11:44:20 2009 @@ -363,7 +363,8 @@ (switch_option "E", (extern)) ... -

    See also the section on plugin priorities.

    +

    If an external option has additional attributes besides 'extern', they are +ignored. See also the section on plugin priorities.

    From resistor at mac.com Tue Jul 7 11:56:28 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Jul 2009 16:56:28 -0000 Subject: [llvm-commits] [llvm] r74915 - /llvm/trunk/include/llvm/LLVMContext.h Message-ID: <200907071656.n67GuV2D020871@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 11:56:05 2009 New Revision: 74915 URL: http://llvm.org/viewvc/llvm-project?rev=74915&view=rev Log: This parameter should default to true, not false. Modified: llvm/trunk/include/llvm/LLVMContext.h Modified: llvm/trunk/include/llvm/LLVMContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=74915&r1=74914&r2=74915&view=diff ============================================================================== --- llvm/trunk/include/llvm/LLVMContext.h (original) +++ llvm/trunk/include/llvm/LLVMContext.h Tue Jul 7 11:56:05 2009 @@ -95,7 +95,7 @@ Constant* getConstantArray(const ArrayType* T, Constant* const* Vals, unsigned NumVals); Constant* getConstantArray(const std::string& Initializer, - bool AddNull = false); + bool AddNull = true); // ConstantExpr accessors Constant* getConstantExpr(unsigned Opcode, Constant* C1, Constant* C2); From mai4 at uiuc.edu Tue Jul 7 11:58:22 2009 From: mai4 at uiuc.edu (Haohui Mai) Date: Tue, 07 Jul 2009 16:58:22 -0000 Subject: [llvm-commits] [poolalloc] r74916 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/Steensgaard.cpp Message-ID: <200907071658.n67GwN4V020945@zion.cs.uiuc.edu> Author: mai4 Date: Tue Jul 7 11:58:21 2009 New Revision: 74916 URL: http://llvm.org/viewvc/llvm-project?rev=74916&view=rev Log: Don't delete ResultsGraph in SteensgaardDataStructures::releaseMyMemory() during destruction since it is deleted by DataStructures::releaseMemory(). Modified: poolalloc/trunk/include/dsa/DataStructure.h poolalloc/trunk/lib/DSA/Steensgaard.cpp Modified: poolalloc/trunk/include/dsa/DataStructure.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=74916&r1=74915&r2=74916&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DataStructure.h (original) +++ poolalloc/trunk/include/dsa/DataStructure.h Tue Jul 7 11:58:21 2009 @@ -140,13 +140,13 @@ virtual void releaseMemory(); - bool hasDSGraph(const Function &F) const { + virtual bool hasDSGraph(const Function &F) const { return DSInfo.find(&F) != DSInfo.end(); } /// getDSGraph - Return the data structure graph for the specified function. /// - DSGraph *getDSGraph(const Function &F) const { + virtual DSGraph *getDSGraph(const Function &F) const { hash_map::const_iterator I = DSInfo.find(&F); assert(I != DSInfo.end() && "Function not in module!"); return I->second; @@ -427,7 +427,7 @@ ResultGraph(NULL) {} ~SteensgaardDataStructures(); virtual bool runOnModule(Module &M); - virtual void releaseMyMemory(); + virtual void releaseMemory(); virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); @@ -436,8 +436,12 @@ /// getDSGraph - Return the data structure graph for the specified function. /// - DSGraph *getDSGraph(const Function &F) const { - return ResultGraph; + virtual DSGraph *getDSGraph(const Function &F) const { + return getResultGraph() ; + } + + virtual bool hasDSGraph(const Function &F) const { + return true; } /// getDSGraph - Return the data structure graph for the whole program. Modified: poolalloc/trunk/lib/DSA/Steensgaard.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Steensgaard.cpp?rev=74916&r1=74915&r2=74916&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Steensgaard.cpp (original) +++ poolalloc/trunk/lib/DSA/Steensgaard.cpp Tue Jul 7 11:58:21 2009 @@ -23,15 +23,14 @@ using namespace llvm; -SteensgaardDataStructures::~SteensgaardDataStructures() { - releaseMyMemory(); - assert(ResultGraph == 0 && "releaseMemory not called?"); -} +SteensgaardDataStructures::~SteensgaardDataStructures() { } void -SteensgaardDataStructures::releaseMyMemory() { - delete ResultGraph; +SteensgaardDataStructures::releaseMemory() { + // Here we don't need to delete the result graph, because it aliases with the + // GlobalsGraph, which is deleted by DataStructures::releaseMemory(). ResultGraph = 0; + DataStructures::releaseMemory(); } // print - Implement the Pass::print method... @@ -133,6 +132,8 @@ ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals); + // Assign the result graph to globals graph. It should be the same. + GlobalsGraph = ResultGraph; print(DOUT, &M); return false; } From gohman at apple.com Tue Jul 7 12:06:26 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 07 Jul 2009 17:06:26 -0000 Subject: [llvm-commits] [llvm] r74918 - in /llvm/trunk: include/llvm/Analysis/IVUsers.h include/llvm/Analysis/LoopVR.h include/llvm/Analysis/ScalarEvolution.h include/llvm/Analysis/ScalarEvolutionExpander.h include/llvm/Analysis/ScalarEvolutionExpressions.h lib/Analysis/IVUsers.cpp lib/Analysis/LoopVR.cpp lib/Analysis/ScalarEvolution.cpp lib/Analysis/ScalarEvolutionExpander.cpp lib/Transforms/Scalar/IndVarSimplify.cpp lib/Transforms/Scalar/LoopDeletion.cpp lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200907071706.n67H6SVd021298@zion.cs.uiuc.edu> Author: djg Date: Tue Jul 7 12:06:11 2009 New Revision: 74918 URL: http://llvm.org/viewvc/llvm-project?rev=74918&view=rev Log: Change all SCEV* to SCEV *. Modified: llvm/trunk/include/llvm/Analysis/IVUsers.h llvm/trunk/include/llvm/Analysis/LoopVR.h llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h llvm/trunk/lib/Analysis/IVUsers.cpp llvm/trunk/lib/Analysis/LoopVR.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/include/llvm/Analysis/IVUsers.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/IVUsers.h?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/IVUsers.h (original) +++ llvm/trunk/include/llvm/Analysis/IVUsers.h Tue Jul 7 12:06:11 2009 @@ -34,7 +34,7 @@ class IVStrideUse : public CallbackVH, public ilist_node { public: IVStrideUse(IVUsersOfOneStride *parent, - const SCEV* offset, + const SCEV *offset, Instruction* U, Value *O) : CallbackVH(U), Parent(parent), Offset(offset), OperandValToReplace(O), @@ -58,10 +58,10 @@ /// getOffset - Return the offset to add to a theoeretical induction /// variable that starts at zero and counts up by the stride to compute /// the value for the use. This always has the same type as the stride. - const SCEV* getOffset() const { return Offset; } + const SCEV *getOffset() const { return Offset; } /// setOffset - Assign a new offset to this use. - void setOffset(const SCEV* Val) { + void setOffset(const SCEV *Val) { Offset = Val; } @@ -96,7 +96,7 @@ IVUsersOfOneStride *Parent; /// Offset - The offset to add to the base induction expression. - const SCEV* Offset; + const SCEV *Offset; /// OperandValToReplace - The Value of the operand in the user instruction /// that this IVStrideUse is representing. @@ -158,7 +158,7 @@ /// initial value and the operand that uses the IV. ilist Users; - void addUser(const SCEV* Offset, Instruction *User, Value *Operand) { + void addUser(const SCEV *Offset, Instruction *User, Value *Operand) { Users.push_back(new IVStrideUse(this, Offset, User, Operand)); } }; @@ -178,12 +178,12 @@ /// IVUsesByStride - A mapping from the strides in StrideOrder to the /// uses in IVUses. - std::map IVUsesByStride; + std::map IVUsesByStride; /// StrideOrder - An ordering of the keys in IVUsesByStride that is stable: /// We use this to iterate over the IVUsesByStride collection without being /// dependent on random ordering of pointers in the process. - SmallVector StrideOrder; + SmallVector StrideOrder; private: virtual void getAnalysisUsage(AnalysisUsage &AU) const; @@ -203,7 +203,7 @@ /// getReplacementExpr - Return a SCEV expression which computes the /// value of the OperandValToReplace of the given IVStrideUse. - const SCEV* getReplacementExpr(const IVStrideUse &U) const; + const SCEV *getReplacementExpr(const IVStrideUse &U) const; void print(raw_ostream &OS, const Module* = 0) const; virtual void print(std::ostream &OS, const Module* = 0) const; Modified: llvm/trunk/include/llvm/Analysis/LoopVR.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopVR.h?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopVR.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopVR.h Tue Jul 7 12:06:11 2009 @@ -78,9 +78,9 @@ private: ConstantRange compute(Value *V); - ConstantRange getRange(const SCEV* S, Loop *L, ScalarEvolution &SE); + ConstantRange getRange(const SCEV *S, Loop *L, ScalarEvolution &SE); - ConstantRange getRange(const SCEV* S, const SCEV* T, ScalarEvolution &SE); + ConstantRange getRange(const SCEV *S, const SCEV *T, ScalarEvolution &SE); std::map Map; }; Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Tue Jul 7 12:06:11 2009 @@ -89,9 +89,9 @@ /// the same value, but which uses the concrete value Conc instead of the /// symbolic value. If this SCEV does not use the symbolic value, it /// returns itself. - virtual const SCEV* - replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + virtual const SCEV * + replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const = 0; /// dominates - Return true if elements that makes up this SCEV dominates @@ -134,9 +134,9 @@ virtual const Type *getType() const; virtual bool hasComputableLoopEvolution(const Loop *L) const; virtual void print(raw_ostream &OS) const; - virtual const SCEV* - replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + virtual const SCEV * + replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const; virtual bool dominates(BasicBlock *BB, DominatorTree *DT) const { @@ -184,7 +184,7 @@ /// Scalars - This is a cache of the scalars we have analyzed so far. /// - std::map Scalars; + std::map Scalars; /// BackedgeTakenInfo - Information about the backedge-taken count /// of a loop. This currently inclues an exact count and a maximum count. @@ -192,16 +192,16 @@ struct BackedgeTakenInfo { /// Exact - An expression indicating the exact backedge-taken count of /// the loop if it is known, or a SCEVCouldNotCompute otherwise. - const SCEV* Exact; + const SCEV *Exact; /// Exact - An expression indicating the least maximum backedge-taken /// count of the loop that is known, or a SCEVCouldNotCompute. - const SCEV* Max; + const SCEV *Max; - /*implicit*/ BackedgeTakenInfo(const SCEV* exact) : + /*implicit*/ BackedgeTakenInfo(const SCEV *exact) : Exact(exact), Max(exact) {} - BackedgeTakenInfo(const SCEV* exact, const SCEV* max) : + BackedgeTakenInfo(const SCEV *exact, const SCEV *max) : Exact(exact), Max(max) {} /// hasAnyInfo - Test whether this BackedgeTakenInfo contains any @@ -231,30 +231,30 @@ /// createSCEV - We know that there is no SCEV for the specified value. /// Analyze the expression. - const SCEV* createSCEV(Value *V); + const SCEV *createSCEV(Value *V); /// createNodeForPHI - Provide the special handling we need to analyze PHI /// SCEVs. - const SCEV* createNodeForPHI(PHINode *PN); + const SCEV *createNodeForPHI(PHINode *PN); /// createNodeForGEP - Provide the special handling we need to analyze GEP /// SCEVs. - const SCEV* createNodeForGEP(User *GEP); + const SCEV *createNodeForGEP(User *GEP); /// ReplaceSymbolicValueWithConcrete - This looks up the computed SCEV value /// for the specified instruction and replaces any references to the /// symbolic value SymName with the specified value. This is used during /// PHI resolution. void ReplaceSymbolicValueWithConcrete(Instruction *I, - const SCEV* SymName, - const SCEV* NewVal); + const SCEV *SymName, + const SCEV *NewVal); /// getBECount - Subtract the end and start values and divide by the step, /// rounding up, to get the number of times the backedge is executed. Return /// CouldNotCompute if an intermediate computation overflows. - const SCEV* getBECount(const SCEV* Start, - const SCEV* End, - const SCEV* Step); + const SCEV *getBECount(const SCEV *Start, + const SCEV *End, + const SCEV *Step); /// getBackedgeTakenInfo - Return the BackedgeTakenInfo for the given /// loop, lazily computing new values if the loop hasn't been analyzed @@ -292,7 +292,7 @@ /// ComputeLoadConstantCompareBackedgeTakenCount - Given an exit condition /// of 'icmp op load X, cst', try to see if we can compute the trip count. - const SCEV* + const SCEV * ComputeLoadConstantCompareBackedgeTakenCount(LoadInst *LI, Constant *RHS, const Loop *L, @@ -303,19 +303,19 @@ /// try to evaluate a few iterations of the loop until we get the exit /// condition gets a value of ExitWhen (true or false). If we cannot /// evaluate the trip count of the loop, return CouldNotCompute. - const SCEV* ComputeBackedgeTakenCountExhaustively(const Loop *L, + const SCEV *ComputeBackedgeTakenCountExhaustively(const Loop *L, Value *Cond, bool ExitWhen); /// HowFarToZero - Return the number of times a backedge comparing the /// specified value to zero will execute. If not computable, return /// CouldNotCompute. - const SCEV* HowFarToZero(const SCEV *V, const Loop *L); + const SCEV *HowFarToZero(const SCEV *V, const Loop *L); /// HowFarToNonZero - Return the number of times a backedge checking the /// specified value for nonzero will execute. If not computable, return /// CouldNotCompute. - const SCEV* HowFarToNonZero(const SCEV *V, const Loop *L); + const SCEV *HowFarToNonZero(const SCEV *V, const Loop *L); /// HowManyLessThans - Return the number of times a backedge containing the /// specified less-than comparison will execute. If not computable, return @@ -375,115 +375,115 @@ /// getSCEV - Return a SCEV expression handle for the full generality of the /// specified expression. - const SCEV* getSCEV(Value *V); + const SCEV *getSCEV(Value *V); - const SCEV* getConstant(ConstantInt *V); - const SCEV* getConstant(const APInt& Val); - const SCEV* getConstant(const Type *Ty, uint64_t V, bool isSigned = false); - const SCEV* getTruncateExpr(const SCEV* Op, const Type *Ty); - const SCEV* getZeroExtendExpr(const SCEV* Op, const Type *Ty); - const SCEV* getSignExtendExpr(const SCEV* Op, const Type *Ty); - const SCEV* getAnyExtendExpr(const SCEV* Op, const Type *Ty); - const SCEV* getAddExpr(SmallVectorImpl &Ops); - const SCEV* getAddExpr(const SCEV* LHS, const SCEV* RHS) { - SmallVector Ops; + const SCEV *getConstant(ConstantInt *V); + const SCEV *getConstant(const APInt& Val); + const SCEV *getConstant(const Type *Ty, uint64_t V, bool isSigned = false); + const SCEV *getTruncateExpr(const SCEV *Op, const Type *Ty); + const SCEV *getZeroExtendExpr(const SCEV *Op, const Type *Ty); + const SCEV *getSignExtendExpr(const SCEV *Op, const Type *Ty); + const SCEV *getAnyExtendExpr(const SCEV *Op, const Type *Ty); + const SCEV *getAddExpr(SmallVectorImpl &Ops); + const SCEV *getAddExpr(const SCEV *LHS, const SCEV *RHS) { + SmallVector Ops; Ops.push_back(LHS); Ops.push_back(RHS); return getAddExpr(Ops); } - const SCEV* getAddExpr(const SCEV* Op0, const SCEV* Op1, - const SCEV* Op2) { - SmallVector Ops; + const SCEV *getAddExpr(const SCEV *Op0, const SCEV *Op1, + const SCEV *Op2) { + SmallVector Ops; Ops.push_back(Op0); Ops.push_back(Op1); Ops.push_back(Op2); return getAddExpr(Ops); } - const SCEV* getMulExpr(SmallVectorImpl &Ops); - const SCEV* getMulExpr(const SCEV* LHS, const SCEV* RHS) { - SmallVector Ops; + const SCEV *getMulExpr(SmallVectorImpl &Ops); + const SCEV *getMulExpr(const SCEV *LHS, const SCEV *RHS) { + SmallVector Ops; Ops.push_back(LHS); Ops.push_back(RHS); return getMulExpr(Ops); } - const SCEV* getUDivExpr(const SCEV* LHS, const SCEV* RHS); - const SCEV* getAddRecExpr(const SCEV* Start, const SCEV* Step, + const SCEV *getUDivExpr(const SCEV *LHS, const SCEV *RHS); + const SCEV *getAddRecExpr(const SCEV *Start, const SCEV *Step, const Loop *L); - const SCEV* getAddRecExpr(SmallVectorImpl &Operands, + const SCEV *getAddRecExpr(SmallVectorImpl &Operands, const Loop *L); - const SCEV* getAddRecExpr(const SmallVectorImpl &Operands, + const SCEV *getAddRecExpr(const SmallVectorImpl &Operands, const Loop *L) { - SmallVector NewOp(Operands.begin(), Operands.end()); + SmallVector NewOp(Operands.begin(), Operands.end()); return getAddRecExpr(NewOp, L); } - const SCEV* getSMaxExpr(const SCEV* LHS, const SCEV* RHS); - const SCEV* getSMaxExpr(SmallVectorImpl &Operands); - const SCEV* getUMaxExpr(const SCEV* LHS, const SCEV* RHS); - const SCEV* getUMaxExpr(SmallVectorImpl &Operands); - const SCEV* getSMinExpr(const SCEV* LHS, const SCEV* RHS); - const SCEV* getUMinExpr(const SCEV* LHS, const SCEV* RHS); - const SCEV* getUnknown(Value *V); - const SCEV* getCouldNotCompute(); + const SCEV *getSMaxExpr(const SCEV *LHS, const SCEV *RHS); + const SCEV *getSMaxExpr(SmallVectorImpl &Operands); + const SCEV *getUMaxExpr(const SCEV *LHS, const SCEV *RHS); + const SCEV *getUMaxExpr(SmallVectorImpl &Operands); + const SCEV *getSMinExpr(const SCEV *LHS, const SCEV *RHS); + const SCEV *getUMinExpr(const SCEV *LHS, const SCEV *RHS); + const SCEV *getUnknown(Value *V); + const SCEV *getCouldNotCompute(); /// getNegativeSCEV - Return the SCEV object corresponding to -V. /// - const SCEV* getNegativeSCEV(const SCEV* V); + const SCEV *getNegativeSCEV(const SCEV *V); /// getNotSCEV - Return the SCEV object corresponding to ~V. /// - const SCEV* getNotSCEV(const SCEV* V); + const SCEV *getNotSCEV(const SCEV *V); /// getMinusSCEV - Return LHS-RHS. /// - const SCEV* getMinusSCEV(const SCEV* LHS, - const SCEV* RHS); + const SCEV *getMinusSCEV(const SCEV *LHS, + const SCEV *RHS); /// getTruncateOrZeroExtend - Return a SCEV corresponding to a conversion /// of the input value to the specified type. If the type must be /// extended, it is zero extended. - const SCEV* getTruncateOrZeroExtend(const SCEV* V, const Type *Ty); + const SCEV *getTruncateOrZeroExtend(const SCEV *V, const Type *Ty); /// getTruncateOrSignExtend - Return a SCEV corresponding to a conversion /// of the input value to the specified type. If the type must be /// extended, it is sign extended. - const SCEV* getTruncateOrSignExtend(const SCEV* V, const Type *Ty); + const SCEV *getTruncateOrSignExtend(const SCEV *V, const Type *Ty); /// getNoopOrZeroExtend - Return a SCEV corresponding to a conversion of /// the input value to the specified type. If the type must be extended, /// it is zero extended. The conversion must not be narrowing. - const SCEV* getNoopOrZeroExtend(const SCEV* V, const Type *Ty); + const SCEV *getNoopOrZeroExtend(const SCEV *V, const Type *Ty); /// getNoopOrSignExtend - Return a SCEV corresponding to a conversion of /// the input value to the specified type. If the type must be extended, /// it is sign extended. The conversion must not be narrowing. - const SCEV* getNoopOrSignExtend(const SCEV* V, const Type *Ty); + const SCEV *getNoopOrSignExtend(const SCEV *V, const Type *Ty); /// getNoopOrAnyExtend - Return a SCEV corresponding to a conversion of /// the input value to the specified type. If the type must be extended, /// it is extended with unspecified bits. The conversion must not be /// narrowing. - const SCEV* getNoopOrAnyExtend(const SCEV* V, const Type *Ty); + const SCEV *getNoopOrAnyExtend(const SCEV *V, const Type *Ty); /// getTruncateOrNoop - Return a SCEV corresponding to a conversion of the /// input value to the specified type. The conversion must not be /// widening. - const SCEV* getTruncateOrNoop(const SCEV* V, const Type *Ty); + const SCEV *getTruncateOrNoop(const SCEV *V, const Type *Ty); /// getIntegerSCEV - Given a SCEVable type, create a constant for the /// specified signed integer value and return a SCEV for the constant. - const SCEV* getIntegerSCEV(int Val, const Type *Ty); + const SCEV *getIntegerSCEV(int Val, const Type *Ty); /// getUMaxFromMismatchedTypes - Promote the operands to the wider of /// the types using zero-extension, and then perform a umax operation /// with them. - const SCEV* getUMaxFromMismatchedTypes(const SCEV* LHS, - const SCEV* RHS); + const SCEV *getUMaxFromMismatchedTypes(const SCEV *LHS, + const SCEV *RHS); /// getUMinFromMismatchedTypes - Promote the operands to the wider of /// the types using zero-extension, and then perform a umin operation /// with them. - const SCEV* getUMinFromMismatchedTypes(const SCEV* LHS, - const SCEV* RHS); + const SCEV *getUMinFromMismatchedTypes(const SCEV *LHS, + const SCEV *RHS); /// hasSCEV - Return true if the SCEV for this value has already been /// computed. @@ -491,7 +491,7 @@ /// setSCEV - Insert the specified SCEV into the map of current SCEVs for /// the specified value. - void setSCEV(Value *V, const SCEV* H); + void setSCEV(Value *V, const SCEV *H); /// getSCEVAtScope - Return a SCEV expression handle for the specified value /// at the specified scope in the program. The L value specifies a loop @@ -503,11 +503,11 @@ /// /// In the case that a relevant loop exit value cannot be computed, the /// original value V is returned. - const SCEV* getSCEVAtScope(const SCEV *S, const Loop *L); + const SCEV *getSCEVAtScope(const SCEV *S, const Loop *L); /// getSCEVAtScope - This is a convenience function which does /// getSCEVAtScope(getSCEV(V), L). - const SCEV* getSCEVAtScope(Value *V, const Loop *L); + const SCEV *getSCEVAtScope(Value *V, const Loop *L); /// isLoopGuardedByCond - Test whether entry to the loop is protected by /// a conditional between LHS and RHS. This is used to help avoid max @@ -526,12 +526,12 @@ /// loop-invariant backedge-taken count (see /// hasLoopInvariantBackedgeTakenCount). /// - const SCEV* getBackedgeTakenCount(const Loop *L); + const SCEV *getBackedgeTakenCount(const Loop *L); /// getMaxBackedgeTakenCount - Similar to getBackedgeTakenCount, except /// return the least SCEV value that is known never to be less than the /// actual backedge taken count. - const SCEV* getMaxBackedgeTakenCount(const Loop *L); + const SCEV *getMaxBackedgeTakenCount(const Loop *L); /// hasLoopInvariantBackedgeTakenCount - Return true if the specified loop /// has an analyzable loop-invariant backedge-taken count. @@ -548,15 +548,15 @@ /// time, the minimum number of times S is divisible by 2. For example, /// given {4,+,8} it returns 2. If S is guaranteed to be 0, it returns the /// bitwidth of S. - uint32_t GetMinTrailingZeros(const SCEV* S); + uint32_t GetMinTrailingZeros(const SCEV *S); /// GetMinLeadingZeros - Determine the minimum number of zero bits that S is /// guaranteed to begin with (at every loop iteration). - uint32_t GetMinLeadingZeros(const SCEV* S); + uint32_t GetMinLeadingZeros(const SCEV *S); /// GetMinSignBits - Determine the minimum number of sign bits that S is /// guaranteed to begin with. - uint32_t GetMinSignBits(const SCEV* S); + uint32_t GetMinSignBits(const SCEV *S); virtual bool runOnFunction(Function &F); virtual void releaseMemory(); Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Tue Jul 7 12:06:11 2009 @@ -53,7 +53,7 @@ /// expandCodeFor - Insert code to directly compute the specified SCEV /// expression into the program. The inserted code is inserted into the /// specified block. - Value *expandCodeFor(const SCEV* SH, const Type *Ty, Instruction *IP) { + Value *expandCodeFor(const SCEV *SH, const Type *Ty, Instruction *IP) { Builder.SetInsertPoint(IP->getParent(), IP); return expandCodeFor(SH, Ty); } @@ -72,8 +72,8 @@ /// expandAddToGEP - Expand a SCEVAddExpr with a pointer type into a GEP /// instead of using ptrtoint+arithmetic+inttoptr. - Value *expandAddToGEP(const SCEV* const *op_begin, - const SCEV* const *op_end, + Value *expandAddToGEP(const SCEV *const *op_begin, + const SCEV *const *op_end, const PointerType *PTy, const Type *Ty, Value *V); Value *expand(const SCEV *S); @@ -82,7 +82,7 @@ /// expression into the program. The inserted code is inserted into the /// SCEVExpander's current insertion point. If a type is specified, the /// result will be expanded to have that type, with a cast if necessary. - Value *expandCodeFor(const SCEV* SH, const Type *Ty = 0); + Value *expandCodeFor(const SCEV *SH, const Type *Ty = 0); /// isInsertedInstruction - Return true if the specified instruction was /// inserted by the code rewriter. If so, the client should not modify the Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Tue Jul 7 12:06:11 2009 @@ -53,8 +53,8 @@ virtual const Type *getType() const; - const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const { return this; } @@ -77,15 +77,15 @@ /// class SCEVCastExpr : public SCEV { protected: - const SCEV* Op; + const SCEV *Op; const Type *Ty; - SCEVCastExpr(unsigned SCEVTy, const SCEV* op, const Type *ty); + SCEVCastExpr(unsigned SCEVTy, const SCEV *op, const Type *ty); public: virtual void Profile(FoldingSetNodeID &ID) const; - const SCEV* getOperand() const { return Op; } + const SCEV *getOperand() const { return Op; } virtual const Type *getType() const { return Ty; } virtual bool isLoopInvariant(const Loop *L) const { @@ -114,13 +114,13 @@ class SCEVTruncateExpr : public SCEVCastExpr { friend class ScalarEvolution; - SCEVTruncateExpr(const SCEV* op, const Type *ty); + SCEVTruncateExpr(const SCEV *op, const Type *ty); public: - const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const { - const SCEV* H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); + const SCEV *H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); if (H == Op) return this; return SE.getTruncateExpr(H, Ty); @@ -142,13 +142,13 @@ class SCEVZeroExtendExpr : public SCEVCastExpr { friend class ScalarEvolution; - SCEVZeroExtendExpr(const SCEV* op, const Type *ty); + SCEVZeroExtendExpr(const SCEV *op, const Type *ty); public: - const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const { - const SCEV* H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); + const SCEV *H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); if (H == Op) return this; return SE.getZeroExtendExpr(H, Ty); @@ -170,13 +170,13 @@ class SCEVSignExtendExpr : public SCEVCastExpr { friend class ScalarEvolution; - SCEVSignExtendExpr(const SCEV* op, const Type *ty); + SCEVSignExtendExpr(const SCEV *op, const Type *ty); public: - const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const { - const SCEV* H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); + const SCEV *H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); if (H == Op) return this; return SE.getSignExtendExpr(H, Ty); @@ -198,22 +198,24 @@ /// class SCEVNAryExpr : public SCEV { protected: - SmallVector Operands; + SmallVector Operands; - SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl &ops) + SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl &ops) : SCEV(T), Operands(ops.begin(), ops.end()) {} public: virtual void Profile(FoldingSetNodeID &ID) const; unsigned getNumOperands() const { return (unsigned)Operands.size(); } - const SCEV* getOperand(unsigned i) const { + const SCEV *getOperand(unsigned i) const { assert(i < Operands.size() && "Operand index out of range!"); return Operands[i]; } - const SmallVectorImpl &getOperands() const { return Operands; } - typedef SmallVectorImpl::const_iterator op_iterator; + const SmallVectorImpl &getOperands() const { + return Operands; + } + typedef SmallVectorImpl::const_iterator op_iterator; op_iterator op_begin() const { return Operands.begin(); } op_iterator op_end() const { return Operands.end(); } @@ -260,12 +262,12 @@ class SCEVCommutativeExpr : public SCEVNAryExpr { protected: SCEVCommutativeExpr(enum SCEVTypes T, - const SmallVectorImpl &ops) + const SmallVectorImpl &ops) : SCEVNAryExpr(T, ops) {} public: - const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const; virtual const char *getOperationStr() const = 0; @@ -289,7 +291,7 @@ class SCEVAddExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - explicit SCEVAddExpr(const SmallVectorImpl &ops) + explicit SCEVAddExpr(const SmallVectorImpl &ops) : SCEVCommutativeExpr(scAddExpr, ops) { } @@ -309,7 +311,7 @@ class SCEVMulExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - explicit SCEVMulExpr(const SmallVectorImpl &ops) + explicit SCEVMulExpr(const SmallVectorImpl &ops) : SCEVCommutativeExpr(scMulExpr, ops) { } @@ -330,16 +332,16 @@ class SCEVUDivExpr : public SCEV { friend class ScalarEvolution; - const SCEV* LHS; - const SCEV* RHS; - SCEVUDivExpr(const SCEV* lhs, const SCEV* rhs) + const SCEV *LHS; + const SCEV *RHS; + SCEVUDivExpr(const SCEV *lhs, const SCEV *rhs) : SCEV(scUDivExpr), LHS(lhs), RHS(rhs) {} public: virtual void Profile(FoldingSetNodeID &ID) const; - const SCEV* getLHS() const { return LHS; } - const SCEV* getRHS() const { return RHS; } + const SCEV *getLHS() const { return LHS; } + const SCEV *getRHS() const { return RHS; } virtual bool isLoopInvariant(const Loop *L) const { return LHS->isLoopInvariant(L) && RHS->isLoopInvariant(L); @@ -350,11 +352,11 @@ RHS->hasComputableLoopEvolution(L); } - const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const { - const SCEV* L = LHS->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); - const SCEV* R = RHS->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); + const SCEV *L = LHS->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); + const SCEV *R = RHS->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); if (L == LHS && R == RHS) return this; else @@ -389,7 +391,7 @@ const Loop *L; - SCEVAddRecExpr(const SmallVectorImpl &ops, const Loop *l) + SCEVAddRecExpr(const SmallVectorImpl &ops, const Loop *l) : SCEVNAryExpr(scAddRecExpr, ops), L(l) { for (size_t i = 0, e = Operands.size(); i != e; ++i) assert(Operands[i]->isLoopInvariant(l) && @@ -399,15 +401,16 @@ public: virtual void Profile(FoldingSetNodeID &ID) const; - const SCEV* getStart() const { return Operands[0]; } + const SCEV *getStart() const { return Operands[0]; } const Loop *getLoop() const { return L; } /// getStepRecurrence - This method constructs and returns the recurrence /// indicating how much this expression steps by. If this is a polynomial /// of degree N, it returns a chrec of degree N-1. - const SCEV* getStepRecurrence(ScalarEvolution &SE) const { + const SCEV *getStepRecurrence(ScalarEvolution &SE) const { if (isAffine()) return getOperand(1); - return SE.getAddRecExpr(SmallVector(op_begin()+1,op_end()), + return SE.getAddRecExpr(SmallVector(op_begin()+1, + op_end()), getLoop()); } @@ -435,7 +438,7 @@ /// evaluateAtIteration - Return the value of this chain of recurrences at /// the specified iteration number. - const SCEV* evaluateAtIteration(const SCEV* It, ScalarEvolution &SE) const; + const SCEV *evaluateAtIteration(const SCEV *It, ScalarEvolution &SE) const; /// getNumIterationsInRange - Return the number of iterations of this loop /// that produce values in the specified constant range. Another way of @@ -443,11 +446,11 @@ /// value is not in the condition, thus computing the exit count. If the /// iteration count can't be computed, an instance of SCEVCouldNotCompute is /// returned. - const SCEV* getNumIterationsInRange(ConstantRange Range, + const SCEV *getNumIterationsInRange(ConstantRange Range, ScalarEvolution &SE) const; - const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const; virtual void print(raw_ostream &OS) const; @@ -466,7 +469,7 @@ class SCEVSMaxExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - explicit SCEVSMaxExpr(const SmallVectorImpl &ops) + explicit SCEVSMaxExpr(const SmallVectorImpl &ops) : SCEVCommutativeExpr(scSMaxExpr, ops) { } @@ -487,7 +490,7 @@ class SCEVUMaxExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - explicit SCEVUMaxExpr(const SmallVectorImpl &ops) + explicit SCEVUMaxExpr(const SmallVectorImpl &ops) : SCEVCommutativeExpr(scUMaxExpr, ops) { } @@ -524,8 +527,8 @@ return false; // not computable } - const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym, - const SCEV* Conc, + const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym, + const SCEV *Conc, ScalarEvolution &SE) const { if (&*Sym == this) return Conc; return this; Modified: llvm/trunk/lib/Analysis/IVUsers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IVUsers.cpp?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IVUsers.cpp (original) +++ llvm/trunk/lib/Analysis/IVUsers.cpp Tue Jul 7 12:06:11 2009 @@ -39,7 +39,7 @@ /// containsAddRecFromDifferentLoop - Determine whether expression S involves a /// subexpression that is an AddRec from a loop other than L. An outer loop /// of L is OK, but not an inner loop nor a disjoint loop. -static bool containsAddRecFromDifferentLoop(const SCEV* S, Loop *L) { +static bool containsAddRecFromDifferentLoop(const SCEV *S, Loop *L) { // This is very common, put it first. if (isa(S)) return false; @@ -80,10 +80,10 @@ /// a mix of loop invariant and loop variant expressions. The start cannot, /// however, contain an AddRec from a different loop, unless that loop is an /// outer loop of the current loop. -static bool getSCEVStartAndStride(const SCEV* &SH, Loop *L, Loop *UseLoop, - const SCEV* &Start, const SCEV* &Stride, +static bool getSCEVStartAndStride(const SCEV *&SH, Loop *L, Loop *UseLoop, + const SCEV *&Start, const SCEV *&Stride, ScalarEvolution *SE, DominatorTree *DT) { - const SCEV* TheAddRec = Start; // Initialize to zero. + const SCEV *TheAddRec = Start; // Initialize to zero. // If the outer level is an AddExpr, the operands are all start values except // for a nested AddRecExpr. @@ -109,9 +109,9 @@ // Use getSCEVAtScope to attempt to simplify other loops out of // the picture. - const SCEV* AddRecStart = AddRec->getStart(); + const SCEV *AddRecStart = AddRec->getStart(); AddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop); - const SCEV* AddRecStride = AddRec->getStepRecurrence(*SE); + const SCEV *AddRecStride = AddRec->getStepRecurrence(*SE); // FIXME: If Start contains an SCEVAddRecExpr from a different loop, other // than an outer loop of the current loop, reject it. LSR has no concept of @@ -196,13 +196,13 @@ return true; // Instruction already handled. // Get the symbolic expression for this instruction. - const SCEV* ISE = SE->getSCEV(I); + const SCEV *ISE = SE->getSCEV(I); if (isa(ISE)) return false; // Get the start and stride for this expression. Loop *UseLoop = LI->getLoopFor(I->getParent()); - const SCEV* Start = SE->getIntegerSCEV(0, ISE->getType()); - const SCEV* Stride = Start; + const SCEV *Start = SE->getIntegerSCEV(0, ISE->getType()); + const SCEV *Stride = Start; if (!getSCEVStartAndStride(ISE, L, UseLoop, Start, Stride, SE, DT)) return false; // Non-reducible symbolic expression, bail out. @@ -254,7 +254,7 @@ if (IVUseShouldUsePostIncValue(User, I, L, LI, DT, this)) { // The value used will be incremented by the stride more than we are // expecting, so subtract this off. - const SCEV* NewStart = SE->getMinusSCEV(Start, Stride); + const SCEV *NewStart = SE->getMinusSCEV(Start, Stride); StrideUses->addUser(NewStart, User, I); StrideUses->Users.back().setIsUseOfPostIncrementedValue(true); DOUT << " USING POSTINC SCEV, START=" << *NewStart<< "\n"; @@ -295,9 +295,9 @@ /// getReplacementExpr - Return a SCEV expression which computes the /// value of the OperandValToReplace of the given IVStrideUse. -const SCEV* IVUsers::getReplacementExpr(const IVStrideUse &U) const { +const SCEV *IVUsers::getReplacementExpr(const IVStrideUse &U) const { // Start with zero. - const SCEV* RetVal = SE->getIntegerSCEV(0, U.getParent()->Stride->getType()); + const SCEV *RetVal = SE->getIntegerSCEV(0, U.getParent()->Stride->getType()); // Create the basic add recurrence. RetVal = SE->getAddRecExpr(RetVal, U.getParent()->Stride, L); // Add the offset in a separate step, because it may be loop-variant. @@ -308,7 +308,7 @@ RetVal = SE->getAddExpr(RetVal, U.getParent()->Stride); // Evaluate the expression out of the loop, if possible. if (!L->contains(U.getUser()->getParent())) { - const SCEV* ExitVal = SE->getSCEVAtScope(RetVal, L->getParentLoop()); + const SCEV *ExitVal = SE->getSCEVAtScope(RetVal, L->getParentLoop()); if (ExitVal->isLoopInvariant(L)) RetVal = ExitVal; } @@ -325,7 +325,7 @@ OS << ":\n"; for (unsigned Stride = 0, e = StrideOrder.size(); Stride != e; ++Stride) { - std::map::const_iterator SI = + std::map::const_iterator SI = IVUsesByStride.find(StrideOrder[Stride]); assert(SI != IVUsesByStride.end() && "Stride doesn't exist!"); OS << " Stride " << *SI->first->getType() << " " << *SI->first << ":\n"; Modified: llvm/trunk/lib/Analysis/LoopVR.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopVR.cpp?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopVR.cpp (original) +++ llvm/trunk/lib/Analysis/LoopVR.cpp Tue Jul 7 12:06:11 2009 @@ -27,8 +27,8 @@ static RegisterPass X("loopvr", "Loop Value Ranges", false, true); /// getRange - determine the range for a particular SCEV within a given Loop -ConstantRange LoopVR::getRange(const SCEV* S, Loop *L, ScalarEvolution &SE) { - const SCEV* T = SE.getBackedgeTakenCount(L); +ConstantRange LoopVR::getRange(const SCEV *S, Loop *L, ScalarEvolution &SE) { + const SCEV *T = SE.getBackedgeTakenCount(L); if (isa(T)) return ConstantRange(cast(S->getType())->getBitWidth(), true); @@ -37,7 +37,7 @@ } /// getRange - determine the range for a particular SCEV with a given trip count -ConstantRange LoopVR::getRange(const SCEV* S, const SCEV* T, ScalarEvolution &SE){ +ConstantRange LoopVR::getRange(const SCEV *S, const SCEV *T, ScalarEvolution &SE){ if (const SCEVConstant *C = dyn_cast(S)) return ConstantRange(C->getValue()->getValue()); @@ -183,8 +183,8 @@ if (!Trip) return FullSet; if (AddRec->isAffine()) { - const SCEV* StartHandle = AddRec->getStart(); - const SCEV* StepHandle = AddRec->getOperand(1); + const SCEV *StartHandle = AddRec->getStart(); + const SCEV *StepHandle = AddRec->getOperand(1); const SCEVConstant *Step = dyn_cast(StepHandle); if (!Step) return FullSet; @@ -195,7 +195,7 @@ if ((TripExt * StepExt).ugt(APInt::getLowBitsSet(ExWidth, ExWidth >> 1))) return FullSet; - const SCEV* EndHandle = SE.getAddExpr(StartHandle, + const SCEV *EndHandle = SE.getAddExpr(StartHandle, SE.getMulExpr(T, StepHandle)); const SCEVConstant *Start = dyn_cast(StartHandle); const SCEVConstant *End = dyn_cast(EndHandle); @@ -255,7 +255,7 @@ ScalarEvolution &SE = getAnalysis(); - const SCEV* S = SE.getSCEV(I); + const SCEV *S = SE.getSCEV(I); if (isa(S) || isa(S)) return ConstantRange(cast(V->getType())->getBitWidth(), false); Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Jul 7 12:06:11 2009 @@ -14,7 +14,7 @@ // There are several aspects to this library. First is the representation of // scalar expressions, which are represented as subclasses of the SCEV class. // These classes are used to represent certain types of subexpressions that we -// can handle. These classes are reference counted, managed by the const SCEV* +// can handle. These classes are reference counted, managed by the const SCEV * // class. We only create one SCEV of a particular shape, so pointer-comparisons // for equality are legal. // @@ -180,7 +180,7 @@ return S->getSCEVType() == scCouldNotCompute; } -const SCEV* ScalarEvolution::getConstant(ConstantInt *V) { +const SCEV *ScalarEvolution::getConstant(ConstantInt *V) { FoldingSetNodeID ID; ID.AddInteger(scConstant); ID.AddPointer(V); @@ -192,11 +192,11 @@ return S; } -const SCEV* ScalarEvolution::getConstant(const APInt& Val) { +const SCEV *ScalarEvolution::getConstant(const APInt& Val) { return getConstant(ConstantInt::get(Val)); } -const SCEV* +const SCEV * ScalarEvolution::getConstant(const Type *Ty, uint64_t V, bool isSigned) { return getConstant(ConstantInt::get(cast(Ty), V, isSigned)); } @@ -213,7 +213,7 @@ } SCEVCastExpr::SCEVCastExpr(unsigned SCEVTy, - const SCEV* op, const Type *ty) + const SCEV *op, const Type *ty) : SCEV(SCEVTy), Op(op), Ty(ty) {} void SCEVCastExpr::Profile(FoldingSetNodeID &ID) const { @@ -226,7 +226,7 @@ return Op->dominates(BB, DT); } -SCEVTruncateExpr::SCEVTruncateExpr(const SCEV* op, const Type *ty) +SCEVTruncateExpr::SCEVTruncateExpr(const SCEV *op, const Type *ty) : SCEVCastExpr(scTruncate, op, ty) { assert((Op->getType()->isInteger() || isa(Op->getType())) && (Ty->isInteger() || isa(Ty)) && @@ -237,7 +237,7 @@ OS << "(trunc " << *Op->getType() << " " << *Op << " to " << *Ty << ")"; } -SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEV* op, const Type *ty) +SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEV *op, const Type *ty) : SCEVCastExpr(scZeroExtend, op, ty) { assert((Op->getType()->isInteger() || isa(Op->getType())) && (Ty->isInteger() || isa(Ty)) && @@ -248,7 +248,7 @@ OS << "(zext " << *Op->getType() << " " << *Op << " to " << *Ty << ")"; } -SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEV* op, const Type *ty) +SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEV *op, const Type *ty) : SCEVCastExpr(scSignExtend, op, ty) { assert((Op->getType()->isInteger() || isa(Op->getType())) && (Ty->isInteger() || isa(Ty)) && @@ -274,10 +274,10 @@ const SCEV *Conc, ScalarEvolution &SE) const { for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { - const SCEV* H = + const SCEV *H = getOperand(i)->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); if (H != getOperand(i)) { - SmallVector NewOps; + SmallVector NewOps; NewOps.reserve(getNumOperands()); for (unsigned j = 0; j != i; ++j) NewOps.push_back(getOperand(j)); @@ -352,10 +352,10 @@ const SCEV *Conc, ScalarEvolution &SE) const { for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { - const SCEV* H = + const SCEV *H = getOperand(i)->replaceSymbolicValuesWithConcrete(Sym, Conc, SE); if (H != getOperand(i)) { - SmallVector NewOps; + SmallVector NewOps; NewOps.reserve(getNumOperands()); for (unsigned j = 0; j != i; ++j) NewOps.push_back(getOperand(j)); @@ -558,7 +558,7 @@ /// this to depend on where the addresses of various SCEV objects happened to /// land in memory. /// -static void GroupByComplexity(SmallVectorImpl &Ops, +static void GroupByComplexity(SmallVectorImpl &Ops, LoopInfo *LI) { if (Ops.size() < 2) return; // Noop if (Ops.size() == 2) { @@ -601,7 +601,7 @@ /// BinomialCoefficient - Compute BC(It, K). The result has width W. /// Assume, K > 0. -static const SCEV* BinomialCoefficient(const SCEV* It, unsigned K, +static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K, ScalarEvolution &SE, const Type* ResultTy) { // Handle the simplest case efficiently. @@ -694,15 +694,15 @@ // Calculate the product, at width T+W const IntegerType *CalculationTy = IntegerType::get(CalculationBits); - const SCEV* Dividend = SE.getTruncateOrZeroExtend(It, CalculationTy); + const SCEV *Dividend = SE.getTruncateOrZeroExtend(It, CalculationTy); for (unsigned i = 1; i != K; ++i) { - const SCEV* S = SE.getMinusSCEV(It, SE.getIntegerSCEV(i, It->getType())); + const SCEV *S = SE.getMinusSCEV(It, SE.getIntegerSCEV(i, It->getType())); Dividend = SE.getMulExpr(Dividend, SE.getTruncateOrZeroExtend(S, CalculationTy)); } // Divide by 2^T - const SCEV* DivResult = SE.getUDivExpr(Dividend, SE.getConstant(DivFactor)); + const SCEV *DivResult = SE.getUDivExpr(Dividend, SE.getConstant(DivFactor)); // Truncate the result, and divide by K! / 2^T. @@ -719,14 +719,14 @@ /// /// where BC(It, k) stands for binomial coefficient. /// -const SCEV* SCEVAddRecExpr::evaluateAtIteration(const SCEV* It, +const SCEV *SCEVAddRecExpr::evaluateAtIteration(const SCEV *It, ScalarEvolution &SE) const { - const SCEV* Result = getStart(); + const SCEV *Result = getStart(); for (unsigned i = 1, e = getNumOperands(); i != e; ++i) { // The computation is correct in the face of overflow provided that the // multiplication is performed _after_ the evaluation of the binomial // coefficient. - const SCEV* Coeff = BinomialCoefficient(It, i, SE, getType()); + const SCEV *Coeff = BinomialCoefficient(It, i, SE, getType()); if (isa(Coeff)) return Coeff; @@ -739,7 +739,7 @@ // SCEV Expression folder implementations //===----------------------------------------------------------------------===// -const SCEV* ScalarEvolution::getTruncateExpr(const SCEV* Op, +const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op, const Type *Ty) { assert(getTypeSizeInBits(Op->getType()) > getTypeSizeInBits(Ty) && "This is not a truncating conversion!"); @@ -766,7 +766,7 @@ // If the input value is a chrec scev, truncate the chrec's operands. if (const SCEVAddRecExpr *AddRec = dyn_cast(Op)) { - SmallVector Operands; + SmallVector Operands; for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i) Operands.push_back(getTruncateExpr(AddRec->getOperand(i), Ty)); return getAddRecExpr(Operands, AddRec->getLoop()); @@ -784,7 +784,7 @@ return S; } -const SCEV* ScalarEvolution::getZeroExtendExpr(const SCEV* Op, +const SCEV *ScalarEvolution::getZeroExtendExpr(const SCEV *Op, const Type *Ty) { assert(getTypeSizeInBits(Op->getType()) < getTypeSizeInBits(Ty) && "This is not an extending conversion!"); @@ -818,28 +818,28 @@ // in infinite recursion. In the later case, the analysis code will // cope with a conservative value, and it will take care to purge // that value once it has finished. - const SCEV* MaxBECount = getMaxBackedgeTakenCount(AR->getLoop()); + const SCEV *MaxBECount = getMaxBackedgeTakenCount(AR->getLoop()); if (!isa(MaxBECount)) { // Manually compute the final value for AR, checking for // overflow. - const SCEV* Start = AR->getStart(); - const SCEV* Step = AR->getStepRecurrence(*this); + const SCEV *Start = AR->getStart(); + const SCEV *Step = AR->getStepRecurrence(*this); // Check whether the backedge-taken count can be losslessly casted to // the addrec's type. The count is always unsigned. - const SCEV* CastedMaxBECount = + const SCEV *CastedMaxBECount = getTruncateOrZeroExtend(MaxBECount, Start->getType()); - const SCEV* RecastedMaxBECount = + const SCEV *RecastedMaxBECount = getTruncateOrZeroExtend(CastedMaxBECount, MaxBECount->getType()); if (MaxBECount == RecastedMaxBECount) { const Type *WideTy = IntegerType::get(getTypeSizeInBits(Start->getType()) * 2); // Check whether Start+Step*MaxBECount has no unsigned overflow. - const SCEV* ZMul = + const SCEV *ZMul = getMulExpr(CastedMaxBECount, getTruncateOrZeroExtend(Step, Start->getType())); - const SCEV* Add = getAddExpr(Start, ZMul); - const SCEV* OperandExtendedAdd = + const SCEV *Add = getAddExpr(Start, ZMul); + const SCEV *OperandExtendedAdd = getAddExpr(getZeroExtendExpr(Start, WideTy), getMulExpr(getZeroExtendExpr(CastedMaxBECount, WideTy), getZeroExtendExpr(Step, WideTy))); @@ -851,7 +851,7 @@ // Similar to above, only this time treat the step value as signed. // This covers loops that count down. - const SCEV* SMul = + const SCEV *SMul = getMulExpr(CastedMaxBECount, getTruncateOrSignExtend(Step, Start->getType())); Add = getAddExpr(Start, SMul); @@ -880,7 +880,7 @@ return S; } -const SCEV* ScalarEvolution::getSignExtendExpr(const SCEV* Op, +const SCEV *ScalarEvolution::getSignExtendExpr(const SCEV *Op, const Type *Ty) { assert(getTypeSizeInBits(Op->getType()) < getTypeSizeInBits(Ty) && "This is not an extending conversion!"); @@ -914,28 +914,28 @@ // in infinite recursion. In the later case, the analysis code will // cope with a conservative value, and it will take care to purge // that value once it has finished. - const SCEV* MaxBECount = getMaxBackedgeTakenCount(AR->getLoop()); + const SCEV *MaxBECount = getMaxBackedgeTakenCount(AR->getLoop()); if (!isa(MaxBECount)) { // Manually compute the final value for AR, checking for // overflow. - const SCEV* Start = AR->getStart(); - const SCEV* Step = AR->getStepRecurrence(*this); + const SCEV *Start = AR->getStart(); + const SCEV *Step = AR->getStepRecurrence(*this); // Check whether the backedge-taken count can be losslessly casted to // the addrec's type. The count is always unsigned. - const SCEV* CastedMaxBECount = + const SCEV *CastedMaxBECount = getTruncateOrZeroExtend(MaxBECount, Start->getType()); - const SCEV* RecastedMaxBECount = + const SCEV *RecastedMaxBECount = getTruncateOrZeroExtend(CastedMaxBECount, MaxBECount->getType()); if (MaxBECount == RecastedMaxBECount) { const Type *WideTy = IntegerType::get(getTypeSizeInBits(Start->getType()) * 2); // Check whether Start+Step*MaxBECount has no signed overflow. - const SCEV* SMul = + const SCEV *SMul = getMulExpr(CastedMaxBECount, getTruncateOrSignExtend(Step, Start->getType())); - const SCEV* Add = getAddExpr(Start, SMul); - const SCEV* OperandExtendedAdd = + const SCEV *Add = getAddExpr(Start, SMul); + const SCEV *OperandExtendedAdd = getAddExpr(getSignExtendExpr(Start, WideTy), getMulExpr(getZeroExtendExpr(CastedMaxBECount, WideTy), getSignExtendExpr(Step, WideTy))); @@ -963,7 +963,7 @@ /// getAnyExtendExpr - Return a SCEV for the given operand extended with /// unspecified bits out to the given type. /// -const SCEV* ScalarEvolution::getAnyExtendExpr(const SCEV* Op, +const SCEV *ScalarEvolution::getAnyExtendExpr(const SCEV *Op, const Type *Ty) { assert(getTypeSizeInBits(Op->getType()) < getTypeSizeInBits(Ty) && "This is not an extending conversion!"); @@ -978,19 +978,19 @@ // Peel off a truncate cast. if (const SCEVTruncateExpr *T = dyn_cast(Op)) { - const SCEV* NewOp = T->getOperand(); + const SCEV *NewOp = T->getOperand(); if (getTypeSizeInBits(NewOp->getType()) < getTypeSizeInBits(Ty)) return getAnyExtendExpr(NewOp, Ty); return getTruncateOrNoop(NewOp, Ty); } // Next try a zext cast. If the cast is folded, use it. - const SCEV* ZExt = getZeroExtendExpr(Op, Ty); + const SCEV *ZExt = getZeroExtendExpr(Op, Ty); if (!isa(ZExt)) return ZExt; // Next try a sext cast. If the cast is folded, use it. - const SCEV* SExt = getSignExtendExpr(Op, Ty); + const SCEV *SExt = getSignExtendExpr(Op, Ty); if (!isa(SExt)) return SExt; @@ -1028,10 +1028,10 @@ /// is also used as a check to avoid infinite recursion. /// static bool -CollectAddOperandsWithScales(DenseMap &M, - SmallVector &NewOps, +CollectAddOperandsWithScales(DenseMap &M, + SmallVector &NewOps, APInt &AccumulatedConstant, - const SmallVectorImpl &Ops, + const SmallVectorImpl &Ops, const APInt &Scale, ScalarEvolution &SE) { bool Interesting = false; @@ -1052,9 +1052,9 @@ } else { // A multiplication of a constant with some other value. Update // the map. - SmallVector MulOps(Mul->op_begin()+1, Mul->op_end()); - const SCEV* Key = SE.getMulExpr(MulOps); - std::pair::iterator, bool> Pair = + SmallVector MulOps(Mul->op_begin()+1, Mul->op_end()); + const SCEV *Key = SE.getMulExpr(MulOps); + std::pair::iterator, bool> Pair = M.insert(std::make_pair(Key, NewScale)); if (Pair.second) { NewOps.push_back(Pair.first->first); @@ -1072,7 +1072,7 @@ AccumulatedConstant += Scale * C->getValue()->getValue(); } else { // An ordinary operand. Update the map. - std::pair::iterator, bool> Pair = + std::pair::iterator, bool> Pair = M.insert(std::make_pair(Ops[i], Scale)); if (Pair.second) { NewOps.push_back(Pair.first->first); @@ -1098,7 +1098,7 @@ /// getAddExpr - Get a canonical add expression, or something simpler if /// possible. -const SCEV* ScalarEvolution::getAddExpr(SmallVectorImpl &Ops) { +const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl &Ops) { assert(!Ops.empty() && "Cannot get empty add!"); if (Ops.size() == 1) return Ops[0]; #ifndef NDEBUG @@ -1142,8 +1142,8 @@ if (Ops[i] == Ops[i+1]) { // X + Y + Y --> X + Y*2 // Found a match, merge the two values into a multiply, and add any // remaining values to the result. - const SCEV* Two = getIntegerSCEV(2, Ty); - const SCEV* Mul = getMulExpr(Ops[i], Two); + const SCEV *Two = getIntegerSCEV(2, Ty); + const SCEV *Mul = getMulExpr(Ops[i], Two); if (Ops.size() == 2) return Mul; Ops.erase(Ops.begin()+i, Ops.begin()+i+2); @@ -1159,7 +1159,7 @@ const SCEVTruncateExpr *Trunc = cast(Ops[Idx]); const Type *DstType = Trunc->getType(); const Type *SrcType = Trunc->getOperand()->getType(); - SmallVector LargeOps; + SmallVector LargeOps; bool Ok = true; // Check all the operands to see if they can be represented in the // source type of the truncate. @@ -1175,7 +1175,7 @@ // is much more likely to be foldable here. LargeOps.push_back(getSignExtendExpr(C, SrcType)); } else if (const SCEVMulExpr *M = dyn_cast(Ops[i])) { - SmallVector LargeMulOps; + SmallVector LargeMulOps; for (unsigned j = 0, f = M->getNumOperands(); j != f && Ok; ++j) { if (const SCEVTruncateExpr *T = dyn_cast(M->getOperand(j))) { @@ -1203,7 +1203,7 @@ } if (Ok) { // Evaluate the expression in the larger type. - const SCEV* Fold = getAddExpr(LargeOps); + const SCEV *Fold = getAddExpr(LargeOps); // If it folds to something simple, use it. Otherwise, don't. if (isa(Fold) || isa(Fold)) return getTruncateExpr(Fold, DstType); @@ -1240,16 +1240,16 @@ // operands multiplied by constant values. if (Idx < Ops.size() && isa(Ops[Idx])) { uint64_t BitWidth = getTypeSizeInBits(Ty); - DenseMap M; - SmallVector NewOps; + DenseMap M; + SmallVector NewOps; APInt AccumulatedConstant(BitWidth, 0); if (CollectAddOperandsWithScales(M, NewOps, AccumulatedConstant, Ops, APInt(BitWidth, 1), *this)) { // Some interesting folding opportunity is present, so its worthwhile to // re-generate the operands list. Group the operands by constant scale, // to avoid multiplying by the same constant scale multiple times. - std::map, APIntCompare> MulOpLists; - for (SmallVector::iterator I = NewOps.begin(), + std::map, APIntCompare> MulOpLists; + for (SmallVector::iterator I = NewOps.begin(), E = NewOps.end(); I != E; ++I) MulOpLists[M.find(*I)->second].push_back(*I); // Re-generate the operands list. @@ -1279,17 +1279,17 @@ for (unsigned AddOp = 0, e = Ops.size(); AddOp != e; ++AddOp) if (MulOpSCEV == Ops[AddOp] && !isa(Ops[AddOp])) { // Fold W + X + (X * Y * Z) --> W + (X * ((Y*Z)+1)) - const SCEV* InnerMul = Mul->getOperand(MulOp == 0); + const SCEV *InnerMul = Mul->getOperand(MulOp == 0); if (Mul->getNumOperands() != 2) { // If the multiply has more than two operands, we must get the // Y*Z term. - SmallVector MulOps(Mul->op_begin(), Mul->op_end()); + SmallVector MulOps(Mul->op_begin(), Mul->op_end()); MulOps.erase(MulOps.begin()+MulOp); InnerMul = getMulExpr(MulOps); } - const SCEV* One = getIntegerSCEV(1, Ty); - const SCEV* AddOne = getAddExpr(InnerMul, One); - const SCEV* OuterMul = getMulExpr(AddOne, Ops[AddOp]); + const SCEV *One = getIntegerSCEV(1, Ty); + const SCEV *AddOne = getAddExpr(InnerMul, One); + const SCEV *OuterMul = getMulExpr(AddOne, Ops[AddOp]); if (Ops.size() == 2) return OuterMul; if (AddOp < Idx) { Ops.erase(Ops.begin()+AddOp); @@ -1313,22 +1313,22 @@ OMulOp != e; ++OMulOp) if (OtherMul->getOperand(OMulOp) == MulOpSCEV) { // Fold X + (A*B*C) + (A*D*E) --> X + (A*(B*C+D*E)) - const SCEV* InnerMul1 = Mul->getOperand(MulOp == 0); + const SCEV *InnerMul1 = Mul->getOperand(MulOp == 0); if (Mul->getNumOperands() != 2) { SmallVector MulOps(Mul->op_begin(), Mul->op_end()); MulOps.erase(MulOps.begin()+MulOp); InnerMul1 = getMulExpr(MulOps); } - const SCEV* InnerMul2 = OtherMul->getOperand(OMulOp == 0); + const SCEV *InnerMul2 = OtherMul->getOperand(OMulOp == 0); if (OtherMul->getNumOperands() != 2) { SmallVector MulOps(OtherMul->op_begin(), OtherMul->op_end()); MulOps.erase(MulOps.begin()+OMulOp); InnerMul2 = getMulExpr(MulOps); } - const SCEV* InnerMulSum = getAddExpr(InnerMul1,InnerMul2); - const SCEV* OuterMul = getMulExpr(MulOpSCEV, InnerMulSum); + const SCEV *InnerMulSum = getAddExpr(InnerMul1,InnerMul2); + const SCEV *OuterMul = getMulExpr(MulOpSCEV, InnerMulSum); if (Ops.size() == 2) return OuterMul; Ops.erase(Ops.begin()+Idx); Ops.erase(Ops.begin()+OtherMulIdx-1); @@ -1349,7 +1349,7 @@ for (; Idx < Ops.size() && isa(Ops[Idx]); ++Idx) { // Scan all of the other operands to this add and add them to the vector if // they are loop invariant w.r.t. the recurrence. - SmallVector LIOps; + SmallVector LIOps; const SCEVAddRecExpr *AddRec = cast(Ops[Idx]); for (unsigned i = 0, e = Ops.size(); i != e; ++i) if (Ops[i]->isLoopInvariant(AddRec->getLoop())) { @@ -1363,11 +1363,11 @@ // NLI + LI + {Start,+,Step} --> NLI + {LI+Start,+,Step} LIOps.push_back(AddRec->getStart()); - SmallVector AddRecOps(AddRec->op_begin(), + SmallVector AddRecOps(AddRec->op_begin(), AddRec->op_end()); AddRecOps[0] = getAddExpr(LIOps); - const SCEV* NewRec = getAddRecExpr(AddRecOps, AddRec->getLoop()); + const SCEV *NewRec = getAddRecExpr(AddRecOps, AddRec->getLoop()); // If all of the other operands were loop invariant, we are done. if (Ops.size() == 1) return NewRec; @@ -1399,7 +1399,7 @@ } NewOps[i] = getAddExpr(NewOps[i], OtherAddRec->getOperand(i)); } - const SCEV* NewAddRec = getAddRecExpr(NewOps, AddRec->getLoop()); + const SCEV *NewAddRec = getAddRecExpr(NewOps, AddRec->getLoop()); if (Ops.size() == 2) return NewAddRec; @@ -1432,7 +1432,7 @@ /// getMulExpr - Get a canonical multiply expression, or something simpler if /// possible. -const SCEV* ScalarEvolution::getMulExpr(SmallVectorImpl &Ops) { +const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl &Ops) { assert(!Ops.empty() && "Cannot get empty mul!"); #ifndef NDEBUG for (unsigned i = 1, e = Ops.size(); i != e; ++i) @@ -1513,7 +1513,7 @@ for (; Idx < Ops.size() && isa(Ops[Idx]); ++Idx) { // Scan all of the other operands to this mul and add them to the vector if // they are loop invariant w.r.t. the recurrence. - SmallVector LIOps; + SmallVector LIOps; const SCEVAddRecExpr *AddRec = cast(Ops[Idx]); for (unsigned i = 0, e = Ops.size(); i != e; ++i) if (Ops[i]->isLoopInvariant(AddRec->getLoop())) { @@ -1525,7 +1525,7 @@ // If we found some loop invariants, fold them into the recurrence. if (!LIOps.empty()) { // NLI * LI * {Start,+,Step} --> NLI * {LI*Start,+,LI*Step} - SmallVector NewOps; + SmallVector NewOps; NewOps.reserve(AddRec->getNumOperands()); if (LIOps.size() == 1) { const SCEV *Scale = LIOps[0]; @@ -1533,13 +1533,13 @@ NewOps.push_back(getMulExpr(Scale, AddRec->getOperand(i))); } else { for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i) { - SmallVector MulOps(LIOps.begin(), LIOps.end()); + SmallVector MulOps(LIOps.begin(), LIOps.end()); MulOps.push_back(AddRec->getOperand(i)); NewOps.push_back(getMulExpr(MulOps)); } } - const SCEV* NewRec = getAddRecExpr(NewOps, AddRec->getLoop()); + const SCEV *NewRec = getAddRecExpr(NewOps, AddRec->getLoop()); // If all of the other operands were loop invariant, we are done. if (Ops.size() == 1) return NewRec; @@ -1563,14 +1563,14 @@ if (AddRec->getLoop() == OtherAddRec->getLoop()) { // F * G --> {A,+,B} * {C,+,D} --> {A*C,+,F*D + G*B + B*D} const SCEVAddRecExpr *F = AddRec, *G = OtherAddRec; - const SCEV* NewStart = getMulExpr(F->getStart(), + const SCEV *NewStart = getMulExpr(F->getStart(), G->getStart()); - const SCEV* B = F->getStepRecurrence(*this); - const SCEV* D = G->getStepRecurrence(*this); - const SCEV* NewStep = getAddExpr(getMulExpr(F, D), + const SCEV *B = F->getStepRecurrence(*this); + const SCEV *D = G->getStepRecurrence(*this); + const SCEV *NewStep = getAddExpr(getMulExpr(F, D), getMulExpr(G, B), getMulExpr(B, D)); - const SCEV* NewAddRec = getAddRecExpr(NewStart, NewStep, + const SCEV *NewAddRec = getAddRecExpr(NewStart, NewStep, F->getLoop()); if (Ops.size() == 2) return NewAddRec; @@ -1636,24 +1636,24 @@ getAddRecExpr(getZeroExtendExpr(AR->getStart(), ExtTy), getZeroExtendExpr(Step, ExtTy), AR->getLoop())) { - SmallVector Operands; + SmallVector Operands; for (unsigned i = 0, e = AR->getNumOperands(); i != e; ++i) Operands.push_back(getUDivExpr(AR->getOperand(i), RHS)); return getAddRecExpr(Operands, AR->getLoop()); } // (A*B)/C --> A*(B/C) if safe and B/C can be folded. if (const SCEVMulExpr *M = dyn_cast(LHS)) { - SmallVector Operands; + SmallVector Operands; for (unsigned i = 0, e = M->getNumOperands(); i != e; ++i) Operands.push_back(getZeroExtendExpr(M->getOperand(i), ExtTy)); if (getZeroExtendExpr(M, ExtTy) == getMulExpr(Operands)) // Find an operand that's safely divisible. for (unsigned i = 0, e = M->getNumOperands(); i != e; ++i) { - const SCEV* Op = M->getOperand(i); - const SCEV* Div = getUDivExpr(Op, RHSC); + const SCEV *Op = M->getOperand(i); + const SCEV *Div = getUDivExpr(Op, RHSC); if (!isa(Div) && getMulExpr(Div, RHSC) == Op) { - const SmallVectorImpl &MOperands = M->getOperands(); - Operands = SmallVector(MOperands.begin(), + const SmallVectorImpl &MOperands = M->getOperands(); + Operands = SmallVector(MOperands.begin(), MOperands.end()); Operands[i] = Div; return getMulExpr(Operands); @@ -1662,13 +1662,13 @@ } // (A+B)/C --> (A/C + B/C) if safe and A/C and B/C can be folded. if (const SCEVAddRecExpr *A = dyn_cast(LHS)) { - SmallVector Operands; + SmallVector Operands; for (unsigned i = 0, e = A->getNumOperands(); i != e; ++i) Operands.push_back(getZeroExtendExpr(A->getOperand(i), ExtTy)); if (getZeroExtendExpr(A, ExtTy) == getAddExpr(Operands)) { Operands.clear(); for (unsigned i = 0, e = A->getNumOperands(); i != e; ++i) { - const SCEV* Op = getUDivExpr(A->getOperand(i), RHS); + const SCEV *Op = getUDivExpr(A->getOperand(i), RHS); if (isa(Op) || getMulExpr(Op, RHS) != A->getOperand(i)) break; Operands.push_back(Op); @@ -1702,9 +1702,9 @@ /// getAddRecExpr - Get an add recurrence expression for the specified loop. /// Simplify the expression as much as possible. -const SCEV* ScalarEvolution::getAddRecExpr(const SCEV* Start, - const SCEV* Step, const Loop *L) { - SmallVector Operands; +const SCEV *ScalarEvolution::getAddRecExpr(const SCEV *Start, + const SCEV *Step, const Loop *L) { + SmallVector Operands; Operands.push_back(Start); if (const SCEVAddRecExpr *StepChrec = dyn_cast(Step)) if (StepChrec->getLoop() == L) { @@ -1720,7 +1720,7 @@ /// getAddRecExpr - Get an add recurrence expression for the specified loop. /// Simplify the expression as much as possible. const SCEV * -ScalarEvolution::getAddRecExpr(SmallVectorImpl &Operands, +ScalarEvolution::getAddRecExpr(SmallVectorImpl &Operands, const Loop *L) { if (Operands.size() == 1) return Operands[0]; #ifndef NDEBUG @@ -1739,7 +1739,7 @@ if (const SCEVAddRecExpr *NestedAR = dyn_cast(Operands[0])) { const Loop* NestedLoop = NestedAR->getLoop(); if (L->getLoopDepth() < NestedLoop->getLoopDepth()) { - SmallVector NestedOperands(NestedAR->op_begin(), + SmallVector NestedOperands(NestedAR->op_begin(), NestedAR->op_end()); Operands[0] = NestedAR->getStart(); // AddRecs require their operands be loop-invariant with respect to their @@ -1784,14 +1784,14 @@ const SCEV *ScalarEvolution::getSMaxExpr(const SCEV *LHS, const SCEV *RHS) { - SmallVector Ops; + SmallVector Ops; Ops.push_back(LHS); Ops.push_back(RHS); return getSMaxExpr(Ops); } -const SCEV* -ScalarEvolution::getSMaxExpr(SmallVectorImpl &Ops) { +const SCEV * +ScalarEvolution::getSMaxExpr(SmallVectorImpl &Ops) { assert(!Ops.empty() && "Cannot get empty smax!"); if (Ops.size() == 1) return Ops[0]; #ifndef NDEBUG @@ -1881,14 +1881,14 @@ const SCEV *ScalarEvolution::getUMaxExpr(const SCEV *LHS, const SCEV *RHS) { - SmallVector Ops; + SmallVector Ops; Ops.push_back(LHS); Ops.push_back(RHS); return getUMaxExpr(Ops); } -const SCEV* -ScalarEvolution::getUMaxExpr(SmallVectorImpl &Ops) { +const SCEV * +ScalarEvolution::getUMaxExpr(SmallVectorImpl &Ops) { assert(!Ops.empty() && "Cannot get empty umax!"); if (Ops.size() == 1) return Ops[0]; #ifndef NDEBUG @@ -1988,7 +1988,7 @@ return getNotSCEV(getUMaxExpr(getNotSCEV(LHS), getNotSCEV(RHS))); } -const SCEV* ScalarEvolution::getUnknown(Value *V) { +const SCEV *ScalarEvolution::getUnknown(Value *V) { // Don't attempt to do anything other than create a SCEVUnknown object // here. createSCEV only calls getUnknown after checking for all other // interesting possibilities, and any other code that calls getUnknown @@ -2055,7 +2055,7 @@ return TD->getIntPtrType(); } -const SCEV* ScalarEvolution::getCouldNotCompute() { +const SCEV *ScalarEvolution::getCouldNotCompute() { return &CouldNotCompute; } @@ -2067,26 +2067,26 @@ /// getSCEV - Return an existing SCEV if it exists, otherwise analyze the /// expression and create a new one. -const SCEV* ScalarEvolution::getSCEV(Value *V) { +const SCEV *ScalarEvolution::getSCEV(Value *V) { assert(isSCEVable(V->getType()) && "Value is not SCEVable!"); - std::map::iterator I = Scalars.find(V); + std::map::iterator I = Scalars.find(V); if (I != Scalars.end()) return I->second; - const SCEV* S = createSCEV(V); + const SCEV *S = createSCEV(V); Scalars.insert(std::make_pair(SCEVCallbackVH(V, this), S)); return S; } /// getIntegerSCEV - Given a SCEVable type, create a constant for the /// specified signed integer value and return a SCEV for the constant. -const SCEV* ScalarEvolution::getIntegerSCEV(int Val, const Type *Ty) { +const SCEV *ScalarEvolution::getIntegerSCEV(int Val, const Type *Ty) { const IntegerType *ITy = cast(getEffectiveSCEVType(Ty)); return getConstant(ConstantInt::get(ITy, Val)); } /// getNegativeSCEV - Return a SCEV corresponding to -V = -1*V /// -const SCEV* ScalarEvolution::getNegativeSCEV(const SCEV* V) { +const SCEV *ScalarEvolution::getNegativeSCEV(const SCEV *V) { if (const SCEVConstant *VC = dyn_cast(V)) return getConstant(cast(ConstantExpr::getNeg(VC->getValue()))); @@ -2096,13 +2096,13 @@ } /// getNotSCEV - Return a SCEV corresponding to ~V = -1-V -const SCEV* ScalarEvolution::getNotSCEV(const SCEV* V) { +const SCEV *ScalarEvolution::getNotSCEV(const SCEV *V) { if (const SCEVConstant *VC = dyn_cast(V)) return getConstant(cast(ConstantExpr::getNot(VC->getValue()))); const Type *Ty = V->getType(); Ty = getEffectiveSCEVType(Ty); - const SCEV* AllOnes = getConstant(ConstantInt::getAllOnesValue(Ty)); + const SCEV *AllOnes = getConstant(ConstantInt::getAllOnesValue(Ty)); return getMinusSCEV(AllOnes, V); } @@ -2117,8 +2117,8 @@ /// getTruncateOrZeroExtend - Return a SCEV corresponding to a conversion of the /// input value to the specified type. If the type must be extended, it is zero /// extended. -const SCEV* -ScalarEvolution::getTruncateOrZeroExtend(const SCEV* V, +const SCEV * +ScalarEvolution::getTruncateOrZeroExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); assert((SrcTy->isInteger() || (TD && isa(SrcTy))) && @@ -2134,8 +2134,8 @@ /// getTruncateOrSignExtend - Return a SCEV corresponding to a conversion of the /// input value to the specified type. If the type must be extended, it is sign /// extended. -const SCEV* -ScalarEvolution::getTruncateOrSignExtend(const SCEV* V, +const SCEV * +ScalarEvolution::getTruncateOrSignExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); assert((SrcTy->isInteger() || (TD && isa(SrcTy))) && @@ -2151,8 +2151,8 @@ /// getNoopOrZeroExtend - Return a SCEV corresponding to a conversion of the /// input value to the specified type. If the type must be extended, it is zero /// extended. The conversion must not be narrowing. -const SCEV* -ScalarEvolution::getNoopOrZeroExtend(const SCEV* V, const Type *Ty) { +const SCEV * +ScalarEvolution::getNoopOrZeroExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); assert((SrcTy->isInteger() || (TD && isa(SrcTy))) && (Ty->isInteger() || (TD && isa(Ty))) && @@ -2167,8 +2167,8 @@ /// getNoopOrSignExtend - Return a SCEV corresponding to a conversion of the /// input value to the specified type. If the type must be extended, it is sign /// extended. The conversion must not be narrowing. -const SCEV* -ScalarEvolution::getNoopOrSignExtend(const SCEV* V, const Type *Ty) { +const SCEV * +ScalarEvolution::getNoopOrSignExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); assert((SrcTy->isInteger() || (TD && isa(SrcTy))) && (Ty->isInteger() || (TD && isa(Ty))) && @@ -2184,8 +2184,8 @@ /// the input value to the specified type. If the type must be extended, /// it is extended with unspecified bits. The conversion must not be /// narrowing. -const SCEV* -ScalarEvolution::getNoopOrAnyExtend(const SCEV* V, const Type *Ty) { +const SCEV * +ScalarEvolution::getNoopOrAnyExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); assert((SrcTy->isInteger() || (TD && isa(SrcTy))) && (Ty->isInteger() || (TD && isa(Ty))) && @@ -2199,8 +2199,8 @@ /// getTruncateOrNoop - Return a SCEV corresponding to a conversion of the /// input value to the specified type. The conversion must not be widening. -const SCEV* -ScalarEvolution::getTruncateOrNoop(const SCEV* V, const Type *Ty) { +const SCEV * +ScalarEvolution::getTruncateOrNoop(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); assert((SrcTy->isInteger() || (TD && isa(SrcTy))) && (Ty->isInteger() || (TD && isa(Ty))) && @@ -2217,8 +2217,8 @@ /// with them. const SCEV *ScalarEvolution::getUMaxFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS) { - const SCEV* PromotedLHS = LHS; - const SCEV* PromotedRHS = RHS; + const SCEV *PromotedLHS = LHS; + const SCEV *PromotedRHS = RHS; if (getTypeSizeInBits(LHS->getType()) > getTypeSizeInBits(RHS->getType())) PromotedRHS = getZeroExtendExpr(RHS, LHS->getType()); @@ -2233,8 +2233,8 @@ /// with them. const SCEV *ScalarEvolution::getUMinFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS) { - const SCEV* PromotedLHS = LHS; - const SCEV* PromotedRHS = RHS; + const SCEV *PromotedLHS = LHS; + const SCEV *PromotedRHS = RHS; if (getTypeSizeInBits(LHS->getType()) > getTypeSizeInBits(RHS->getType())) PromotedRHS = getZeroExtendExpr(RHS, LHS->getType()); @@ -2251,11 +2251,11 @@ ScalarEvolution::ReplaceSymbolicValueWithConcrete(Instruction *I, const SCEV *SymName, const SCEV *NewVal) { - std::map::iterator SI = + std::map::iterator SI = Scalars.find(SCEVCallbackVH(I, this)); if (SI == Scalars.end()) return; - const SCEV* NV = + const SCEV *NV = SI->second->replaceSymbolicValuesWithConcrete(SymName, NewVal, *this); if (NV == SI->second) return; // No change. @@ -2271,7 +2271,7 @@ /// createNodeForPHI - PHI nodes have two cases. Either the PHI node exists in /// a loop header, making it a potential recurrence, or it doesn't. /// -const SCEV* ScalarEvolution::createNodeForPHI(PHINode *PN) { +const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) { if (PN->getNumIncomingValues() == 2) // The loops have been canonicalized. if (const Loop *L = LI->getLoopFor(PN->getParent())) if (L->getHeader() == PN->getParent()) { @@ -2281,14 +2281,14 @@ unsigned BackEdge = IncomingEdge^1; // While we are analyzing this PHI node, handle its value symbolically. - const SCEV* SymbolicName = getUnknown(PN); + const SCEV *SymbolicName = getUnknown(PN); assert(Scalars.find(PN) == Scalars.end() && "PHI node already processed?"); Scalars.insert(std::make_pair(SCEVCallbackVH(PN, this), SymbolicName)); // Using this symbolic name for the PHI, analyze the value coming around // the back-edge. - const SCEV* BEValue = getSCEV(PN->getIncomingValue(BackEdge)); + const SCEV *BEValue = getSCEV(PN->getIncomingValue(BackEdge)); // NOTE: If BEValue is loop invariant, we know that the PHI node just // has a special value for the first iteration of the loop. @@ -2308,11 +2308,11 @@ if (FoundIndex != Add->getNumOperands()) { // Create an add with everything but the specified operand. - SmallVector Ops; + SmallVector Ops; for (unsigned i = 0, e = Add->getNumOperands(); i != e; ++i) if (i != FoundIndex) Ops.push_back(Add->getOperand(i)); - const SCEV* Accum = getAddExpr(Ops); + const SCEV *Accum = getAddExpr(Ops); // This is not a valid addrec if the step amount is varying each // loop iteration, but is not itself an addrec in this loop. @@ -2341,13 +2341,13 @@ // Because the other in-value of i (0) fits the evolution of BEValue // i really is an addrec evolution. if (AddRec->getLoop() == L && AddRec->isAffine()) { - const SCEV* StartVal = getSCEV(PN->getIncomingValue(IncomingEdge)); + const SCEV *StartVal = getSCEV(PN->getIncomingValue(IncomingEdge)); // If StartVal = j.start - j.stride, we can use StartVal as the // initial step of the addrec evolution. if (StartVal == getMinusSCEV(AddRec->getOperand(0), AddRec->getOperand(1))) { - const SCEV* PHISCEV = + const SCEV *PHISCEV = getAddRecExpr(StartVal, AddRec->getOperand(1), L); // Okay, for the entire analysis of this edge we assumed the PHI @@ -2371,14 +2371,14 @@ /// createNodeForGEP - Expand GEP instructions into add and multiply /// operations. This allows them to be analyzed by regular SCEV code. /// -const SCEV* ScalarEvolution::createNodeForGEP(User *GEP) { +const SCEV *ScalarEvolution::createNodeForGEP(User *GEP) { const Type *IntPtrTy = TD->getIntPtrType(); Value *Base = GEP->getOperand(0); // Don't attempt to analyze GEPs over unsized objects. if (!cast(Base->getType())->getElementType()->isSized()) return getUnknown(GEP); - const SCEV* TotalOffset = getIntegerSCEV(0, IntPtrTy); + const SCEV *TotalOffset = getIntegerSCEV(0, IntPtrTy); gep_type_iterator GTI = gep_type_begin(GEP); for (GetElementPtrInst::op_iterator I = next(GEP->op_begin()), E = GEP->op_end(); @@ -2394,7 +2394,7 @@ getIntegerSCEV(Offset, IntPtrTy)); } else { // For an array, add the element offset, explicitly scaled. - const SCEV* LocalOffset = getSCEV(Index); + const SCEV *LocalOffset = getSCEV(Index); if (!isa(LocalOffset->getType())) // Getelementptr indicies are signed. LocalOffset = getTruncateOrSignExtend(LocalOffset, @@ -2414,7 +2414,7 @@ /// the minimum number of times S is divisible by 2. For example, given {4,+,8} /// it returns 2. If S is guaranteed to be 0, it returns the bitwidth of S. uint32_t -ScalarEvolution::GetMinTrailingZeros(const SCEV* S) { +ScalarEvolution::GetMinTrailingZeros(const SCEV *S) { if (const SCEVConstant *C = dyn_cast(S)) return C->getValue()->getValue().countTrailingZeros(); @@ -2491,7 +2491,7 @@ } uint32_t -ScalarEvolution::GetMinLeadingZeros(const SCEV* S) { +ScalarEvolution::GetMinLeadingZeros(const SCEV *S) { // TODO: Handle other SCEV expression types here. if (const SCEVConstant *C = dyn_cast(S)) @@ -2517,7 +2517,7 @@ } uint32_t -ScalarEvolution::GetMinSignBits(const SCEV* S) { +ScalarEvolution::GetMinSignBits(const SCEV *S) { // TODO: Handle other SCEV expression types here. if (const SCEVConstant *C = dyn_cast(S)) { @@ -2576,7 +2576,7 @@ /// createSCEV - We know that there is no SCEV for the specified value. /// Analyze the expression. /// -const SCEV* ScalarEvolution::createSCEV(Value *V) { +const SCEV *ScalarEvolution::createSCEV(Value *V) { if (!isSCEVable(V->getType())) return getUnknown(V); @@ -2646,7 +2646,7 @@ // In order for this transformation to be safe, the LHS must be of the // form X*(2^n) and the Or constant must be less than 2^n. if (ConstantInt *CI = dyn_cast(U->getOperand(1))) { - const SCEV* LHS = getSCEV(U->getOperand(0)); + const SCEV *LHS = getSCEV(U->getOperand(0)); const APInt &CIVal = CI->getValue(); if (GetMinTrailingZeros(LHS) >= (CIVal.getBitWidth() - CIVal.countLeadingZeros())) @@ -2676,7 +2676,7 @@ if (const SCEVZeroExtendExpr *Z = dyn_cast(getSCEV(U->getOperand(0)))) { const Type *UTy = U->getType(); - const SCEV* Z0 = Z->getOperand(); + const SCEV *Z0 = Z->getOperand(); const Type *Z0Ty = Z0->getType(); unsigned Z0TySize = getTypeSizeInBits(Z0Ty); @@ -2845,14 +2845,14 @@ /// loop-invariant backedge-taken count (see /// hasLoopInvariantBackedgeTakenCount). /// -const SCEV* ScalarEvolution::getBackedgeTakenCount(const Loop *L) { +const SCEV *ScalarEvolution::getBackedgeTakenCount(const Loop *L) { return getBackedgeTakenInfo(L).Exact; } /// getMaxBackedgeTakenCount - Similar to getBackedgeTakenCount, except /// return the least SCEV value that is known never to be less than the /// actual backedge taken count. -const SCEV* ScalarEvolution::getMaxBackedgeTakenCount(const Loop *L) { +const SCEV *ScalarEvolution::getMaxBackedgeTakenCount(const Loop *L) { return getBackedgeTakenInfo(L).Max; } @@ -2919,7 +2919,7 @@ SmallVector Worklist; for (BasicBlock::iterator I = Header->begin(); PHINode *PN = dyn_cast(I); ++I) { - std::map::iterator It = + std::map::iterator It = Scalars.find((Value*)I); if (It != Scalars.end() && !isa(It->second)) Worklist.push_back(PN); @@ -2942,8 +2942,8 @@ L->getExitingBlocks(ExitingBlocks); // Examine all exits and pick the most conservative values. - const SCEV* BECount = getCouldNotCompute(); - const SCEV* MaxBECount = getCouldNotCompute(); + const SCEV *BECount = getCouldNotCompute(); + const SCEV *MaxBECount = getCouldNotCompute(); bool CouldNotComputeBECount = false; for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i) { BackedgeTakenInfo NewBTI = @@ -3052,8 +3052,8 @@ ComputeBackedgeTakenCountFromExitCond(L, BO->getOperand(0), TBB, FBB); BackedgeTakenInfo BTI1 = ComputeBackedgeTakenCountFromExitCond(L, BO->getOperand(1), TBB, FBB); - const SCEV* BECount = getCouldNotCompute(); - const SCEV* MaxBECount = getCouldNotCompute(); + const SCEV *BECount = getCouldNotCompute(); + const SCEV *MaxBECount = getCouldNotCompute(); if (L->contains(TBB)) { // Both conditions must be true for the loop to continue executing. // Choose the less conservative count. @@ -3087,8 +3087,8 @@ ComputeBackedgeTakenCountFromExitCond(L, BO->getOperand(0), TBB, FBB); BackedgeTakenInfo BTI1 = ComputeBackedgeTakenCountFromExitCond(L, BO->getOperand(1), TBB, FBB); - const SCEV* BECount = getCouldNotCompute(); - const SCEV* MaxBECount = getCouldNotCompute(); + const SCEV *BECount = getCouldNotCompute(); + const SCEV *MaxBECount = getCouldNotCompute(); if (L->contains(FBB)) { // Both conditions must be false for the loop to continue executing. // Choose the less conservative count. @@ -3146,7 +3146,7 @@ // Handle common loops like: for (X = "string"; *X; ++X) if (LoadInst *LI = dyn_cast(ExitCond->getOperand(0))) if (Constant *RHS = dyn_cast(ExitCond->getOperand(1))) { - const SCEV* ItCnt = + const SCEV *ItCnt = ComputeLoadConstantCompareBackedgeTakenCount(LI, RHS, L, Cond); if (!isa(ItCnt)) { unsigned BitWidth = getTypeSizeInBits(ItCnt->getType()); @@ -3156,8 +3156,8 @@ } } - const SCEV* LHS = getSCEV(ExitCond->getOperand(0)); - const SCEV* RHS = getSCEV(ExitCond->getOperand(1)); + const SCEV *LHS = getSCEV(ExitCond->getOperand(0)); + const SCEV *RHS = getSCEV(ExitCond->getOperand(1)); // Try to evaluate any dependencies out of the loop. LHS = getSCEVAtScope(LHS, L); @@ -3180,20 +3180,20 @@ ConstantRange CompRange( ICmpInst::makeConstantRange(Cond, RHSC->getValue()->getValue())); - const SCEV* Ret = AddRec->getNumIterationsInRange(CompRange, *this); + const SCEV *Ret = AddRec->getNumIterationsInRange(CompRange, *this); if (!isa(Ret)) return Ret; } switch (Cond) { case ICmpInst::ICMP_NE: { // while (X != Y) // Convert to: while (X-Y != 0) - const SCEV* TC = HowFarToZero(getMinusSCEV(LHS, RHS), L); + const SCEV *TC = HowFarToZero(getMinusSCEV(LHS, RHS), L); if (!isa(TC)) return TC; break; } case ICmpInst::ICMP_EQ: { // Convert to: while (X-Y == 0) // while (X == Y) - const SCEV* TC = HowFarToNonZero(getMinusSCEV(LHS, RHS), L); + const SCEV *TC = HowFarToNonZero(getMinusSCEV(LHS, RHS), L); if (!isa(TC)) return TC; break; } @@ -3237,8 +3237,8 @@ static ConstantInt * EvaluateConstantChrecAtConstant(const SCEVAddRecExpr *AddRec, ConstantInt *C, ScalarEvolution &SE) { - const SCEV* InVal = SE.getConstant(C); - const SCEV* Val = AddRec->evaluateAtIteration(InVal, SE); + const SCEV *InVal = SE.getConstant(C); + const SCEV *Val = AddRec->evaluateAtIteration(InVal, SE); assert(isa(Val) && "Evaluation of SCEV at constant didn't fold correctly?"); return cast(Val)->getValue(); @@ -3317,7 +3317,7 @@ // Okay, we know we have a (load (gep GV, 0, X)) comparison with a constant. // Check to see if X is a loop variant variable value now. - const SCEV* Idx = getSCEV(VarIdx); + const SCEV *Idx = getSCEV(VarIdx); Idx = getSCEVAtScope(Idx, L); // We can only recognize very limited forms of loop index expressions, in @@ -3556,7 +3556,7 @@ /// /// In the case that a relevant loop exit value cannot be computed, the /// original value V is returned. -const SCEV* ScalarEvolution::getSCEVAtScope(const SCEV *V, const Loop *L) { +const SCEV *ScalarEvolution::getSCEVAtScope(const SCEV *V, const Loop *L) { // FIXME: this should be turned into a virtual method on SCEV! if (isa(V)) return V; @@ -3573,7 +3573,7 @@ // to see if the loop that contains it has a known backedge-taken // count. If so, we may be able to force computation of the exit // value. - const SCEV* BackedgeTakenCount = getBackedgeTakenCount(LI); + const SCEV *BackedgeTakenCount = getBackedgeTakenCount(LI); if (const SCEVConstant *BTCC = dyn_cast(BackedgeTakenCount)) { // Okay, we know how many times the containing loop executes. If @@ -3611,7 +3611,7 @@ if (!isSCEVable(Op->getType())) return V; - const SCEV* OpV = getSCEVAtScope(getSCEV(Op), L); + const SCEV *OpV = getSCEVAtScope(getSCEV(Op), L); if (const SCEVConstant *SC = dyn_cast(OpV)) { Constant *C = SC->getValue(); if (C->getType() != Op->getType()) @@ -3658,7 +3658,7 @@ // Avoid performing the look-up in the common case where the specified // expression has no loop-variant portions. for (unsigned i = 0, e = Comm->getNumOperands(); i != e; ++i) { - const SCEV* OpAtScope = getSCEVAtScope(Comm->getOperand(i), L); + const SCEV *OpAtScope = getSCEVAtScope(Comm->getOperand(i), L); if (OpAtScope != Comm->getOperand(i)) { // Okay, at least one of these operands is loop variant but might be // foldable. Build a new instance of the folded commutative expression. @@ -3686,8 +3686,8 @@ } if (const SCEVUDivExpr *Div = dyn_cast(V)) { - const SCEV* LHS = getSCEVAtScope(Div->getLHS(), L); - const SCEV* RHS = getSCEVAtScope(Div->getRHS(), L); + const SCEV *LHS = getSCEVAtScope(Div->getLHS(), L); + const SCEV *RHS = getSCEVAtScope(Div->getRHS(), L); if (LHS == Div->getLHS() && RHS == Div->getRHS()) return Div; // must be loop invariant return getUDivExpr(LHS, RHS); @@ -3699,7 +3699,7 @@ if (!L || !AddRec->getLoop()->contains(L->getHeader())) { // To evaluate this recurrence, we need to know how many times the AddRec // loop iterates. Compute this now. - const SCEV* BackedgeTakenCount = getBackedgeTakenCount(AddRec->getLoop()); + const SCEV *BackedgeTakenCount = getBackedgeTakenCount(AddRec->getLoop()); if (BackedgeTakenCount == getCouldNotCompute()) return AddRec; // Then, evaluate the AddRec. @@ -3709,21 +3709,21 @@ } if (const SCEVZeroExtendExpr *Cast = dyn_cast(V)) { - const SCEV* Op = getSCEVAtScope(Cast->getOperand(), L); + const SCEV *Op = getSCEVAtScope(Cast->getOperand(), L); if (Op == Cast->getOperand()) return Cast; // must be loop invariant return getZeroExtendExpr(Op, Cast->getType()); } if (const SCEVSignExtendExpr *Cast = dyn_cast(V)) { - const SCEV* Op = getSCEVAtScope(Cast->getOperand(), L); + const SCEV *Op = getSCEVAtScope(Cast->getOperand(), L); if (Op == Cast->getOperand()) return Cast; // must be loop invariant return getSignExtendExpr(Op, Cast->getType()); } if (const SCEVTruncateExpr *Cast = dyn_cast(V)) { - const SCEV* Op = getSCEVAtScope(Cast->getOperand(), L); + const SCEV *Op = getSCEVAtScope(Cast->getOperand(), L); if (Op == Cast->getOperand()) return Cast; // must be loop invariant return getTruncateExpr(Op, Cast->getType()); @@ -3735,7 +3735,7 @@ /// getSCEVAtScope - This is a convenience function which does /// getSCEVAtScope(getSCEV(V), L). -const SCEV* ScalarEvolution::getSCEVAtScope(Value *V, const Loop *L) { +const SCEV *ScalarEvolution::getSCEVAtScope(Value *V, const Loop *L) { return getSCEVAtScope(getSCEV(V), L); } @@ -3748,7 +3748,7 @@ /// A and B isn't important. /// /// If the equation does not have a solution, SCEVCouldNotCompute is returned. -static const SCEV* SolveLinEquationWithOverflow(const APInt &A, const APInt &B, +static const SCEV *SolveLinEquationWithOverflow(const APInt &A, const APInt &B, ScalarEvolution &SE) { uint32_t BW = A.getBitWidth(); assert(BW == B.getBitWidth() && "Bit widths must be the same."); @@ -3791,7 +3791,7 @@ /// given quadratic chrec {L,+,M,+,N}. This returns either the two roots (which /// might be the same) or two SCEVCouldNotCompute objects. /// -static std::pair +static std::pair SolveQuadraticEquation(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) { assert(AddRec->getNumOperands() == 3 && "This is not a quadratic chrec!"); const SCEVConstant *LC = dyn_cast(AddRec->getOperand(0)); @@ -3854,7 +3854,7 @@ /// HowFarToZero - Return the number of times a backedge comparing the specified /// value to zero will execute. If not computable, return CouldNotCompute. -const SCEV* ScalarEvolution::HowFarToZero(const SCEV *V, const Loop *L) { +const SCEV *ScalarEvolution::HowFarToZero(const SCEV *V, const Loop *L) { // If the value is a constant if (const SCEVConstant *C = dyn_cast(V)) { // If the value is already zero, the branch will execute zero times. @@ -3902,7 +3902,7 @@ } else if (AddRec->isQuadratic() && AddRec->getType()->isInteger()) { // If this is a quadratic (3-term) AddRec {L,+,M,+,N}, find the roots of // the quadratic equation to solve it. - std::pair Roots = SolveQuadraticEquation(AddRec, + std::pair Roots = SolveQuadraticEquation(AddRec, *this); const SCEVConstant *R1 = dyn_cast(Roots.first); const SCEVConstant *R2 = dyn_cast(Roots.second); @@ -3921,7 +3921,7 @@ // We can only use this value if the chrec ends up with an exact zero // value at this index. When solving for "X*X != 5", for example, we // should not accept a root of 2. - const SCEV* Val = AddRec->evaluateAtIteration(R1, *this); + const SCEV *Val = AddRec->evaluateAtIteration(R1, *this); if (Val->isZero()) return R1; // We found a quadratic root! } @@ -3934,7 +3934,7 @@ /// HowFarToNonZero - Return the number of times a backedge checking the /// specified value for nonzero will execute. If not computable, return /// CouldNotCompute -const SCEV* ScalarEvolution::HowFarToNonZero(const SCEV *V, const Loop *L) { +const SCEV *ScalarEvolution::HowFarToNonZero(const SCEV *V, const Loop *L) { // Loops that look like: while (X == 0) are very strange indeed. We don't // handle them yet except for the trivial case. This could be expanded in the // future as needed. @@ -3995,7 +3995,7 @@ /// more general, since a front-end may have replicated the controlling /// expression. /// -static bool HasSameValue(const SCEV* A, const SCEV* B) { +static bool HasSameValue(const SCEV *A, const SCEV *B) { // Quick check to see if they are the same SCEV. if (A == B) return true; @@ -4148,22 +4148,22 @@ /// getBECount - Subtract the end and start values and divide by the step, /// rounding up, to get the number of times the backedge is executed. Return /// CouldNotCompute if an intermediate computation overflows. -const SCEV* ScalarEvolution::getBECount(const SCEV* Start, - const SCEV* End, - const SCEV* Step) { +const SCEV *ScalarEvolution::getBECount(const SCEV *Start, + const SCEV *End, + const SCEV *Step) { const Type *Ty = Start->getType(); - const SCEV* NegOne = getIntegerSCEV(-1, Ty); - const SCEV* Diff = getMinusSCEV(End, Start); - const SCEV* RoundUp = getAddExpr(Step, NegOne); + const SCEV *NegOne = getIntegerSCEV(-1, Ty); + const SCEV *Diff = getMinusSCEV(End, Start); + const SCEV *RoundUp = getAddExpr(Step, NegOne); // Add an adjustment to the difference between End and Start so that // the division will effectively round up. - const SCEV* Add = getAddExpr(Diff, RoundUp); + const SCEV *Add = getAddExpr(Diff, RoundUp); // Check Add for unsigned overflow. // TODO: More sophisticated things could be done here. const Type *WideTy = Context->getIntegerType(getTypeSizeInBits(Ty) + 1); - const SCEV* OperandExtendedAdd = + const SCEV *OperandExtendedAdd = getAddExpr(getZeroExtendExpr(Diff, WideTy), getZeroExtendExpr(RoundUp, WideTy)); if (getZeroExtendExpr(Add, WideTy) != OperandExtendedAdd) @@ -4188,7 +4188,7 @@ if (AddRec->isAffine()) { // FORNOW: We only support unit strides. unsigned BitWidth = getTypeSizeInBits(AddRec->getType()); - const SCEV* Step = AddRec->getStepRecurrence(*this); + const SCEV *Step = AddRec->getStepRecurrence(*this); // TODO: handle non-constant strides. const SCEVConstant *CStep = dyn_cast(Step); @@ -4224,7 +4224,7 @@ // treat m-n as signed nor unsigned due to overflow possibility. // First, we get the value of the LHS in the first iteration: n - const SCEV* Start = AddRec->getOperand(0); + const SCEV *Start = AddRec->getOperand(0); // Determine the minimum constant start value. const SCEV *MinStart = isa(Start) ? Start : @@ -4235,7 +4235,7 @@ // then we know that it will run exactly (m-n)/s times. Otherwise, we // only know that it will execute (max(m,n)-n)/s times. In both cases, // the division must round up. - const SCEV* End = RHS; + const SCEV *End = RHS; if (!isLoopGuardedByCond(L, isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, getMinusSCEV(Start, Step), RHS)) @@ -4243,7 +4243,7 @@ : getUMaxExpr(RHS, Start); // Determine the maximum constant end value. - const SCEV* MaxEnd = + const SCEV *MaxEnd = isa(End) ? End : getConstant(isSigned ? APInt::getSignedMaxValue(BitWidth) .ashr(GetMinSignBits(End) - 1) : @@ -4252,11 +4252,11 @@ // Finally, we subtract these two values and divide, rounding up, to get // the number of times the backedge is executed. - const SCEV* BECount = getBECount(Start, End, Step); + const SCEV *BECount = getBECount(Start, End, Step); // The maximum backedge count is similar, except using the minimum start // value and the maximum end value. - const SCEV* MaxBECount = getBECount(MinStart, MaxEnd, Step); + const SCEV *MaxBECount = getBECount(MinStart, MaxEnd, Step); return BackedgeTakenInfo(BECount, MaxBECount); } @@ -4269,7 +4269,7 @@ /// this is that it returns the first iteration number where the value is not in /// the condition, thus computing the exit count. If the iteration count can't /// be computed, an instance of SCEVCouldNotCompute is returned. -const SCEV* SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range, +const SCEV *SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range, ScalarEvolution &SE) const { if (Range.isFullSet()) // Infinite loop. return SE.getCouldNotCompute(); @@ -4277,9 +4277,9 @@ // If the start is a non-zero constant, shift the range to simplify things. if (const SCEVConstant *SC = dyn_cast(getStart())) if (!SC->getValue()->isZero()) { - SmallVector Operands(op_begin(), op_end()); + SmallVector Operands(op_begin(), op_end()); Operands[0] = SE.getIntegerSCEV(0, SC->getType()); - const SCEV* Shifted = SE.getAddRecExpr(Operands, getLoop()); + const SCEV *Shifted = SE.getAddRecExpr(Operands, getLoop()); if (const SCEVAddRecExpr *ShiftedAddRec = dyn_cast(Shifted)) return ShiftedAddRec->getNumIterationsInRange( @@ -4338,12 +4338,12 @@ // quadratic equation to solve it. To do this, we must frame our problem in // terms of figuring out when zero is crossed, instead of when // Range.getUpper() is crossed. - SmallVector NewOps(op_begin(), op_end()); + SmallVector NewOps(op_begin(), op_end()); NewOps[0] = SE.getNegativeSCEV(SE.getConstant(Range.getUpper())); - const SCEV* NewAddRec = SE.getAddRecExpr(NewOps, getLoop()); + const SCEV *NewAddRec = SE.getAddRecExpr(NewOps, getLoop()); // Next, solve the constructed addrec - std::pair Roots = + std::pair Roots = SolveQuadraticEquation(cast(NewAddRec), SE); const SCEVConstant *R1 = dyn_cast(Roots.first); const SCEVConstant *R2 = dyn_cast(Roots.second); @@ -4525,12 +4525,12 @@ if (isSCEVable(I->getType())) { OS << *I; OS << " --> "; - const SCEV* SV = SE.getSCEV(&*I); + const SCEV *SV = SE.getSCEV(&*I); SV->print(OS); const Loop *L = LI->getLoopFor((*I).getParent()); - const SCEV* AtUse = SE.getSCEVAtScope(SV, L); + const SCEV *AtUse = SE.getSCEVAtScope(SV, L); if (AtUse != SV) { OS << " --> "; AtUse->print(OS); @@ -4538,7 +4538,7 @@ if (L) { OS << "\t\t" "Exits: "; - const SCEV* ExitValue = SE.getSCEVAtScope(SV, L->getParentLoop()); + const SCEV *ExitValue = SE.getSCEVAtScope(SV, L->getParentLoop()); if (!ExitValue->isLoopInvariant(L)) { OS << "<>"; } else { Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Tue Jul 7 12:06:11 2009 @@ -156,8 +156,8 @@ /// TODO: When ScalarEvolution gets a SCEVSDivExpr, this can be made /// unnecessary; in its place, just signed-divide Ops[i] by the scale and /// check to see if the divide was folded. -static bool FactorOutConstant(const SCEV* &S, - const SCEV* &Remainder, +static bool FactorOutConstant(const SCEV *&S, + const SCEV *&Remainder, const APInt &Factor, ScalarEvolution &SE) { // Everything is divisible by one. @@ -172,7 +172,7 @@ // the value at this scale. It will be considered for subsequent // smaller scales. if (C->isZero() || !CI->isZero()) { - const SCEV* Div = SE.getConstant(CI); + const SCEV *Div = SE.getConstant(CI); S = Div; Remainder = SE.getAddExpr(Remainder, @@ -197,13 +197,13 @@ // In an AddRec, check if both start and step are divisible. if (const SCEVAddRecExpr *A = dyn_cast(S)) { - const SCEV* Step = A->getStepRecurrence(SE); - const SCEV* StepRem = SE.getIntegerSCEV(0, Step->getType()); + const SCEV *Step = A->getStepRecurrence(SE); + const SCEV *StepRem = SE.getIntegerSCEV(0, Step->getType()); if (!FactorOutConstant(Step, StepRem, Factor, SE)) return false; if (!StepRem->isZero()) return false; - const SCEV* Start = A->getStart(); + const SCEV *Start = A->getStart(); if (!FactorOutConstant(Start, Remainder, Factor, SE)) return false; S = SE.getAddRecExpr(Start, Step, A->getLoop()); @@ -238,14 +238,14 @@ /// loop-invariant portions of expressions, after considering what /// can be folded using target addressing modes. /// -Value *SCEVExpander::expandAddToGEP(const SCEV* const *op_begin, - const SCEV* const *op_end, +Value *SCEVExpander::expandAddToGEP(const SCEV *const *op_begin, + const SCEV *const *op_end, const PointerType *PTy, const Type *Ty, Value *V) { const Type *ElTy = PTy->getElementType(); SmallVector GepIndices; - SmallVector Ops(op_begin, op_end); + SmallVector Ops(op_begin, op_end); bool AnyNonZeroIndices = false; // Decend down the pointer's type and attempt to convert the other @@ -256,14 +256,14 @@ for (;;) { APInt ElSize = APInt(SE.getTypeSizeInBits(Ty), ElTy->isSized() ? SE.TD->getTypeAllocSize(ElTy) : 0); - SmallVector NewOps; - SmallVector ScaledOps; + SmallVector NewOps; + SmallVector ScaledOps; for (unsigned i = 0, e = Ops.size(); i != e; ++i) { // Split AddRecs up into parts as either of the parts may be usable // without the other. if (const SCEVAddRecExpr *A = dyn_cast(Ops[i])) if (!A->getStart()->isZero()) { - const SCEV* Start = A->getStart(); + const SCEV *Start = A->getStart(); Ops.push_back(SE.getAddRecExpr(SE.getIntegerSCEV(0, A->getType()), A->getStepRecurrence(SE), A->getLoop())); @@ -272,8 +272,8 @@ } // If the scale size is not 0, attempt to factor out a scale. if (ElSize != 0) { - const SCEV* Op = Ops[i]; - const SCEV* Remainder = SE.getIntegerSCEV(0, Op->getType()); + const SCEV *Op = Ops[i]; + const SCEV *Remainder = SE.getIntegerSCEV(0, Op->getType()); if (FactorOutConstant(Op, Remainder, ElSize, SE)) { ScaledOps.push_back(Op); // Op now has ElSize factored out. NewOps.push_back(Remainder); @@ -370,7 +370,7 @@ // comments on expandAddToGEP for details. if (SE.TD) if (const PointerType *PTy = dyn_cast(V->getType())) { - const SmallVectorImpl &Ops = S->getOperands(); + const SmallVectorImpl &Ops = S->getOperands(); return expandAddToGEP(&Ops[0], &Ops[Ops.size() - 1], PTy, Ty, V); } @@ -424,7 +424,7 @@ /// Move parts of Base into Rest to leave Base with the minimal /// expression that provides a pointer operand suitable for a /// GEP expansion. -static void ExposePointerBase(const SCEV* &Base, const SCEV* &Rest, +static void ExposePointerBase(const SCEV *&Base, const SCEV *&Rest, ScalarEvolution &SE) { while (const SCEVAddRecExpr *A = dyn_cast(Base)) { Base = A->getStart(); @@ -435,7 +435,7 @@ } if (const SCEVAddExpr *A = dyn_cast(Base)) { Base = A->getOperand(A->getNumOperands()-1); - SmallVector NewAddOps(A->op_begin(), A->op_end()); + SmallVector NewAddOps(A->op_begin(), A->op_end()); NewAddOps.back() = Rest; Rest = SE.getAddExpr(NewAddOps); ExposePointerBase(Base, Rest, SE); @@ -477,16 +477,16 @@ // {X,+,F} --> X + {0,+,F} if (!S->getStart()->isZero()) { - const SmallVectorImpl &SOperands = S->getOperands(); - SmallVector NewOps(SOperands.begin(), SOperands.end()); + const SmallVectorImpl &SOperands = S->getOperands(); + SmallVector NewOps(SOperands.begin(), SOperands.end()); NewOps[0] = SE.getIntegerSCEV(0, Ty); - const SCEV* Rest = SE.getAddRecExpr(NewOps, L); + const SCEV *Rest = SE.getAddRecExpr(NewOps, L); // Turn things like ptrtoint+arithmetic+inttoptr into GEP. See the // comments on expandAddToGEP for details. if (SE.TD) { - const SCEV* Base = S->getStart(); - const SCEV* RestArray[1] = { Rest }; + const SCEV *Base = S->getStart(); + const SCEV *RestArray[1] = { Rest }; // Dig into the expression to find the pointer base for a GEP. ExposePointerBase(Base, RestArray[0], SE); // If we found a pointer, expand the AddRec with a GEP. @@ -565,19 +565,19 @@ // folders, then expandCodeFor the closed form. This allows the folders to // simplify the expression without having to build a bunch of special code // into this folder. - const SCEV* IH = SE.getUnknown(I); // Get I as a "symbolic" SCEV. + const SCEV *IH = SE.getUnknown(I); // Get I as a "symbolic" SCEV. // Promote S up to the canonical IV type, if the cast is foldable. - const SCEV* NewS = S; - const SCEV* Ext = SE.getNoopOrAnyExtend(S, I->getType()); + const SCEV *NewS = S; + const SCEV *Ext = SE.getNoopOrAnyExtend(S, I->getType()); if (isa(Ext)) NewS = Ext; - const SCEV* V = cast(NewS)->evaluateAtIteration(IH, SE); + const SCEV *V = cast(NewS)->evaluateAtIteration(IH, SE); //cerr << "Evaluated: " << *this << "\n to: " << *V << "\n"; // Truncate the result down to the original type, if needed. - const SCEV* T = SE.getTruncateOrNoop(V, Ty); + const SCEV *T = SE.getTruncateOrNoop(V, Ty); return expand(T); } @@ -636,7 +636,7 @@ return LHS; } -Value *SCEVExpander::expandCodeFor(const SCEV* SH, const Type *Ty) { +Value *SCEVExpander::expandCodeFor(const SCEV *SH, const Type *Ty) { // Expand the code for this SCEV. Value *V = expand(SH); if (Ty) { @@ -697,7 +697,7 @@ SCEVExpander::getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty) { assert(Ty->isInteger() && "Can only insert integer induction variables!"); - const SCEV* H = SE.getAddRecExpr(SE.getIntegerSCEV(0, Ty), + const SCEV *H = SE.getAddRecExpr(SE.getIntegerSCEV(0, Ty), SE.getIntegerSCEV(1, Ty), L); BasicBlock *SaveInsertBB = Builder.GetInsertBlock(); BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint(); Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Tue Jul 7 12:06:11 2009 @@ -98,7 +98,7 @@ void RewriteNonIntegerIVs(Loop *L); - ICmpInst *LinearFunctionTestReplace(Loop *L, const SCEV* BackedgeTakenCount, + ICmpInst *LinearFunctionTestReplace(Loop *L, const SCEV *BackedgeTakenCount, Value *IndVar, BasicBlock *ExitingBlock, BranchInst *BI, @@ -129,7 +129,7 @@ /// SCEV analysis can determine a loop-invariant trip count of the loop, which /// is actually a much broader range than just linear tests. ICmpInst *IndVarSimplify::LinearFunctionTestReplace(Loop *L, - const SCEV* BackedgeTakenCount, + const SCEV *BackedgeTakenCount, Value *IndVar, BasicBlock *ExitingBlock, BranchInst *BI, @@ -138,13 +138,13 @@ // against the preincremented value, otherwise we prefer to compare against // the post-incremented value. Value *CmpIndVar; - const SCEV* RHS = BackedgeTakenCount; + const SCEV *RHS = BackedgeTakenCount; if (ExitingBlock == L->getLoopLatch()) { // Add one to the "backedge-taken" count to get the trip count. // If this addition may overflow, we have to be more pessimistic and // cast the induction variable before doing the add. - const SCEV* Zero = SE->getIntegerSCEV(0, BackedgeTakenCount->getType()); - const SCEV* N = + const SCEV *Zero = SE->getIntegerSCEV(0, BackedgeTakenCount->getType()); + const SCEV *N = SE->getAddExpr(BackedgeTakenCount, SE->getIntegerSCEV(1, BackedgeTakenCount->getType())); if ((isa(N) && !N->isZero()) || @@ -264,7 +264,7 @@ // Okay, this instruction has a user outside of the current loop // and varies predictably *inside* the loop. Evaluate the value it // contains when the loop exits, if possible. - const SCEV* ExitValue = SE->getSCEVAtScope(Inst, L->getParentLoop()); + const SCEV *ExitValue = SE->getSCEVAtScope(Inst, L->getParentLoop()); if (!ExitValue->isLoopInvariant(L)) continue; @@ -339,7 +339,7 @@ RewriteNonIntegerIVs(L); BasicBlock *ExitingBlock = L->getExitingBlock(); // may be null - const SCEV* BackedgeTakenCount = SE->getBackedgeTakenCount(L); + const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); // Create a rewriter object which we'll use to transform the code with. SCEVExpander Rewriter(*SE); @@ -367,14 +367,14 @@ NeedCannIV = true; } for (unsigned i = 0, e = IU->StrideOrder.size(); i != e; ++i) { - const SCEV* Stride = IU->StrideOrder[i]; + const SCEV *Stride = IU->StrideOrder[i]; const Type *Ty = SE->getEffectiveSCEVType(Stride->getType()); if (!LargestType || SE->getTypeSizeInBits(Ty) > SE->getTypeSizeInBits(LargestType)) LargestType = Ty; - std::map::iterator SI = + std::map::iterator SI = IU->IVUsesByStride.find(IU->StrideOrder[i]); assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); @@ -458,9 +458,9 @@ // the need for the code evaluation methods to insert induction variables // of different sizes. for (unsigned i = 0, e = IU->StrideOrder.size(); i != e; ++i) { - const SCEV* Stride = IU->StrideOrder[i]; + const SCEV *Stride = IU->StrideOrder[i]; - std::map::iterator SI = + std::map::iterator SI = IU->IVUsesByStride.find(IU->StrideOrder[i]); assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); ilist &List = SI->second->Users; @@ -471,7 +471,7 @@ Instruction *User = UI->getUser(); // Compute the final addrec to expand into code. - const SCEV* AR = IU->getReplacementExpr(*UI); + const SCEV *AR = IU->getReplacementExpr(*UI); // FIXME: It is an extremely bad idea to indvar substitute anything more // complex than affine induction variables. Doing so will put expensive Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Tue Jul 7 12:06:11 2009 @@ -187,7 +187,7 @@ // Don't remove loops for which we can't solve the trip count. // They could be infinite, in which case we'd be changing program behavior. ScalarEvolution& SE = getAnalysis(); - const SCEV* S = SE.getBackedgeTakenCount(L); + const SCEV *S = SE.getBackedgeTakenCount(L); if (isa(S)) return false; Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=74918&r1=74917&r2=74918&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Jul 7 12:06:11 2009 @@ -65,11 +65,11 @@ /// StrengthReduceStridedIVUsers. It contains the stride, the common base, as /// well as the PHI node and increment value created for rewrite. struct VISIBILITY_HIDDEN IVExpr { - const SCEV* Stride; - const SCEV* Base; + const SCEV *Stride; + const SCEV *Base; PHINode *PHI; - IVExpr(const SCEV* const stride, const SCEV* const base, PHINode *phi) + IVExpr(const SCEV *const stride, const SCEV *const base, PHINode *phi) : Stride(stride), Base(base), PHI(phi) {} }; @@ -78,7 +78,7 @@ struct VISIBILITY_HIDDEN IVsOfOneStride { std::vector IVs; - void addIV(const SCEV* const Stride, const SCEV* const Base, PHINode *PHI) { + void addIV(const SCEV *const Stride, const SCEV *const Base, PHINode *PHI) { IVs.push_back(IVExpr(Stride, Base, PHI)); } }; @@ -92,11 +92,11 @@ /// IVsByStride - Keep track of all IVs that have been inserted for a /// particular stride. - std::map IVsByStride; + std::map IVsByStride; /// StrideNoReuse - Keep track of all the strides whose ivs cannot be /// reused (nor should they be rewritten to reuse other strides). - SmallSet StrideNoReuse; + SmallSet StrideNoReuse; /// DeadInsts - Keep track of instructions we may have made dead, so that /// we can remove them after we are done working. @@ -134,7 +134,7 @@ private: ICmpInst *ChangeCompareStride(Loop *L, ICmpInst *Cond, IVStrideUse* &CondUse, - const SCEV* const * &CondStride); + const SCEV *const * &CondStride); void OptimizeIndvars(Loop *L); void OptimizeLoopCountIV(Loop *L); @@ -150,16 +150,16 @@ IVStrideUse* &CondUse); bool FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse, - const SCEV* const * &CondStride); + const SCEV *const * &CondStride); bool RequiresTypeConversion(const Type *Ty, const Type *NewTy); - const SCEV* CheckForIVReuse(bool, bool, bool, const SCEV* const&, + const SCEV *CheckForIVReuse(bool, bool, bool, const SCEV *const&, IVExpr&, const Type*, const std::vector& UsersToProcess); bool ValidScale(bool, int64_t, const std::vector& UsersToProcess); bool ValidOffset(bool, int64_t, int64_t, const std::vector& UsersToProcess); - const SCEV* CollectIVUsers(const SCEV* const &Stride, + const SCEV *CollectIVUsers(const SCEV *const &Stride, IVUsersOfOneStride &Uses, Loop *L, bool &AllUsesAreAddresses, @@ -169,11 +169,11 @@ const std::vector &UsersToProcess, const Loop *L, bool AllUsesAreAddresses, - const SCEV* Stride); + const SCEV *Stride); void PrepareToStrengthReduceFully( std::vector &UsersToProcess, - const SCEV* Stride, - const SCEV* CommonExprs, + const SCEV *Stride, + const SCEV *CommonExprs, const Loop *L, SCEVExpander &PreheaderRewriter); void PrepareToStrengthReduceFromSmallerStride( @@ -183,13 +183,13 @@ Instruction *PreInsertPt); void PrepareToStrengthReduceWithNewPhi( std::vector &UsersToProcess, - const SCEV* Stride, - const SCEV* CommonExprs, + const SCEV *Stride, + const SCEV *CommonExprs, Value *CommonBaseV, Instruction *IVIncInsertPt, const Loop *L, SCEVExpander &PreheaderRewriter); - void StrengthReduceStridedIVUsers(const SCEV* const &Stride, + void StrengthReduceStridedIVUsers(const SCEV *const &Stride, IVUsersOfOneStride &Uses, Loop *L); void DeleteTriviallyDeadInstructions(); @@ -233,7 +233,7 @@ /// containsAddRecFromDifferentLoop - Determine whether expression S involves a /// subexpression that is an AddRec from a loop other than L. An outer loop /// of L is OK, but not an inner loop nor a disjoint loop. -static bool containsAddRecFromDifferentLoop(const SCEV* S, Loop *L) { +static bool containsAddRecFromDifferentLoop(const SCEV *S, Loop *L) { // This is very common, put it first. if (isa(S)) return false; @@ -328,7 +328,7 @@ /// this use. As the use is processed, information gets moved from this /// field to the Imm field (below). BasedUser values are sorted by this /// field. - const SCEV* Base; + const SCEV *Base; /// Inst - The instruction using the induction variable. Instruction *Inst; @@ -341,7 +341,7 @@ /// before Inst, because it will be folded into the imm field of the /// instruction. This is also sometimes used for loop-variant values that /// must be added inside the loop. - const SCEV* Imm; + const SCEV *Imm; /// Phi - The induction variable that performs the striding that /// should be used for this user. @@ -363,13 +363,13 @@ // Once we rewrite the code to insert the new IVs we want, update the // operands of Inst to use the new expression 'NewBase', with 'Imm' added // to it. - void RewriteInstructionToUseNewBase(const SCEV* const &NewBase, + void RewriteInstructionToUseNewBase(const SCEV *const &NewBase, Instruction *InsertPt, SCEVExpander &Rewriter, Loop *L, Pass *P, LoopInfo &LI, SmallVectorImpl &DeadInsts); - Value *InsertCodeForBaseAtPosition(const SCEV* const &NewBase, + Value *InsertCodeForBaseAtPosition(const SCEV *const &NewBase, const Type *Ty, SCEVExpander &Rewriter, Instruction *IP, Loop *L, @@ -384,7 +384,7 @@ cerr << " Inst: " << *Inst; } -Value *BasedUser::InsertCodeForBaseAtPosition(const SCEV* const &NewBase, +Value *BasedUser::InsertCodeForBaseAtPosition(const SCEV *const &NewBase, const Type *Ty, SCEVExpander &Rewriter, Instruction *IP, Loop *L, @@ -408,7 +408,7 @@ Value *Base = Rewriter.expandCodeFor(NewBase, 0, BaseInsertPt); - const SCEV* NewValSCEV = SE->getUnknown(Base); + const SCEV *NewValSCEV = SE->getUnknown(Base); // Always emit the immediate into the same block as the user. NewValSCEV = SE->getAddExpr(NewValSCEV, Imm); @@ -423,7 +423,7 @@ // value of NewBase in the case that it's a diffferent instruction from // the PHI that NewBase is computed from, or null otherwise. // -void BasedUser::RewriteInstructionToUseNewBase(const SCEV* const &NewBase, +void BasedUser::RewriteInstructionToUseNewBase(const SCEV *const &NewBase, Instruction *NewBasePt, SCEVExpander &Rewriter, Loop *L, Pass *P, LoopInfo &LI, @@ -535,7 +535,7 @@ /// fitsInAddressMode - Return true if V can be subsumed within an addressing /// mode, and does not need to be put in a register first. -static bool fitsInAddressMode(const SCEV* const &V, const Type *AccessTy, +static bool fitsInAddressMode(const SCEV *const &V, const Type *AccessTy, const TargetLowering *TLI, bool HasBaseReg) { if (const SCEVConstant *SC = dyn_cast(V)) { int64_t VC = SC->getValue()->getSExtValue(); @@ -567,12 +567,12 @@ /// MoveLoopVariantsToImmediateField - Move any subexpressions from Val that are /// loop varying to the Imm operand. -static void MoveLoopVariantsToImmediateField(const SCEV* &Val, const SCEV* &Imm, +static void MoveLoopVariantsToImmediateField(const SCEV *&Val, const SCEV *&Imm, Loop *L, ScalarEvolution *SE) { if (Val->isLoopInvariant(L)) return; // Nothing to do. if (const SCEVAddExpr *SAE = dyn_cast(Val)) { - SmallVector NewOps; + SmallVector NewOps; NewOps.reserve(SAE->getNumOperands()); for (unsigned i = 0; i != SAE->getNumOperands(); ++i) @@ -590,10 +590,10 @@ Val = SE->getAddExpr(NewOps); } else if (const SCEVAddRecExpr *SARE = dyn_cast(Val)) { // Try to pull immediates out of the start value of nested addrec's. - const SCEV* Start = SARE->getStart(); + const SCEV *Start = SARE->getStart(); MoveLoopVariantsToImmediateField(Start, Imm, L, SE); - SmallVector Ops(SARE->op_begin(), SARE->op_end()); + SmallVector Ops(SARE->op_begin(), SARE->op_end()); Ops[0] = Start; Val = SE->getAddRecExpr(Ops, SARE->getLoop()); } else { @@ -609,15 +609,15 @@ /// Accumulate these immediate values into the Imm value. static void MoveImmediateValues(const TargetLowering *TLI, const Type *AccessTy, - const SCEV* &Val, const SCEV* &Imm, + const SCEV *&Val, const SCEV *&Imm, bool isAddress, Loop *L, ScalarEvolution *SE) { if (const SCEVAddExpr *SAE = dyn_cast(Val)) { - SmallVector NewOps; + SmallVector NewOps; NewOps.reserve(SAE->getNumOperands()); for (unsigned i = 0; i != SAE->getNumOperands(); ++i) { - const SCEV* NewOp = SAE->getOperand(i); + const SCEV *NewOp = SAE->getOperand(i); MoveImmediateValues(TLI, AccessTy, NewOp, Imm, isAddress, L, SE); if (!NewOp->isLoopInvariant(L)) { @@ -636,11 +636,11 @@ return; } else if (const SCEVAddRecExpr *SARE = dyn_cast(Val)) { // Try to pull immediates out of the start value of nested addrec's. - const SCEV* Start = SARE->getStart(); + const SCEV *Start = SARE->getStart(); MoveImmediateValues(TLI, AccessTy, Start, Imm, isAddress, L, SE); if (Start != SARE->getStart()) { - SmallVector Ops(SARE->op_begin(), SARE->op_end()); + SmallVector Ops(SARE->op_begin(), SARE->op_end()); Ops[0] = Start; Val = SE->getAddRecExpr(Ops, SARE->getLoop()); } @@ -651,8 +651,8 @@ fitsInAddressMode(SME->getOperand(0), AccessTy, TLI, false) && SME->getNumOperands() == 2 && SME->isLoopInvariant(L)) { - const SCEV* SubImm = SE->getIntegerSCEV(0, Val->getType()); - const SCEV* NewOp = SME->getOperand(1); + const SCEV *SubImm = SE->getIntegerSCEV(0, Val->getType()); + const SCEV *NewOp = SME->getOperand(1); MoveImmediateValues(TLI, AccessTy, NewOp, SubImm, isAddress, L, SE); // If we extracted something out of the subexpressions, see if we can @@ -687,7 +687,7 @@ static void MoveImmediateValues(const TargetLowering *TLI, Instruction *User, - const SCEV* &Val, const SCEV* &Imm, + const SCEV *&Val, const SCEV *&Imm, bool isAddress, Loop *L, ScalarEvolution *SE) { const Type *AccessTy = getAccessType(User); @@ -697,19 +697,19 @@ /// SeparateSubExprs - Decompose Expr into all of the subexpressions that are /// added together. This is used to reassociate common addition subexprs /// together for maximal sharing when rewriting bases. -static void SeparateSubExprs(SmallVector &SubExprs, - const SCEV* Expr, +static void SeparateSubExprs(SmallVector &SubExprs, + const SCEV *Expr, ScalarEvolution *SE) { if (const SCEVAddExpr *AE = dyn_cast(Expr)) { for (unsigned j = 0, e = AE->getNumOperands(); j != e; ++j) SeparateSubExprs(SubExprs, AE->getOperand(j), SE); } else if (const SCEVAddRecExpr *SARE = dyn_cast(Expr)) { - const SCEV* Zero = SE->getIntegerSCEV(0, Expr->getType()); + const SCEV *Zero = SE->getIntegerSCEV(0, Expr->getType()); if (SARE->getOperand(0) == Zero) { SubExprs.push_back(Expr); } else { // Compute the addrec with zero as its base. - SmallVector Ops(SARE->op_begin(), SARE->op_end()); + SmallVector Ops(SARE->op_begin(), SARE->op_end()); Ops[0] = Zero; // Start with zero base. SubExprs.push_back(SE->getAddRecExpr(Ops, SARE->getLoop())); @@ -733,7 +733,7 @@ /// not remove anything. This looks for things like (a+b+c) and /// (a+c+d) and computes the common (a+c) subexpression. The common expression /// is *removed* from the Bases and returned. -static const SCEV* +static const SCEV * RemoveCommonExpressionsFromUseBases(std::vector &Uses, ScalarEvolution *SE, Loop *L, const TargetLowering *TLI) { @@ -741,9 +741,9 @@ // Only one use? This is a very common case, so we handle it specially and // cheaply. - const SCEV* Zero = SE->getIntegerSCEV(0, Uses[0].Base->getType()); - const SCEV* Result = Zero; - const SCEV* FreeResult = Zero; + const SCEV *Zero = SE->getIntegerSCEV(0, Uses[0].Base->getType()); + const SCEV *Result = Zero; + const SCEV *FreeResult = Zero; if (NumUses == 1) { // If the use is inside the loop, use its base, regardless of what it is: // it is clearly shared across all the IV's. If the use is outside the loop @@ -759,13 +759,13 @@ // Also track whether all uses of each expression can be moved into an // an addressing mode "for free"; such expressions are left within the loop. // struct SubExprUseData { unsigned Count; bool notAllUsesAreFree; }; - std::map SubExpressionUseData; + std::map SubExpressionUseData; // UniqueSubExprs - Keep track of all of the subexpressions we see in the // order we see them. - SmallVector UniqueSubExprs; + SmallVector UniqueSubExprs; - SmallVector SubExprs; + SmallVector SubExprs; unsigned NumUsesInsideLoop = 0; for (unsigned i = 0; i != NumUses; ++i) { // If the user is outside the loop, just ignore it for base computation. @@ -809,7 +809,7 @@ // Now that we know how many times each is used, build Result. Iterate over // UniqueSubexprs so that we have a stable ordering. for (unsigned i = 0, e = UniqueSubExprs.size(); i != e; ++i) { - std::map::iterator I = + std::map::iterator I = SubExpressionUseData.find(UniqueSubExprs[i]); assert(I != SubExpressionUseData.end() && "Entry not found?"); if (I->second.Count == NumUsesInsideLoop) { // Found CSE! @@ -853,7 +853,7 @@ if (FreeResult != Zero) { SeparateSubExprs(SubExprs, FreeResult, SE); for (unsigned j = 0, e = SubExprs.size(); j != e; ++j) { - std::map::iterator I = + std::map::iterator I = SubExpressionUseData.find(SubExprs[j]); SubExpressionUseData.erase(I); } @@ -982,10 +982,10 @@ /// be folded into the addressing mode, nor even that the factor be constant; /// a multiply (executed once) outside the loop is better than another IV /// within. Well, usually. -const SCEV* LoopStrengthReduce::CheckForIVReuse(bool HasBaseReg, +const SCEV *LoopStrengthReduce::CheckForIVReuse(bool HasBaseReg, bool AllUsesAreAddresses, bool AllUsesAreOutsideLoop, - const SCEV* const &Stride, + const SCEV *const &Stride, IVExpr &IV, const Type *Ty, const std::vector& UsersToProcess) { if (StrideNoReuse.count(Stride)) @@ -995,7 +995,7 @@ int64_t SInt = SC->getValue()->getSExtValue(); for (unsigned NewStride = 0, e = IU->StrideOrder.size(); NewStride != e; ++NewStride) { - std::map::iterator SI = + std::map::iterator SI = IVsByStride.find(IU->StrideOrder[NewStride]); if (SI == IVsByStride.end() || !isa(SI->first) || StrideNoReuse.count(SI->first)) @@ -1048,7 +1048,7 @@ // an existing IV if we can. for (unsigned NewStride = 0, e = IU->StrideOrder.size(); NewStride != e; ++NewStride) { - std::map::iterator SI = + std::map::iterator SI = IVsByStride.find(IU->StrideOrder[NewStride]); if (SI == IVsByStride.end() || !isa(SI->first)) continue; @@ -1068,7 +1068,7 @@ // -1*old. for (unsigned NewStride = 0, e = IU->StrideOrder.size(); NewStride != e; ++NewStride) { - std::map::iterator SI = + std::map::iterator SI = IVsByStride.find(IU->StrideOrder[NewStride]); if (SI == IVsByStride.end()) continue; @@ -1097,7 +1097,7 @@ /// isNonConstantNegative - Return true if the specified scev is negated, but /// not a constant. -static bool isNonConstantNegative(const SCEV* const &Expr) { +static bool isNonConstantNegative(const SCEV *const &Expr) { const SCEVMulExpr *Mul = dyn_cast(Expr); if (!Mul) return false; @@ -1114,7 +1114,7 @@ /// of the strided accesses, as well as the old information from Uses. We /// progressively move information from the Base field to the Imm field, until /// we eventually have the full access expression to rewrite the use. -const SCEV* LoopStrengthReduce::CollectIVUsers(const SCEV* const &Stride, +const SCEV *LoopStrengthReduce::CollectIVUsers(const SCEV *const &Stride, IVUsersOfOneStride &Uses, Loop *L, bool &AllUsesAreAddresses, @@ -1145,7 +1145,7 @@ // for the strides (e.g. if we have "A+C+B" and "A+B+D" as our bases, find // "A+B"), emit it to the preheader, then remove the expression from the // UsersToProcess base values. - const SCEV* CommonExprs = + const SCEV *CommonExprs = RemoveCommonExpressionsFromUseBases(UsersToProcess, SE, L, TLI); // Next, figure out what we can represent in the immediate fields of @@ -1211,7 +1211,7 @@ const std::vector &UsersToProcess, const Loop *L, bool AllUsesAreAddresses, - const SCEV* Stride) { + const SCEV *Stride) { if (!EnableFullLSRMode) return false; @@ -1248,7 +1248,7 @@ if (!Imm) Imm = SE->getIntegerSCEV(0, Stride->getType()); const Instruction *Inst = UsersToProcess[i].Inst; const Type *AccessTy = getAccessType(Inst); - const SCEV* Diff = SE->getMinusSCEV(UsersToProcess[i].Imm, Imm); + const SCEV *Diff = SE->getMinusSCEV(UsersToProcess[i].Imm, Imm); if (!Diff->isZero() && (!AllUsesAreAddresses || !fitsInAddressMode(Diff, AccessTy, TLI, /*HasBaseReg=*/true))) @@ -1282,7 +1282,7 @@ /// /// Return the created phi node. /// -static PHINode *InsertAffinePhi(const SCEV* Start, const SCEV* Step, +static PHINode *InsertAffinePhi(const SCEV *Start, const SCEV *Step, Instruction *IVIncInsertPt, const Loop *L, SCEVExpander &Rewriter) { @@ -1302,7 +1302,7 @@ // If the stride is negative, insert a sub instead of an add for the // increment. bool isNegative = isNonConstantNegative(Step); - const SCEV* IncAmount = Step; + const SCEV *IncAmount = Step; if (isNegative) IncAmount = Rewriter.SE.getNegativeSCEV(Step); @@ -1341,13 +1341,13 @@ // loop before users outside of the loop with a particular base. // // We would like to use stable_sort here, but we can't. The problem is that - // const SCEV*'s don't have a deterministic ordering w.r.t to each other, so + // const SCEV *'s don't have a deterministic ordering w.r.t to each other, so // we don't have anything to do a '<' comparison on. Because we think the // number of uses is small, do a horrible bubble sort which just relies on // ==. for (unsigned i = 0, e = UsersToProcess.size(); i != e; ++i) { // Get a base value. - const SCEV* Base = UsersToProcess[i].Base; + const SCEV *Base = UsersToProcess[i].Base; // Compact everything with this base to be consecutive with this one. for (unsigned j = i+1; j != e; ++j) { @@ -1366,8 +1366,8 @@ void LoopStrengthReduce::PrepareToStrengthReduceFully( std::vector &UsersToProcess, - const SCEV* Stride, - const SCEV* CommonExprs, + const SCEV *Stride, + const SCEV *CommonExprs, const Loop *L, SCEVExpander &PreheaderRewriter) { DOUT << " Fully reducing all users\n"; @@ -1379,9 +1379,9 @@ // TODO: The uses are grouped by base, but not sorted. We arbitrarily // pick the first Imm value here to start with, and adjust it for the // other uses. - const SCEV* Imm = UsersToProcess[i].Imm; - const SCEV* Base = UsersToProcess[i].Base; - const SCEV* Start = SE->getAddExpr(CommonExprs, Base, Imm); + const SCEV *Imm = UsersToProcess[i].Imm; + const SCEV *Base = UsersToProcess[i].Base; + const SCEV *Start = SE->getAddExpr(CommonExprs, Base, Imm); PHINode *Phi = InsertAffinePhi(Start, Stride, IVIncInsertPt, L, PreheaderRewriter); // Loop over all the users with the same base. @@ -1413,8 +1413,8 @@ void LoopStrengthReduce::PrepareToStrengthReduceWithNewPhi( std::vector &UsersToProcess, - const SCEV* Stride, - const SCEV* CommonExprs, + const SCEV *Stride, + const SCEV *CommonExprs, Value *CommonBaseV, Instruction *IVIncInsertPt, const Loop *L, @@ -1490,7 +1490,7 @@ /// StrengthReduceStridedIVUsers - Strength reduce all of the users of a single /// stride of IV. All of the users may have different starting values, and this /// may not be the only stride. -void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEV* const &Stride, +void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEV *const &Stride, IVUsersOfOneStride &Uses, Loop *L) { // If all the users are moved to another stride, then there is nothing to do. @@ -1513,7 +1513,7 @@ // move information from the Base field to the Imm field, until we eventually // have the full access expression to rewrite the use. std::vector UsersToProcess; - const SCEV* CommonExprs = CollectIVUsers(Stride, Uses, L, AllUsesAreAddresses, + const SCEV *CommonExprs = CollectIVUsers(Stride, Uses, L, AllUsesAreAddresses, AllUsesAreOutsideLoop, UsersToProcess); @@ -1531,8 +1531,8 @@ // If all uses are addresses, consider sinking the immediate part of the // common expression back into uses if they can fit in the immediate fields. if (TLI && HaveCommonExprs && AllUsesAreAddresses) { - const SCEV* NewCommon = CommonExprs; - const SCEV* Imm = SE->getIntegerSCEV(0, ReplacedTy); + const SCEV *NewCommon = CommonExprs; + const SCEV *Imm = SE->getIntegerSCEV(0, ReplacedTy); MoveImmediateValues(TLI, Type::VoidTy, NewCommon, Imm, true, L, SE); if (!Imm->isZero()) { bool DoSink = true; @@ -1578,7 +1578,7 @@ Value *CommonBaseV = Context->getNullValue(ReplacedTy); - const SCEV* RewriteFactor = SE->getIntegerSCEV(0, ReplacedTy); + const SCEV *RewriteFactor = SE->getIntegerSCEV(0, ReplacedTy); IVExpr ReuseIV(SE->getIntegerSCEV(0, Type::Int32Ty), SE->getIntegerSCEV(0, Type::Int32Ty), 0); @@ -1618,7 +1618,7 @@ // strength-reduced forms. This outer loop handles all bases, the inner // loop handles all users of a particular base. while (!UsersToProcess.empty()) { - const SCEV* Base = UsersToProcess.back().Base; + const SCEV *Base = UsersToProcess.back().Base; Instruction *Inst = UsersToProcess.back().Inst; // Emit the code for Base into the preheader. @@ -1673,7 +1673,7 @@ User.Inst->moveBefore(IVIncInsertPt); } - const SCEV* RewriteExpr = SE->getUnknown(RewriteOp); + const SCEV *RewriteExpr = SE->getUnknown(RewriteOp); if (SE->getEffectiveSCEVType(RewriteOp->getType()) != SE->getEffectiveSCEVType(ReplacedTy)) { @@ -1705,7 +1705,7 @@ // The base has been used to initialize the PHI node but we don't want // it here. if (!ReuseIV.Base->isZero()) { - const SCEV* typedBase = ReuseIV.Base; + const SCEV *typedBase = ReuseIV.Base; if (SE->getEffectiveSCEVType(RewriteExpr->getType()) != SE->getEffectiveSCEVType(ReuseIV.Base->getType())) { // It's possible the original IV is a larger type than the new IV, @@ -1770,10 +1770,10 @@ /// set the IV user and stride information and return true, otherwise return /// false. bool LoopStrengthReduce::FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse, - const SCEV* const * &CondStride) { + const SCEV *const * &CondStride) { for (unsigned Stride = 0, e = IU->StrideOrder.size(); Stride != e && !CondUse; ++Stride) { - std::map::iterator SI = + std::map::iterator SI = IU->IVUsesByStride.find(IU->StrideOrder[Stride]); assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); @@ -1800,7 +1800,7 @@ const ScalarEvolution *SE; explicit StrideCompare(const ScalarEvolution *se) : SE(se) {} - bool operator()(const SCEV* const &LHS, const SCEV* const &RHS) { + bool operator()(const SCEV *const &LHS, const SCEV *const &RHS) { const SCEVConstant *LHSC = dyn_cast(LHS); const SCEVConstant *RHSC = dyn_cast(RHS); if (LHSC && RHSC) { @@ -1843,14 +1843,14 @@ /// if (v1 < 30) goto loop ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond, IVStrideUse* &CondUse, - const SCEV* const* &CondStride) { + const SCEV *const* &CondStride) { // If there's only one stride in the loop, there's nothing to do here. if (IU->StrideOrder.size() < 2) return Cond; // If there are other users of the condition's stride, don't bother // trying to change the condition because the stride will still // remain. - std::map::iterator I = + std::map::iterator I = IU->IVUsesByStride.find(*CondStride); if (I == IU->IVUsesByStride.end() || I->second->Users.size() != 1) @@ -1867,11 +1867,11 @@ const Type *NewCmpTy = NULL; unsigned TyBits = SE->getTypeSizeInBits(CmpTy); unsigned NewTyBits = 0; - const SCEV* *NewStride = NULL; + const SCEV **NewStride = NULL; Value *NewCmpLHS = NULL; Value *NewCmpRHS = NULL; int64_t Scale = 1; - const SCEV* NewOffset = SE->getIntegerSCEV(0, CmpTy); + const SCEV *NewOffset = SE->getIntegerSCEV(0, CmpTy); if (ConstantInt *C = dyn_cast(Cond->getOperand(1))) { int64_t CmpVal = C->getValue().getSExtValue(); @@ -1883,7 +1883,7 @@ // Look for a suitable stride / iv as replacement. for (unsigned i = 0, e = IU->StrideOrder.size(); i != e; ++i) { - std::map::iterator SI = + std::map::iterator SI = IU->IVUsesByStride.find(IU->StrideOrder[i]); if (!isa(SI->first)) continue; @@ -1963,7 +1963,7 @@ bool AllUsesAreAddresses = true; bool AllUsesAreOutsideLoop = true; std::vector UsersToProcess; - const SCEV* CommonExprs = CollectIVUsers(SI->first, *SI->second, L, + const SCEV *CommonExprs = CollectIVUsers(SI->first, *SI->second, L, AllUsesAreAddresses, AllUsesAreOutsideLoop, UsersToProcess); @@ -2098,13 +2098,13 @@ SelectInst *Sel = dyn_cast(Cond->getOperand(1)); if (!Sel || !Sel->hasOneUse()) return Cond; - const SCEV* BackedgeTakenCount = SE->getBackedgeTakenCount(L); + const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); if (isa(BackedgeTakenCount)) return Cond; - const SCEV* One = SE->getIntegerSCEV(1, BackedgeTakenCount->getType()); + const SCEV *One = SE->getIntegerSCEV(1, BackedgeTakenCount->getType()); // Add one to the backedge-taken count to get the trip count. - const SCEV* IterationCount = SE->getAddExpr(BackedgeTakenCount, One); + const SCEV *IterationCount = SE->getAddExpr(BackedgeTakenCount, One); // Check for a max calculation that matches the pattern. if (!isa(IterationCount) && !isa(IterationCount)) @@ -2117,13 +2117,13 @@ if (Max->getNumOperands() != 2) return Cond; - const SCEV* MaxLHS = Max->getOperand(0); - const SCEV* MaxRHS = Max->getOperand(1); + const SCEV *MaxLHS = Max->getOperand(0); + const SCEV *MaxRHS = Max->getOperand(1); if (!MaxLHS || MaxLHS != One) return Cond; // Check the relevant induction variable for conformance to // the pattern. - const SCEV* IV = SE->getSCEV(Cond->getOperand(0)); + const SCEV *IV = SE->getSCEV(Cond->getOperand(0)); const SCEVAddRecExpr *AR = dyn_cast(IV); if (!AR || !AR->isAffine() || AR->getStart() != One || @@ -2169,13 +2169,13 @@ /// inside the loop then try to eliminate the cast opeation. void LoopStrengthReduce::OptimizeShadowIV(Loop *L) { - const SCEV* BackedgeTakenCount = SE->getBackedgeTakenCount(L); + const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); if (isa(BackedgeTakenCount)) return; for (unsigned Stride = 0, e = IU->StrideOrder.size(); Stride != e; ++Stride) { - std::map::iterator SI = + std::map::iterator SI = IU->IVUsesByStride.find(IU->StrideOrder[Stride]); assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); if (!isa(SI->first)) @@ -2305,7 +2305,7 @@ // Search IVUsesByStride to find Cond's IVUse if there is one. IVStrideUse *CondUse = 0; - const SCEV* const *CondStride = 0; + const SCEV *const *CondStride = 0; ICmpInst *Cond = cast(TermBr->getCondition()); if (!FindIVUserForCond(Cond, CondUse, CondStride)) return; // setcc doesn't use the IV. @@ -2335,7 +2335,7 @@ int64_t SInt = SC->getValue()->getSExtValue(); for (unsigned NewStride = 0, ee = IU->StrideOrder.size(); NewStride != ee; ++NewStride) { - std::map::iterator SI = + std::map::iterator SI = IU->IVUsesByStride.find(IU->StrideOrder[NewStride]); if (!isa(SI->first) || SI->first == *CondStride) continue; @@ -2349,7 +2349,7 @@ bool AllUsesAreAddresses = true; bool AllUsesAreOutsideLoop = true; std::vector UsersToProcess; - const SCEV* CommonExprs = CollectIVUsers(SI->first, *SI->second, L, + const SCEV *CommonExprs = CollectIVUsers(SI->first, *SI->second, L, AllUsesAreAddresses, AllUsesAreOutsideLoop, UsersToProcess); @@ -2410,7 +2410,7 @@ void LoopStrengthReduce::OptimizeLoopCountIV(Loop *L) { // If the number of times the loop is executed isn't computable, give up. - const SCEV* BackedgeTakenCount = SE->getBackedgeTakenCount(L); + const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); if (isa(BackedgeTakenCount)) return; @@ -2439,9 +2439,9 @@ // Handle only tests for equality for the moment, and only stride 1. if (Cond->getPredicate() != CmpInst::ICMP_EQ) return; - const SCEV* IV = SE->getSCEV(Cond->getOperand(0)); + const SCEV *IV = SE->getSCEV(Cond->getOperand(0)); const SCEVAddRecExpr *AR = dyn_cast(IV); - const SCEV* One = SE->getIntegerSCEV(1, BackedgeTakenCount->getType()); + const SCEV *One = SE->getIntegerSCEV(1, BackedgeTakenCount->getType()); if (!AR || !AR->isAffine() || AR->getStepRecurrence(*SE) != One) return; // If the RHS of the comparison is defined inside the loop, the rewrite @@ -2557,7 +2557,7 @@ // strides deterministic - not dependent on map order. for (unsigned Stride = 0, e = IU->StrideOrder.size(); Stride != e; ++Stride) { - std::map::iterator SI = + std::map::iterator SI = IU->IVUsesByStride.find(IU->StrideOrder[Stride]); assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); // FIXME: Generalize to non-affine IV's. From resistor at mac.com Tue Jul 7 12:12:57 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Jul 2009 17:12:57 -0000 Subject: [llvm-commits] [llvm] r74920 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp Message-ID: <200907071712.n67HCxXb021589@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 12:12:53 2009 New Revision: 74920 URL: http://llvm.org/viewvc/llvm-project?rev=74920&view=rev Log: Re-LLVMContext-ize DebugInfo, now with less breakage. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=74920&r1=74919&r2=74920&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Jul 7 12:12:53 2009 @@ -39,6 +39,7 @@ class DebugLoc; class DebugLocTracker; class Instruction; + class LLVMContext; class DIDescriptor { protected: @@ -407,6 +408,8 @@ /// descriptors. class DIFactory { Module &M; + LLVMContext& VMContext; + // Cached values for uniquing and faster lookups. const Type *EmptyStructPtr; // "{}*". Function *StopPointFn; // llvm.dbg.stoppoint Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=74920&r1=74919&r2=74920&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Jul 7 12:12:53 2009 @@ -18,6 +18,7 @@ #include "llvm/Intrinsics.h" #include "llvm/IntrinsicInst.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Support/Dwarf.h" @@ -453,22 +454,23 @@ //===----------------------------------------------------------------------===// DIFactory::DIFactory(Module &m) - : M(m), StopPointFn(0), FuncStartFn(0), RegionStartFn(0), RegionEndFn(0), + : M(m), VMContext(M.getContext()), StopPointFn(0), FuncStartFn(0), + RegionStartFn(0), RegionEndFn(0), DeclareFn(0) { - EmptyStructPtr = PointerType::getUnqual(StructType::get()); + EmptyStructPtr = VMContext.getPointerTypeUnqual(VMContext.getStructType()); } /// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'. /// This is only valid when the descriptor is non-null. Constant *DIFactory::getCastToEmpty(DIDescriptor D) { if (D.isNull()) return Constant::getNullValue(EmptyStructPtr); - return ConstantExpr::getBitCast(D.getGV(), EmptyStructPtr); + return VMContext.getConstantExprBitCast(D.getGV(), EmptyStructPtr); } Constant *DIFactory::GetTagConstant(unsigned TAG) { assert((TAG & LLVMDebugVersionMask) == 0 && "Tag too large for debug encoding!"); - return ConstantInt::get(Type::Int32Ty, TAG | LLVMDebugVersion); + return VMContext.getConstantInt(Type::Int32Ty, TAG | LLVMDebugVersion); } Constant *DIFactory::GetStringConstant(const std::string &String) { @@ -478,21 +480,21 @@ // Return Constant if previously defined. if (Slot) return Slot; - const PointerType *DestTy = PointerType::getUnqual(Type::Int8Ty); + const PointerType *DestTy = VMContext.getPointerTypeUnqual(Type::Int8Ty); // If empty string then use a i8* null instead. if (String.empty()) - return Slot = ConstantPointerNull::get(DestTy); + return Slot = VMContext.getConstantPointerNull(DestTy); // Construct string as an llvm constant. - Constant *ConstStr = ConstantArray::get(String); + Constant *ConstStr = VMContext.getConstantArray(String); // Otherwise create and return a new string global. GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true, GlobalVariable::InternalLinkage, ConstStr, ".str", &M); StrGV->setSection("llvm.metadata"); - return Slot = ConstantExpr::getBitCast(StrGV, DestTy); + return Slot = VMContext.getConstantExprBitCast(StrGV, DestTy); } //===----------------------------------------------------------------------===// @@ -507,7 +509,7 @@ for (unsigned i = 0; i != NumTys; ++i) Elts.push_back(getCastToEmpty(Tys[i])); - Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr, + Constant *Init = VMContext.getConstantArray(VMContext.getArrayType(EmptyStructPtr, Elts.size()), Elts.data(), Elts.size()); // If we already have this array, just return the uniqued version. @@ -527,11 +529,12 @@ DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) { Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_subrange_type), - ConstantInt::get(Type::Int64Ty, Lo), - ConstantInt::get(Type::Int64Ty, Hi) + VMContext.getConstantInt(Type::Int64Ty, Lo), + VMContext.getConstantInt(Type::Int64Ty, Hi) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); // If we already have this range, just return the uniqued version. DIDescriptor &Entry = SimpleConstantCache[Init]; @@ -561,18 +564,19 @@ unsigned RunTimeVer) { Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_compile_unit), - Constant::getNullValue(EmptyStructPtr), - ConstantInt::get(Type::Int32Ty, LangID), + VMContext.getNullValue(EmptyStructPtr), + VMContext.getConstantInt(Type::Int32Ty, LangID), GetStringConstant(Filename), GetStringConstant(Directory), GetStringConstant(Producer), - ConstantInt::get(Type::Int1Ty, isMain), - ConstantInt::get(Type::Int1Ty, isOptimized), + VMContext.getConstantInt(Type::Int1Ty, isMain), + VMContext.getConstantInt(Type::Int1Ty, isOptimized), GetStringConstant(Flags), - ConstantInt::get(Type::Int32Ty, RunTimeVer) + VMContext.getConstantInt(Type::Int32Ty, RunTimeVer) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.compile_unit.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -587,10 +591,11 @@ Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_enumerator), GetStringConstant(Name), - ConstantInt::get(Type::Int64Ty, Val) + VMContext.getConstantInt(Type::Int64Ty, Val) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.enumerator.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -615,15 +620,16 @@ getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNumber), - ConstantInt::get(Type::Int64Ty, SizeInBits), - ConstantInt::get(Type::Int64Ty, AlignInBits), - ConstantInt::get(Type::Int64Ty, OffsetInBits), - ConstantInt::get(Type::Int32Ty, Flags), - ConstantInt::get(Type::Int32Ty, Encoding) + VMContext.getConstantInt(Type::Int32Ty, LineNumber), + VMContext.getConstantInt(Type::Int64Ty, SizeInBits), + VMContext.getConstantInt(Type::Int64Ty, AlignInBits), + VMContext.getConstantInt(Type::Int64Ty, OffsetInBits), + VMContext.getConstantInt(Type::Int32Ty, Flags), + VMContext.getConstantInt(Type::Int32Ty, Encoding) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.basictype.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -650,15 +656,16 @@ getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNumber), - ConstantInt::get(Type::Int64Ty, SizeInBits), - ConstantInt::get(Type::Int64Ty, AlignInBits), - ConstantInt::get(Type::Int64Ty, OffsetInBits), - ConstantInt::get(Type::Int32Ty, Flags), + VMContext.getConstantInt(Type::Int32Ty, LineNumber), + VMContext.getConstantInt(Type::Int64Ty, SizeInBits), + VMContext.getConstantInt(Type::Int64Ty, AlignInBits), + VMContext.getConstantInt(Type::Int64Ty, OffsetInBits), + VMContext.getConstantInt(Type::Int32Ty, Flags), getCastToEmpty(DerivedFrom) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.derivedtype.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -687,17 +694,18 @@ getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNumber), - ConstantInt::get(Type::Int64Ty, SizeInBits), - ConstantInt::get(Type::Int64Ty, AlignInBits), - ConstantInt::get(Type::Int64Ty, OffsetInBits), - ConstantInt::get(Type::Int32Ty, Flags), + VMContext.getConstantInt(Type::Int32Ty, LineNumber), + VMContext.getConstantInt(Type::Int64Ty, SizeInBits), + VMContext.getConstantInt(Type::Int64Ty, AlignInBits), + VMContext.getConstantInt(Type::Int64Ty, OffsetInBits), + VMContext.getConstantInt(Type::Int32Ty, Flags), getCastToEmpty(DerivedFrom), getCastToEmpty(Elements), - ConstantInt::get(Type::Int32Ty, RuntimeLang) + VMContext.getConstantInt(Type::Int32Ty, RuntimeLang) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.composite.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -722,19 +730,20 @@ Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_subprogram), - Constant::getNullValue(EmptyStructPtr), + VMContext.getNullValue(EmptyStructPtr), getCastToEmpty(Context), GetStringConstant(Name), GetStringConstant(DisplayName), GetStringConstant(LinkageName), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNo), + VMContext.getConstantInt(Type::Int32Ty, LineNo), getCastToEmpty(Type), - ConstantInt::get(Type::Int1Ty, isLocalToUnit), - ConstantInt::get(Type::Int1Ty, isDefinition) + VMContext.getConstantInt(Type::Int1Ty, isLocalToUnit), + VMContext.getConstantInt(Type::Int1Ty, isDefinition) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.subprogram.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -754,20 +763,21 @@ bool isDefinition, llvm::GlobalVariable *Val) { Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_variable), - Constant::getNullValue(EmptyStructPtr), + VMContext.getNullValue(EmptyStructPtr), getCastToEmpty(Context), GetStringConstant(Name), GetStringConstant(DisplayName), GetStringConstant(LinkageName), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNo), + VMContext.getConstantInt(Type::Int32Ty, LineNo), getCastToEmpty(Type), - ConstantInt::get(Type::Int1Ty, isLocalToUnit), - ConstantInt::get(Type::Int1Ty, isDefinition), - ConstantExpr::getBitCast(Val, EmptyStructPtr) + VMContext.getConstantInt(Type::Int1Ty, isLocalToUnit), + VMContext.getConstantInt(Type::Int1Ty, isDefinition), + VMContext.getConstantExprBitCast(Val, EmptyStructPtr) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.global_variable.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -788,11 +798,12 @@ getCastToEmpty(Context), GetStringConstant(Name), getCastToEmpty(CompileUnit), - ConstantInt::get(Type::Int32Ty, LineNo), + VMContext.getConstantInt(Type::Int32Ty, LineNo), getCastToEmpty(Type) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.variable.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -804,14 +815,15 @@ /// CreateBlock - This creates a descriptor for a lexical block with the -/// specified parent context. +/// specified parent VMContext. DIBlock DIFactory::CreateBlock(DIDescriptor Context) { Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_lexical_block), getCastToEmpty(Context) }; - Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); + Constant *Init = VMContext.getConstantStruct(Elts, + sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.block.type", Init->getType()); GlobalVariable *GV = new GlobalVariable(Init->getType(), true, @@ -838,8 +850,8 @@ // Invoke llvm.dbg.stoppoint Value *Args[] = { - llvm::ConstantInt::get(llvm::Type::Int32Ty, LineNo), - llvm::ConstantInt::get(llvm::Type::Int32Ty, ColNo), + VMContext.getConstantInt(llvm::Type::Int32Ty, LineNo), + VMContext.getConstantInt(llvm::Type::Int32Ty, ColNo), getCastToEmpty(CU) }; CallInst::Create(StopPointFn, Args, Args+3, "", BB); @@ -939,10 +951,12 @@ Value *findDbgGlobalDeclare(GlobalVariable *V) { const Module *M = V->getParent(); + LLVMContext& Context = M->getContext(); + const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type"); if (!Ty) return 0; - Ty = PointerType::get(Ty, 0); + Ty = Context.getPointerType(Ty, 0); Value *Val = V->stripPointerCasts(); for (Value::use_iterator I = Val->use_begin(), E = Val->use_end(); From clattner at apple.com Tue Jul 7 12:16:08 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 10:16:08 -0700 Subject: [llvm-commits] [PATCH] Improve error handling, supersede cerr+abort In-Reply-To: <4A4D065C.5080809@gmail.com> References: <4A47D8D4.6060001@gmail.com> <60D5E8C7-05E7-4D68-9D61-E07D83090882@apple.com> <4A4B23CA.2070603@gmail.com> <6a8523d60907010802o84d6bd9k2d19ad928cf1bb1d@mail.gmail.com> <4A4D065C.5080809@gmail.com> Message-ID: On Jul 2, 2009, at 12:11 PM, T?r?k Edwin wrote: > On 2009-07-01 18:02, Daniel Dunbar wrote: >> 2009/7/1 T?r?k Edwin : >> >>>> We don't need this. Assertions "can't happen", so assert(0) >>>> really is >>>> unreachable. >>>> >>>> >>> What if assertions are turned off? Should we just remove the calls >>> to >>> abort() after each assert(0)? >>> I thought the abort()s were there after the assert(0) so that the >>> compiler knows that the codepaths >>> never return even with assertions turned off. >>> >> >> The compiler will still know this if we replace such places with a >> report_error call, and report_error is marked noreturn. >> > > Yes, llvm_report_error is already marked as noreturn. > > Can I commit the patch? Yes, this looks great, please commit. Sorry for the delay, -Chris From clattner at apple.com Tue Jul 7 12:16:44 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 10:16:44 -0700 Subject: [llvm-commits] [llvm] r74742 - /llvm/trunk/utils/TableGen/ In-Reply-To: <200907030010.n630AV3N029704@zion.cs.uiuc.edu> References: <200907030010.n630AV3N029704@zion.cs.uiuc.edu> Message-ID: <6F951BA9-8441-46A5-AB49-0954B9192775@apple.com> On Jul 2, 2009, at 5:10 PM, Daniel Dunbar wrote: > Author: ddunbar > Date: Thu Jul 2 19:10:29 2009 > New Revision: 74742 > > URL: http://llvm.org/viewvc/llvm-project?rev=74742&view=rev > Log: > Replace std::iostreams with raw_ostream in TableGen. > - Sorry, I can't help myself. Yay :) -Chris From edwintorok at gmail.com Tue Jul 7 12:32:53 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Tue, 07 Jul 2009 17:32:53 -0000 Subject: [llvm-commits] [llvm] r74922 - in /llvm/trunk: include/llvm/Support/Compiler.h include/llvm/Support/ErrorHandling.h lib/ExecutionEngine/ExecutionEngine.cpp lib/ExecutionEngine/JIT/JIT.cpp lib/Support/ErrorHandling.cpp Message-ID: <200907071733.n67HX5E5022485@zion.cs.uiuc.edu> Author: edwin Date: Tue Jul 7 12:32:34 2009 New Revision: 74922 URL: http://llvm.org/viewvc/llvm-project?rev=74922&view=rev Log: Introduce new error handling API. This will replace exit()/abort() style error handling with an API that allows clients to register custom error handling hooks. The default is to call exit(1) when no error handler is provided. Added: llvm/trunk/include/llvm/Support/ErrorHandling.h llvm/trunk/lib/Support/ErrorHandling.cpp Modified: llvm/trunk/include/llvm/Support/Compiler.h llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Modified: llvm/trunk/include/llvm/Support/Compiler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=74922&r1=74921&r2=74922&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Compiler.h (original) +++ llvm/trunk/include/llvm/Support/Compiler.h Tue Jul 7 12:32:34 2009 @@ -56,4 +56,10 @@ #define DISABLE_INLINE #endif +#ifdef __GNUC__ +#define NORETURN __attribute__((noreturn)) +#else +#define NORETURN +#endif + #endif Added: llvm/trunk/include/llvm/Support/ErrorHandling.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=74922&view=auto ============================================================================== --- llvm/trunk/include/llvm/Support/ErrorHandling.h (added) +++ llvm/trunk/include/llvm/Support/ErrorHandling.h Tue Jul 7 12:32:34 2009 @@ -0,0 +1,52 @@ +//===- llvm/Support/ErrorHandling.h - Callbacks for errors ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines an API used to indicate error conditions. +// Callbacks can be registered for these errors through this API. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_ERRORHANDLING_H +#define LLVM_SUPPORT_ERRORHANDLING_H + +#include "llvm/Support/Compiler.h" + +namespace llvm { + // An error handler callback. + typedef void (*llvm_error_handler_t)(const std::string& reason); + + // Installs a new error handler: this function will be called whenever a + // serious error is encountered by LLVM. + // If you are using llvm_start_multithreaded, you should register the handler + // before doing that. + // + // If no error handler is installed the default is to print the error message + // to stderr, and call exit(1). + // If an error handler is installed then it is the handler's responsibility to + // log the message, it will no longer be printed to stderr. + // If the error handler returns, then exit(1) will be called. + void llvm_install_error_handler(llvm_error_handler_t handler); + + // Restores default error handling behaviour. + // This must not be called between llvm_start_multithreaded() and + // llvm_stop_multithreaded(). + void llvm_remove_error_handler(void); + + // Reports a serious error, calling any installed error handler. + // If no error handler is installed the default is to print the message to + void llvm_report_error(const std::string &reason) NORETURN; + + // This function calls abort(). + // Call this after assert(0), so that compiler knows the path is not + // reachable. + void llvm_unreachable(void) NORETURN; +} + +#endif + Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=74922&r1=74921&r2=74922&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Tue Jul 7 12:32:34 2009 @@ -22,6 +22,7 @@ #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MutexGuard.h" #include "llvm/System/DynamicLibrary.h" #include "llvm/System/Host.h" @@ -640,7 +641,7 @@ case Type::FP128TyID: { APFloat apfLHS = APFloat(LHS.IntVal); switch (CE->getOpcode()) { - default: assert(0 && "Invalid long double opcode"); abort(); + default: assert(0 && "Invalid long double opcode");llvm_unreachable(); case Instruction::FAdd: apfLHS.add(APFloat(RHS.IntVal), APFloat::rmNearestTiesToEven); GV.IntVal = apfLHS.bitcastToAPInt(); @@ -953,9 +954,8 @@ sys::DynamicLibrary::SearchForAddressOfSymbol(I->getName().c_str())) addGlobalMapping(I, SymAddr); else { - cerr << "Could not resolve external global address: " - << I->getName() << "\n"; - abort(); + llvm_report_error("Could not resolve external global address: " + +I->getName()); } } } Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=74922&r1=74921&r2=74922&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Tue Jul 7 12:32:34 2009 @@ -27,6 +27,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetJITInfo.h" #include "llvm/Support/Dwarf.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MutexGuard.h" #include "llvm/System/DynamicLibrary.h" #include "llvm/Config/config.h" @@ -671,9 +672,8 @@ #endif Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(GV->getName().c_str()); if (Ptr == 0 && !areDlsymStubsEnabled()) { - cerr << "Could not resolve external global address: " - << GV->getName() << "\n"; - abort(); + llvm_report_error("Could not resolve external global address: " + +GV->getName()); } addGlobalMapping(GV, Ptr); } else { Added: llvm/trunk/lib/Support/ErrorHandling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ErrorHandling.cpp?rev=74922&view=auto ============================================================================== --- llvm/trunk/lib/Support/ErrorHandling.cpp (added) +++ llvm/trunk/lib/Support/ErrorHandling.cpp Tue Jul 7 12:32:34 2009 @@ -0,0 +1,53 @@ +//===- lib/Support/ErrorHandling.cpp - Callbacks for errors -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines an API for error handling, it supersedes cerr+abort(), and +// cerr+exit() style error handling. +// Callbacks can be registered for these errors through this API. +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/System/Threading.h" +#include +#include + +using namespace llvm; +using namespace std; + +static llvm_error_handler_t ErrorHandler = 0; +namespace llvm { +void llvm_install_error_handler(llvm_error_handler_t handler) { + assert(!llvm_is_multithreaded() && + "Cannot register error handlers after starting multithreaded mode!\n"); + assert(!ErrorHandler && "Error handler already registered!\n"); + ErrorHandler = handler; +} + +void llvm_remove_error_handler(void) { + ErrorHandler = 0; +} + +void llvm_report_error(const std::string &reason) +{ + if (!ErrorHandler) { + errs() << "LLVM ERROR: " << reason << "\n"; + } else { + ErrorHandler(reason); + } + exit(1); +} + +void llvm_unreachable(void) +{ + abort(); +} +} + From edwintorok at gmail.com Tue Jul 7 12:40:25 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Tue, 07 Jul 2009 17:40:25 -0000 Subject: [llvm-commits] [llvm] r74923 - /llvm/trunk/lib/Support/ErrorHandling.cpp Message-ID: <200907071740.n67HeRYA022715@zion.cs.uiuc.edu> Author: edwin Date: Tue Jul 7 12:39:53 2009 New Revision: 74923 URL: http://llvm.org/viewvc/llvm-project?rev=74923&view=rev Log: Fix braces. Modified: llvm/trunk/lib/Support/ErrorHandling.cpp Modified: llvm/trunk/lib/Support/ErrorHandling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ErrorHandling.cpp?rev=74923&r1=74922&r2=74923&view=diff ============================================================================== --- llvm/trunk/lib/Support/ErrorHandling.cpp (original) +++ llvm/trunk/lib/Support/ErrorHandling.cpp Tue Jul 7 12:39:53 2009 @@ -35,8 +35,7 @@ ErrorHandler = 0; } -void llvm_report_error(const std::string &reason) -{ +void llvm_report_error(const std::string &reason) { if (!ErrorHandler) { errs() << "LLVM ERROR: " << reason << "\n"; } else { @@ -45,8 +44,7 @@ exit(1); } -void llvm_unreachable(void) -{ +void llvm_unreachable(void) { abort(); } } From sabre at nondot.org Tue Jul 7 12:50:21 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 17:50:21 -0000 Subject: [llvm-commits] [llvm] r74924 - /llvm/trunk/lib/System/DynamicLibrary.cpp Message-ID: <200907071750.n67HoOFW023241@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 12:50:11 2009 New Revision: 74924 URL: http://llvm.org/viewvc/llvm-project?rev=74924&view=rev Log: we don't use libtool anymore, update comments. Modified: llvm/trunk/lib/System/DynamicLibrary.cpp Modified: llvm/trunk/lib/System/DynamicLibrary.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/DynamicLibrary.cpp?rev=74924&r1=74923&r2=74924&view=diff ============================================================================== --- llvm/trunk/lib/System/DynamicLibrary.cpp (original) +++ llvm/trunk/lib/System/DynamicLibrary.cpp Tue Jul 7 12:50:11 2009 @@ -23,26 +23,18 @@ static std::map symbols; static llvm::sys::SmartRWMutex SymbolsLock; - void llvm::sys::DynamicLibrary::AddSymbol(const char* symbolName, void *symbolValue) { llvm::sys::SmartScopedWriter Writer(&SymbolsLock); symbols[symbolName] = symbolValue; } -// It is not possible to use ltdl.c on VC++ builds as the terms of its LGPL -// license and special exception would cause all of LLVM to be placed under -// the LGPL. This is because the exception applies only when libtool is -// used, and obviously libtool is not used with Visual Studio. An entirely -// separate implementation is provided in win32/DynamicLibrary.cpp. - #ifdef LLVM_ON_WIN32 #include "Win32/DynamicLibrary.inc" #else -//#include "ltdl.h" #include #include using namespace llvm; @@ -53,7 +45,6 @@ //=== independent code. //===----------------------------------------------------------------------===// -//static std::vector OpenedHandles; static std::vector OpenedHandles; DynamicLibrary::DynamicLibrary() {} @@ -61,7 +52,8 @@ DynamicLibrary::~DynamicLibrary() { SmartScopedWriter Writer(&SymbolsLock); while(!OpenedHandles.empty()) { - void *H = OpenedHandles.back(); OpenedHandles.pop_back(); + void *H = OpenedHandles.back(); + OpenedHandles.pop_back(); dlclose(H); } } @@ -80,8 +72,6 @@ } void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { - // check_ltdl_initialization(); - // First check symbols added via AddSymbol(). SymbolsLock.reader_acquire(); std::map::iterator I = symbols.find(symbolName); From evan.cheng at apple.com Tue Jul 7 12:50:29 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 7 Jul 2009 10:50:29 -0700 Subject: [llvm-commits] [llvm] r74898 - /llvm/trunk/lib/CodeGen/PHIElimination.cpp In-Reply-To: <200907070804.n6784sHX030896@zion.cs.uiuc.edu> References: <200907070804.n6784sHX030896@zion.cs.uiuc.edu> Message-ID: This patch broke a whole bunch of tests. For example on Grawp-PIC: New Test Failures: test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll [DEJAGNU] test/CodeGen/X86/2006-05-02-InstrSched2.ll [DEJAGNU] test/CodeGen/X86/2008-05-21-CoalescerBug.ll for PR2343 [DEJAGNU] test/CodeGen/X86/stack-color-with-reg-2.ll [DEJAGNU] test/CodeGen/X86/twoaddr-pass-sink.ll [DEJAGNU] Applications/oggenc/oggenc [LLC compile, ] Benchmarks/ASCI_Purple/SMG2000/smg2000 [LLC compile, ] Benchmarks/mafft/pairlocalalign [LLC compile, ] Benchmarks/MallocBench/gs/gs [LLC compile, ] Benchmarks/mediabench/mpeg2/mpeg2dec/mpeg2decode [LLC compile, ] Benchmarks/MiBench/consumer-jpeg/consumer-jpeg [LLC compile, ] Benchmarks/MiBench/consumer-lame/consumer-lame [LLC compile, ] Benchmarks/Misc/whetstone [LLC compile, ] Benchmarks/Ptrdist/yacr2/yacr2 [LLC compile, ] Nurbs/nurbs [LLC compile, ] SPEC/CFP2006/433.milc/433.milc [LLC compile, ] SPEC/CINT2000/176.gcc/176.gcc [LLC compile, ] SPEC/CINT2000/254.gap/254.gap [LLC compile, ] SPEC/CINT2006/403.gcc/403.gcc [LLC compile, ] I'll back it out for now. Sanjiv, please investigate. Thanks. Evan On Jul 7, 2009, at 1:04 AM, Sanjiv Gupta wrote: > Author: sgupta > Date: Tue Jul 7 03:04:51 2009 > New Revision: 74898 > > URL: http://llvm.org/viewvc/llvm-project?rev=74898&view=rev > Log: > if the terminator is a branch depending upon the side effects of a > previous cmp; a copy can not be inserted here if the copy insn also > has > side effects. We don't have access to the attributes of copy insn > here; > so just play safe by finding a safe locations for branch terminators. > > Modified: > llvm/trunk/lib/CodeGen/PHIElimination.cpp > > Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=74898&r1=74897&r2=74898&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) > +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Tue Jul 7 03:04:51 2009 > @@ -169,9 +169,15 @@ > return MBB.begin(); > > // If this basic block does not contain an invoke, then control > flow always > - // reaches the end of it, so place the copy there. The logic > below works in > - // this case too, but is more expensive. > - if (!isa(MBB.getBasicBlock()->getTerminator())) > + // reaches the end of it, so place the copy there. > + // If the terminator is a branch depending upon the side effects > of a > + // previous cmp; a copy can not be inserted here if the copy insn > also > + // side effects. We don't have access to the attributes of copy > insn here; > + // so just play safe by finding a safe locations for branch > terminators. > + // > + // The logic below works in this case too, but is more expensive. > + const TerminatorInst *TermInst = MBB.getBasicBlock()- > >getTerminator(); > + if (!(isa(TermInst) || isa(TermInst))) > return MBB.getFirstTerminator(); > > // Discover any definition/uses in this basic block. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090707/6da76e8b/attachment.html From evan.cheng at apple.com Tue Jul 7 12:50:47 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Jul 2009 17:50:47 -0000 Subject: [llvm-commits] [llvm] r74925 - /llvm/trunk/lib/CodeGen/PHIElimination.cpp Message-ID: <200907071750.n67Holjj023262@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jul 7 12:50:43 2009 New Revision: 74925 URL: http://llvm.org/viewvc/llvm-project?rev=74925&view=rev Log: Revert 74898. It broke several tests. Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=74925&r1=74924&r2=74925&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Tue Jul 7 12:50:43 2009 @@ -169,15 +169,9 @@ return MBB.begin(); // If this basic block does not contain an invoke, then control flow always - // reaches the end of it, so place the copy there. - // If the terminator is a branch depending upon the side effects of a - // previous cmp; a copy can not be inserted here if the copy insn also - // side effects. We don't have access to the attributes of copy insn here; - // so just play safe by finding a safe locations for branch terminators. - // - // The logic below works in this case too, but is more expensive. - const TerminatorInst *TermInst = MBB.getBasicBlock()->getTerminator(); - if (!(isa(TermInst) || isa(TermInst))) + // reaches the end of it, so place the copy there. The logic below works in + // this case too, but is more expensive. + if (!isa(MBB.getBasicBlock()->getTerminator())) return MBB.getFirstTerminator(); // Discover any definition/uses in this basic block. From sabre at nondot.org Tue Jul 7 13:02:29 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 18:02:29 -0000 Subject: [llvm-commits] [llvm] r74926 - in /llvm/trunk: include/llvm/System/DynamicLibrary.h lib/System/DynamicLibrary.cpp Message-ID: <200907071802.n67I2Z6b023676@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 13:01:58 2009 New Revision: 74926 URL: http://llvm.org/viewvc/llvm-project?rev=74926&view=rev Log: remove dead code, noone creates instances of "DynamicLibrary", so the ctor and dtor are dead. Modified: llvm/trunk/include/llvm/System/DynamicLibrary.h llvm/trunk/lib/System/DynamicLibrary.cpp Modified: llvm/trunk/include/llvm/System/DynamicLibrary.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/DynamicLibrary.h?rev=74926&r1=74925&r2=74926&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/DynamicLibrary.h (original) +++ llvm/trunk/include/llvm/System/DynamicLibrary.h Tue Jul 7 13:01:58 2009 @@ -14,7 +14,6 @@ #ifndef LLVM_SYSTEM_DYNAMIC_LIBRARY_H #define LLVM_SYSTEM_DYNAMIC_LIBRARY_H -#include "llvm/System/Path.h" #include namespace llvm { @@ -30,66 +29,40 @@ /// but rather the main program itself, useful on Windows where the main /// executable cannot be searched. class DynamicLibrary { - /// @name Constructors - /// @{ - public: - /// Construct a DynamicLibrary that represents the currently executing - /// program. The program must have been linked with -export-dynamic or - /// -dlopen self for this to work. - /// @throws std::string indicating why the program couldn't be opened. - /// @brief Open program as dynamic library. - DynamicLibrary(); - - /// After destruction, the symbols of the library will no longer be - /// available to the program. - /// @brief Closes the DynamicLibrary - ~DynamicLibrary(); - - /// @} - /// @name Functions - /// @{ - public: - /// This function allows a library to be loaded without instantiating a - /// DynamicLibrary object. Consequently, it is marked as being permanent - /// and will only be unloaded when the program terminates. This returns - /// false on success or returns true and fills in *ErrMsg on failure. - /// @brief Open a dynamic library permanently. - static bool LoadLibraryPermanently(const char* filename, - std::string *ErrMsg = 0); - - /// This function will search through all previously loaded dynamic - /// libraries for the symbol \p symbolName. If it is found, the addressof - /// that symbol is returned. If not, null is returned. Note that this will - /// search permanently loaded libraries (LoadLibraryPermanently) as well - /// as ephemerally loaded libraries (constructors). - /// @throws std::string on error. - /// @brief Search through libraries for address of a symbol - static void* SearchForAddressOfSymbol(const char* symbolName); - - /// @brief Convenience function for C++ophiles. - static void* SearchForAddressOfSymbol(const std::string& symbolName) { - return SearchForAddressOfSymbol(symbolName.c_str()); - } - - /// This functions permanently adds the symbol \p symbolName with the - /// value \p symbolValue. These symbols are searched before any - /// libraries. - /// @brief Add searchable symbol/value pair. - static void AddSymbol(const char* symbolName, void *symbolValue); - - /// @brief Convenience function for C++ophiles. - static void AddSymbol(const std::string& symbolName, void *symbolValue) { - AddSymbol(symbolName.c_str(), symbolValue); - } - - /// @} - /// @name Implementation - /// @{ - protected: - void* handle; // Opaque handle for information about the library - DynamicLibrary(const DynamicLibrary&); ///< Do not implement - DynamicLibrary& operator=(const DynamicLibrary&); ///< Do not implement - /// @} + DynamicLibrary(); // DO NOT IMPLEMENT + public: + /// This function allows a library to be loaded without instantiating a + /// DynamicLibrary object. Consequently, it is marked as being permanent + /// and will only be unloaded when the program terminates. This returns + /// false on success or returns true and fills in *ErrMsg on failure. + /// @brief Open a dynamic library permanently. + static bool LoadLibraryPermanently(const char *filename, + std::string *ErrMsg = 0); + + /// This function will search through all previously loaded dynamic + /// libraries for the symbol \p symbolName. If it is found, the addressof + /// that symbol is returned. If not, null is returned. Note that this will + /// search permanently loaded libraries (LoadLibraryPermanently) as well + /// as ephemerally loaded libraries (constructors). + /// @throws std::string on error. + /// @brief Search through libraries for address of a symbol + static void *SearchForAddressOfSymbol(const char *symbolName); + + /// @brief Convenience function for C++ophiles. + static void *SearchForAddressOfSymbol(const std::string &symbolName) { + return SearchForAddressOfSymbol(symbolName.c_str()); + } + + /// This functions permanently adds the symbol \p symbolName with the + /// value \p symbolValue. These symbols are searched before any + /// libraries. + /// @brief Add searchable symbol/value pair. + static void AddSymbol(const char *symbolName, void *symbolValue); + + /// @brief Convenience function for C++ophiles. + static void AddSymbol(const std::string &symbolName, void *symbolValue) { + AddSymbol(symbolName.c_str(), symbolValue); + } }; } // End sys namespace Modified: llvm/trunk/lib/System/DynamicLibrary.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/DynamicLibrary.cpp?rev=74926&r1=74925&r2=74926&view=diff ============================================================================== --- llvm/trunk/lib/System/DynamicLibrary.cpp (original) +++ llvm/trunk/lib/System/DynamicLibrary.cpp Tue Jul 7 13:01:58 2009 @@ -18,6 +18,7 @@ #include #include #include +#include // Collection of symbol name/value pairs to be searched prior to any libraries. static std::map symbols; @@ -47,16 +48,6 @@ static std::vector OpenedHandles; -DynamicLibrary::DynamicLibrary() {} - -DynamicLibrary::~DynamicLibrary() { - SmartScopedWriter Writer(&SymbolsLock); - while(!OpenedHandles.empty()) { - void *H = OpenedHandles.back(); - OpenedHandles.pop_back(); - dlclose(H); - } -} bool DynamicLibrary::LoadLibraryPermanently(const char *Filename, std::string *ErrMsg) { From sabre at nondot.org Tue Jul 7 13:17:33 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 18:17:33 -0000 Subject: [llvm-commits] [llvm] r74927 - in /llvm/trunk: include/llvm/System/DynamicLibrary.h lib/System/DynamicLibrary.cpp Message-ID: <200907071817.n67IHbJ8024168@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 13:17:07 2009 New Revision: 74927 URL: http://llvm.org/viewvc/llvm-project?rev=74927&view=rev Log: Eliminate the static constructors and locks from DynamicLibrary.cpp. This fixes PR4512 and eliminating static ctors is always good. Losing thread safety is unfortunate, but the code is just incredibly poorly designed. If someone is interested, the "right" solution is to split DynamicLibrary.cpp into two separate pieces: a stateless piece in libsystem, and a simple support file in libsupport that has the "state" (e.g. AddSymbol) in managed static objects. Doing this would both fix memory leaks we already have, as well as make the code thread safe again. it would also make sense to move all the unix specific code in System/DynamicLibrary.cpp into System/Unix/DynamicLibrary.inc. Modified: llvm/trunk/include/llvm/System/DynamicLibrary.h llvm/trunk/lib/System/DynamicLibrary.cpp Modified: llvm/trunk/include/llvm/System/DynamicLibrary.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/DynamicLibrary.h?rev=74927&r1=74926&r2=74927&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/DynamicLibrary.h (original) +++ llvm/trunk/include/llvm/System/DynamicLibrary.h Tue Jul 7 13:17:07 2009 @@ -36,6 +36,9 @@ /// and will only be unloaded when the program terminates. This returns /// false on success or returns true and fills in *ErrMsg on failure. /// @brief Open a dynamic library permanently. + /// + /// NOTE: This function is not thread safe. + /// static bool LoadLibraryPermanently(const char *filename, std::string *ErrMsg = 0); @@ -46,9 +49,15 @@ /// as ephemerally loaded libraries (constructors). /// @throws std::string on error. /// @brief Search through libraries for address of a symbol + /// + /// NOTE: This function is not thread safe. + /// static void *SearchForAddressOfSymbol(const char *symbolName); /// @brief Convenience function for C++ophiles. + /// + /// NOTE: This function is not thread safe. + /// static void *SearchForAddressOfSymbol(const std::string &symbolName) { return SearchForAddressOfSymbol(symbolName.c_str()); } @@ -57,9 +66,15 @@ /// value \p symbolValue. These symbols are searched before any /// libraries. /// @brief Add searchable symbol/value pair. + /// + /// NOTE: This function is not thread safe. + /// static void AddSymbol(const char *symbolName, void *symbolValue); /// @brief Convenience function for C++ophiles. + /// + /// NOTE: This function is not thread safe. + /// static void AddSymbol(const std::string &symbolName, void *symbolValue) { AddSymbol(symbolName.c_str(), symbolValue); } Modified: llvm/trunk/lib/System/DynamicLibrary.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/DynamicLibrary.cpp?rev=74927&r1=74926&r2=74927&view=diff ============================================================================== --- llvm/trunk/lib/System/DynamicLibrary.cpp (original) +++ llvm/trunk/lib/System/DynamicLibrary.cpp Tue Jul 7 13:17:07 2009 @@ -9,11 +9,13 @@ // // This header file implements the operating system DynamicLibrary concept. // +// FIXME: This file leaks the ExplicitSymbols and OpenedHandles vector, and is +// not thread safe! +// //===----------------------------------------------------------------------===// #include "llvm/System/DynamicLibrary.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/System/RWMutex.h" #include "llvm/Config/config.h" #include #include @@ -21,13 +23,13 @@ #include // Collection of symbol name/value pairs to be searched prior to any libraries. -static std::map symbols; -static llvm::sys::SmartRWMutex SymbolsLock; +static std::map *ExplicitSymbols = 0; void llvm::sys::DynamicLibrary::AddSymbol(const char* symbolName, void *symbolValue) { - llvm::sys::SmartScopedWriter Writer(&SymbolsLock); - symbols[symbolName] = symbolValue; + if (ExplicitSymbols == 0) + ExplicitSymbols = new std::map(); + (*ExplicitSymbols)[symbolName] = symbolValue; } #ifdef LLVM_ON_WIN32 @@ -37,7 +39,6 @@ #else #include -#include using namespace llvm; using namespace llvm::sys; @@ -46,44 +47,44 @@ //=== independent code. //===----------------------------------------------------------------------===// -static std::vector OpenedHandles; +static std::vector *OpenedHandles = 0; bool DynamicLibrary::LoadLibraryPermanently(const char *Filename, std::string *ErrMsg) { - SmartScopedWriter Writer(&SymbolsLock); void *H = dlopen(Filename, RTLD_LAZY|RTLD_GLOBAL); if (H == 0) { - if (ErrMsg) - *ErrMsg = dlerror(); + if (ErrMsg) *ErrMsg = dlerror(); return true; } - OpenedHandles.push_back(H); + if (OpenedHandles == 0) + OpenedHandles = new std::vector(); + OpenedHandles->push_back(H); return false; } void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { // First check symbols added via AddSymbol(). - SymbolsLock.reader_acquire(); - std::map::iterator I = symbols.find(symbolName); - std::map::iterator E = symbols.end(); - SymbolsLock.reader_release(); + if (ExplicitSymbols) { + std::map::iterator I = + ExplicitSymbols->find(symbolName); + std::map::iterator E = ExplicitSymbols->end(); - if (I != E) - return I->second; + if (I != E) + return I->second; + } - SymbolsLock.writer_acquire(); // Now search the libraries. - for (std::vector::iterator I = OpenedHandles.begin(), - E = OpenedHandles.end(); I != E; ++I) { - //lt_ptr ptr = lt_dlsym(*I, symbolName); - void *ptr = dlsym(*I, symbolName); - if (ptr) { - SymbolsLock.writer_release(); - return ptr; + if (OpenedHandles) { + for (std::vector::iterator I = OpenedHandles->begin(), + E = OpenedHandles->end(); I != E; ++I) { + //lt_ptr ptr = lt_dlsym(*I, symbolName); + void *ptr = dlsym(*I, symbolName); + if (ptr) { + return ptr; + } } } - SymbolsLock.writer_release(); #define EXPLICIT_SYMBOL(SYM) \ extern void *SYM; if (!strcmp(symbolName, #SYM)) return &SYM From isanbard at gmail.com Tue Jul 7 13:21:34 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 07 Jul 2009 18:21:34 -0000 Subject: [llvm-commits] [llvm] r74928 - /llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Message-ID: <200907071821.n67ILZoK024535@zion.cs.uiuc.edu> Author: void Date: Tue Jul 7 13:21:19 2009 New Revision: 74928 URL: http://llvm.org/viewvc/llvm-project?rev=74928&view=rev Log: Remove unused parameter. Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=74928&r1=74927&r2=74928&view=diff ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original) +++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Tue Jul 7 13:21:19 2009 @@ -282,8 +282,8 @@ /// the JIT. See JITEventListener.h for more details. Does not /// take ownership of the argument. The argument may be NULL, in /// which case these functions do nothing. - virtual void RegisterJITEventListener(JITEventListener *L) {} - virtual void UnregisterJITEventListener(JITEventListener *L) {} + virtual void RegisterJITEventListener(JITEventListener *) {} + virtual void UnregisterJITEventListener(JITEventListener *) {} /// DisableLazyCompilation - If called, the JIT will abort if lazy compilation /// is ever attempted. From sabre at nondot.org Tue Jul 7 13:28:30 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 18:28:30 -0000 Subject: [llvm-commits] [llvm] r74929 - /llvm/trunk/include/llvm/CodeGen/BinaryObject.h Message-ID: <200907071828.n67ISaxY024878@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 13:28:00 2009 New Revision: 74929 URL: http://llvm.org/viewvc/llvm-project?rev=74929&view=rev Log: "BinaryObject.h was implicitly converting between uint{16,32,64}_t to uint8_t (via 'foo & 255'), i replaced this with an explicit (uint8_t) cast which is equivalent, faster and more correct (silences type-related warnings). Also, following coding standards I replaced post-increment with pre-increment." Patch by Ryan Flynn! Modified: llvm/trunk/include/llvm/CodeGen/BinaryObject.h Modified: llvm/trunk/include/llvm/CodeGen/BinaryObject.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/BinaryObject.h?rev=74929&r1=74928&r2=74929&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/BinaryObject.h (original) +++ llvm/trunk/include/llvm/CodeGen/BinaryObject.h Tue Jul 7 13:28:00 2009 @@ -86,15 +86,15 @@ /// emitWord16LE - This callback is invoked when a 16-bit word needs to be /// written to the data stream in correct endian format and correct size. inline void emitWord16LE(uint16_t W) { - Data.push_back((W >> 0) & 255); - Data.push_back((W >> 8) & 255); + Data.push_back((uint8_t)(W >> 0)); + Data.push_back((uint8_t)(W >> 8)); } /// emitWord16BE - This callback is invoked when a 16-bit word needs to be /// written to the data stream in correct endian format and correct size. inline void emitWord16BE(uint16_t W) { - Data.push_back((W >> 8) & 255); - Data.push_back((W >> 0) & 255); + Data.push_back((uint8_t)(W >> 8)); + Data.push_back((uint8_t)(W >> 0)); } /// emitWord - This callback is invoked when a word needs to be @@ -127,46 +127,46 @@ /// emitWordLE - This callback is invoked when a 32-bit word needs to be /// written to the data stream in little-endian format. inline void emitWordLE(uint32_t W) { - Data.push_back((W >> 0) & 255); - Data.push_back((W >> 8) & 255); - Data.push_back((W >> 16) & 255); - Data.push_back((W >> 24) & 255); + Data.push_back((uint8_t)(W >> 0)); + Data.push_back((uint8_t)(W >> 8)); + Data.push_back((uint8_t)(W >> 16)); + Data.push_back((uint8_t)(W >> 24)); } /// emitWordBE - This callback is invoked when a 32-bit word needs to be /// written to the data stream in big-endian format. /// inline void emitWordBE(uint32_t W) { - Data.push_back((W >> 24) & 255); - Data.push_back((W >> 16) & 255); - Data.push_back((W >> 8) & 255); - Data.push_back((W >> 0) & 255); + Data.push_back((uint8_t)(W >> 24)); + Data.push_back((uint8_t)(W >> 16)); + Data.push_back((uint8_t)(W >> 8)); + Data.push_back((uint8_t)(W >> 0)); } /// emitDWordLE - This callback is invoked when a 64-bit word needs to be /// written to the data stream in little-endian format. inline void emitDWordLE(uint64_t W) { - Data.push_back((W >> 0) & 255); - Data.push_back((W >> 8) & 255); - Data.push_back((W >> 16) & 255); - Data.push_back((W >> 24) & 255); - Data.push_back((W >> 32) & 255); - Data.push_back((W >> 40) & 255); - Data.push_back((W >> 48) & 255); - Data.push_back((W >> 56) & 255); + Data.push_back((uint8_t)(W >> 0)); + Data.push_back((uint8_t)(W >> 8)); + Data.push_back((uint8_t)(W >> 16)); + Data.push_back((uint8_t)(W >> 24)); + Data.push_back((uint8_t)(W >> 32)); + Data.push_back((uint8_t)(W >> 40)); + Data.push_back((uint8_t)(W >> 48)); + Data.push_back((uint8_t)(W >> 56)); } /// emitDWordBE - This callback is invoked when a 64-bit word needs to be /// written to the data stream in big-endian format. inline void emitDWordBE(uint64_t W) { - Data.push_back((W >> 56) & 255); - Data.push_back((W >> 48) & 255); - Data.push_back((W >> 40) & 255); - Data.push_back((W >> 32) & 255); - Data.push_back((W >> 24) & 255); - Data.push_back((W >> 16) & 255); - Data.push_back((W >> 8) & 255); - Data.push_back((W >> 0) & 255); + Data.push_back((uint8_t)(W >> 56)); + Data.push_back((uint8_t)(W >> 48)); + Data.push_back((uint8_t)(W >> 40)); + Data.push_back((uint8_t)(W >> 32)); + Data.push_back((uint8_t)(W >> 24)); + Data.push_back((uint8_t)(W >> 16)); + Data.push_back((uint8_t)(W >> 8)); + Data.push_back((uint8_t)(W >> 0)); } /// fixByte - This callback is invoked when a byte needs to be @@ -187,15 +187,15 @@ /// emitWord16LE - This callback is invoked when a 16-bit word needs to /// fixup the data stream in little endian format. inline void fixWord16LE(uint16_t W, uint32_t offset) { - Data[offset++] = W & 255; - Data[offset] = (W >> 8) & 255; + Data[offset] = (uint8_t)(W >> 0); + Data[++offset] = (uint8_t)(W >> 8); } /// fixWord16BE - This callback is invoked when a 16-bit word needs to /// fixup data stream in big endian format. inline void fixWord16BE(uint16_t W, uint32_t offset) { - Data[offset++] = (W >> 8) & 255; - Data[offset] = W & 255; + Data[offset] = (uint8_t)(W >> 8); + Data[++offset] = (uint8_t)(W >> 0); } /// emitWord - This callback is invoked when a word needs to @@ -219,19 +219,19 @@ /// fixWord32LE - This callback is invoked when a 32-bit word needs to /// fixup the data in little endian format. inline void fixWord32LE(uint32_t W, uint32_t offset) { - Data[offset++] = W & 255; - Data[offset++] = (W >> 8) & 255; - Data[offset++] = (W >> 16) & 255; - Data[offset] = (W >> 24) & 255; + Data[offset] = (uint8_t)(W >> 0); + Data[++offset] = (uint8_t)(W >> 8); + Data[++offset] = (uint8_t)(W >> 16); + Data[++offset] = (uint8_t)(W >> 24); } /// fixWord32BE - This callback is invoked when a 32-bit word needs to /// fixup the data in big endian format. inline void fixWord32BE(uint32_t W, uint32_t offset) { - Data[offset++] = (W >> 24) & 255; - Data[offset++] = (W >> 16) & 255; - Data[offset++] = (W >> 8) & 255; - Data[offset] = W & 255; + Data[offset] = (uint8_t)(W >> 24); + Data[++offset] = (uint8_t)(W >> 16); + Data[++offset] = (uint8_t)(W >> 8); + Data[++offset] = (uint8_t)(W >> 0); } /// fixWord64 - This callback is invoked when a 64-bit word needs to @@ -246,27 +246,27 @@ /// fixWord64BE - This callback is invoked when a 64-bit word needs to /// fixup the data in little endian format. inline void fixWord64LE(uint64_t W, uint32_t offset) { - Data[offset++] = W & 255; - Data[offset++] = (W >> 8) & 255; - Data[offset++] = (W >> 16) & 255; - Data[offset++] = (W >> 24) & 255; - Data[offset++] = (W >> 32) & 255; - Data[offset++] = (W >> 40) & 255; - Data[offset++] = (W >> 48) & 255; - Data[offset] = (W >> 56) & 255; + Data[offset] = (uint8_t)(W >> 0); + Data[++offset] = (uint8_t)(W >> 8); + Data[++offset] = (uint8_t)(W >> 16); + Data[++offset] = (uint8_t)(W >> 24); + Data[++offset] = (uint8_t)(W >> 32); + Data[++offset] = (uint8_t)(W >> 40); + Data[++offset] = (uint8_t)(W >> 48); + Data[++offset] = (uint8_t)(W >> 56); } /// fixWord64BE - This callback is invoked when a 64-bit word needs to /// fixup the data in big endian format. inline void fixWord64BE(uint64_t W, uint32_t offset) { - Data[offset++] = (W >> 56) & 255; - Data[offset++] = (W >> 48) & 255; - Data[offset++] = (W >> 40) & 255; - Data[offset++] = (W >> 32) & 255; - Data[offset++] = (W >> 24) & 255; - Data[offset++] = (W >> 16) & 255; - Data[offset++] = (W >> 8) & 255; - Data[offset] = W & 255; + Data[offset] = (uint8_t)(W >> 56); + Data[++offset] = (uint8_t)(W >> 48); + Data[++offset] = (uint8_t)(W >> 40); + Data[++offset] = (uint8_t)(W >> 32); + Data[++offset] = (uint8_t)(W >> 24); + Data[++offset] = (uint8_t)(W >> 16); + Data[++offset] = (uint8_t)(W >> 8); + Data[++offset] = (uint8_t)(W >> 0); } /// emitAlignment - Pad the data to the specified alignment. @@ -281,7 +281,7 @@ /// written to the data stream. void emitULEB128Bytes(uint64_t Value) { do { - unsigned char Byte = Value & 0x7f; + uint8_t Byte = (uint8_t)(Value & 0x7f); Value >>= 7; if (Value) Byte |= 0x80; emitByte(Byte); @@ -295,7 +295,7 @@ bool IsMore; do { - unsigned char Byte = Value & 0x7f; + uint8_t Byte = (uint8_t)(Value & 0x7f); Value >>= 7; IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0; if (IsMore) Byte |= 0x80; From clattner at apple.com Tue Jul 7 13:29:16 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 11:29:16 -0700 Subject: [llvm-commits] patch: CodeGen/BinaryObject.h explicit typecast In-Reply-To: References: Message-ID: <3E60DC6A-8BF0-44E9-8239-4ED032C0A0AF@apple.com> On Jul 7, 2009, at 7:46 AM, Ryan Flynn wrote: > BinaryObject.h was implicitly converting between uint{16,32,64}_t to > uint8_t (via 'foo & 255'), i replaced this with an explicit (uint8_t) > cast which is equivalent, faster and more correct (silences > type-related warnings). Also, following coding standards I replaced > post-increment with pre-increment. Looks great, thanks! http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090706/080244.html -Chris From gohman at apple.com Tue Jul 7 13:30:22 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 7 Jul 2009 11:30:22 -0700 Subject: [llvm-commits] PATCH: remove VICmp and VFCmp. In-Reply-To: <7ABB6DFD-7F2E-4F31-A7D9-FC86362095E6@apple.com> References: <4A518899.80806@mxc.ca> <7ABB6DFD-7F2E-4F31-A7D9-FC86362095E6@apple.com> Message-ID: <05085D11-65C9-478A-B854-1EAC52FD9E42@apple.com> On Jul 6, 2009, at 10:10 AM, Chris Lattner wrote: > > On Jul 5, 2009, at 10:16 PM, Nick Lewycky wrote: > > >> This patch removes vicmp and vfcmp, which has the positive side that >> >> it fixes existing type-safety bugs and simplifies some code, but a >> >> downside in that it XFAILs 9 CodeGen tests. >> > > I haven't had a chance to look at the patch, but removing v[fi]cmp > will almost certainly break clang (which generates them for vector > comparisons in opencl/ext_vector mode). The right way to remove this > is to make codegen pattern match [fi]cmp+sext to the same nodes it is > using for v[fi]cmp, then change clang to generate [fi]cmp+sext instead > of v[if]cmp, then nuke v[fi]cmp. This way we won't loose any codegen > capability and clang will still build :). Vector [fi]cmp are not yet ready to replace v[fi]cmp, and there's more work required than just adding patterns. Work has been one to support vector [fi]cmp in the IR, however no work has been done to support it in CodeGen yet. Adding support in CodeGen will require a variety of fairly straight-forward changes, plus finding a solution for vectors of i1 in CodeGen. Here's a simple example: define <4 x float> @foo(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x float> %d) { %y = fcmp olt <4 x float> %a, %b %z = select <4 x i1> %y, <4 x float> %c, <4 x float> %d ret <4 x float> %z } %y has type <4 x i1>. This is not a legal type on most current architectures. But, many architectures have ways of supporting this kind of code, often by putting the comparison result in a <4 x i32> register. The main twist is that a type like <4 x i1> might be legalized to either <4 x i32> or <4 x i64> on a target like x86, depending on the type of the comparison operands, so the current getTypeToTransformTo, which assumes that every type has a unique destination type, isn't sufficient. But this just needs some creativity. Dan From sabre at nondot.org Tue Jul 7 13:31:21 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 18:31:21 -0000 Subject: [llvm-commits] [llvm] r74930 - /llvm/trunk/tools/lli/lli.cpp Message-ID: <200907071831.n67IVQu7025026@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 13:31:09 2009 New Revision: 74930 URL: http://llvm.org/viewvc/llvm-project?rev=74930&view=rev Log: Fix lli to print an error and exit when EE returns null but no string. Patch by Eric Rannaud! Modified: llvm/trunk/tools/lli/lli.cpp Modified: llvm/trunk/tools/lli/lli.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=74930&r1=74929&r2=74930&view=diff ============================================================================== --- llvm/trunk/tools/lli/lli.cpp (original) +++ llvm/trunk/tools/lli/lli.cpp Tue Jul 7 13:31:09 2009 @@ -147,8 +147,11 @@ InitializeNativeTarget(); EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg, OLvl); - if (!EE && !ErrorMsg.empty()) { - std::cerr << argv[0] << ":error creating EE: " << ErrorMsg << "\n"; + if (!EE) { + if (!ErrorMsg.empty()) + std::cerr << argv[0] << ": error creating EE: " << ErrorMsg << "\n"; + else + std::cerr << argv[0] << ": unknown error creating EE!\n"; exit(1); } From resistor at mac.com Tue Jul 7 13:33:05 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Jul 2009 18:33:05 -0000 Subject: [llvm-commits] [llvm] r74931 - in /llvm/trunk: include/llvm/System/ lib/CodeGen/SelectionDAG/ lib/CompilerDriver/ lib/ExecutionEngine/Interpreter/ lib/Support/ lib/Target/ lib/VMCore/ Message-ID: <200907071833.n67IX975025096@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 13:33:04 2009 New Revision: 74931 URL: http://llvm.org/viewvc/llvm-project?rev=74931&view=rev Log: Have scoped mutexes take referenes instead of pointers. Modified: llvm/trunk/include/llvm/System/Mutex.h llvm/trunk/include/llvm/System/RWMutex.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CompilerDriver/Plugin.cpp llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp llvm/trunk/lib/Support/Annotation.cpp llvm/trunk/lib/Support/PluginLoader.cpp llvm/trunk/lib/Support/Statistic.cpp llvm/trunk/lib/Support/Timer.cpp llvm/trunk/lib/Target/TargetData.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Function.cpp llvm/trunk/lib/VMCore/LeakDetector.cpp llvm/trunk/lib/VMCore/Pass.cpp llvm/trunk/lib/VMCore/PassManager.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/lib/VMCore/TypeSymbolTable.cpp llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/include/llvm/System/Mutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Mutex.h (original) +++ llvm/trunk/include/llvm/System/Mutex.h Tue Jul 7 13:33:04 2009 @@ -131,15 +131,15 @@ template class SmartScopedLock { - SmartMutex* mtx; + SmartMutex& mtx; public: - SmartScopedLock(SmartMutex* m) : mtx(m) { - mtx->acquire(); + SmartScopedLock(SmartMutex& m) : mtx(m) { + mtx.acquire(); } ~SmartScopedLock() { - mtx->release(); + mtx.release(); } }; Modified: llvm/trunk/include/llvm/System/RWMutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/RWMutex.h (original) +++ llvm/trunk/include/llvm/System/RWMutex.h Tue Jul 7 13:33:04 2009 @@ -141,15 +141,14 @@ /// ScopedReader - RAII acquisition of a reader lock template struct SmartScopedReader { - SmartRWMutex* mutex; + SmartRWMutex& mutex; - explicit SmartScopedReader(SmartRWMutex* m) { - mutex = m; - mutex->reader_acquire(); + explicit SmartScopedReader(SmartRWMutex& m) : mutex(m) { + mutex.reader_acquire(); } ~SmartScopedReader() { - mutex->reader_release(); + mutex.reader_release(); } }; typedef SmartScopedReader ScopedReader; @@ -157,15 +156,14 @@ /// ScopedWriter - RAII acquisition of a writer lock template struct SmartScopedWriter { - SmartRWMutex* mutex; + SmartRWMutex& mutex; - explicit SmartScopedWriter(SmartRWMutex* m) { - mutex = m; - mutex->writer_acquire(); + explicit SmartScopedWriter(SmartRWMutex& m) : mutex(m) { + mutex.writer_acquire(); } ~SmartScopedWriter() { - mutex->writer_release(); + mutex.writer_release(); } }; typedef SmartScopedWriter ScopedWriter; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Jul 7 13:33:04 2009 @@ -5010,7 +5010,7 @@ /// getValueTypeList - Return a pointer to the specified value type. /// const MVT *SDNode::getValueTypeList(MVT VT) { - sys::SmartScopedLock Lock(&*VTMutex); + sys::SmartScopedLock Lock(*VTMutex); if (VT.isExtended()) { return &(*EVTs->insert(VT).first); } else { Modified: llvm/trunk/lib/CompilerDriver/Plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Plugin.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Plugin.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Plugin.cpp Tue Jul 7 13:33:04 2009 @@ -42,7 +42,7 @@ namespace llvmc { PluginLoader::PluginLoader() { - llvm::sys::SmartScopedLock Lock(&*PluginMutex); + llvm::sys::SmartScopedLock Lock(*PluginMutex); if (!pluginListInitialized) { for (PluginRegistry::iterator B = PluginRegistry::begin(), E = PluginRegistry::end(); B != E; ++B) @@ -53,7 +53,7 @@ } PluginLoader::~PluginLoader() { - llvm::sys::SmartScopedLock Lock(&*PluginMutex); + llvm::sys::SmartScopedLock Lock(*PluginMutex); if (pluginListInitialized) { for (PluginList::iterator B = Plugins.begin(), E = Plugins.end(); B != E; ++B) @@ -63,14 +63,14 @@ } void PluginLoader::PopulateLanguageMap(LanguageMap& langMap) { - llvm::sys::SmartScopedLock Lock(&*PluginMutex); + llvm::sys::SmartScopedLock Lock(*PluginMutex); for (PluginList::iterator B = Plugins.begin(), E = Plugins.end(); B != E; ++B) (*B)->PopulateLanguageMap(langMap); } void PluginLoader::PopulateCompilationGraph(CompilationGraph& graph) { - llvm::sys::SmartScopedLock Lock(&*PluginMutex); + llvm::sys::SmartScopedLock Lock(*PluginMutex); for (PluginList::iterator B = Plugins.begin(), E = Plugins.end(); B != E; ++B) (*B)->PopulateCompilationGraph(graph); Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Tue Jul 7 13:33:04 2009 @@ -97,7 +97,7 @@ ExtName += getTypeID(FT->getContainedType(i)); ExtName += "_" + F->getName(); - sys::ScopedLock Writer(&*FunctionsLock); + sys::ScopedLock Writer(*FunctionsLock); ExFunc FnPtr = FuncNames[ExtName]; if (FnPtr == 0) FnPtr = FuncNames["lle_X_"+F->getName()]; @@ -539,7 +539,7 @@ void Interpreter::initializeExternalFunctions() { - sys::ScopedLock Writer(&*FunctionsLock); + sys::ScopedLock Writer(*FunctionsLock); FuncNames["lle_X_atexit"] = lle_X_atexit; FuncNames["lle_X_exit"] = lle_X_exit; FuncNames["lle_X_abort"] = lle_X_abort; Modified: llvm/trunk/lib/Support/Annotation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Annotation.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/Support/Annotation.cpp (original) +++ llvm/trunk/lib/Support/Annotation.cpp Tue Jul 7 13:33:04 2009 @@ -55,7 +55,7 @@ } static void eraseFromFactMap(unsigned ID) { - sys::SmartScopedWriter Writer(&*AnnotationsLock); + sys::SmartScopedWriter Writer(*AnnotationsLock); TheFactMap->erase(ID); } @@ -66,7 +66,7 @@ AnnotationsLock->reader_release(); if (I == E) { - sys::SmartScopedWriter Writer(&*AnnotationsLock); + sys::SmartScopedWriter Writer(*AnnotationsLock); I = IDMap->find(Name); if (I == IDMap->end()) { unsigned newCount = sys::AtomicIncrement(&IDCounter); @@ -91,7 +91,7 @@ // only be used for debugging. // const char *AnnotationManager::getName(AnnotationID ID) { // ID -> Name - sys::SmartScopedReader Reader(&*AnnotationsLock); + sys::SmartScopedReader Reader(*AnnotationsLock); IDMapType &TheMap = *IDMap; for (IDMapType::iterator I = TheMap.begin(); ; ++I) { assert(I != TheMap.end() && "Annotation ID is unknown!"); @@ -106,7 +106,7 @@ void AnnotationManager::registerAnnotationFactory(AnnotationID ID, AnnFactory F, void *ExtraData) { if (F) { - sys::SmartScopedWriter Writer(&*AnnotationsLock); + sys::SmartScopedWriter Writer(*AnnotationsLock); getFactMap()[ID.ID] = std::make_pair(F, ExtraData); } else { eraseFromFactMap(ID.ID); Modified: llvm/trunk/lib/Support/PluginLoader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PluginLoader.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/Support/PluginLoader.cpp (original) +++ llvm/trunk/lib/Support/PluginLoader.cpp Tue Jul 7 13:33:04 2009 @@ -25,7 +25,7 @@ static ManagedStatic > PluginsLock; void PluginLoader::operator=(const std::string &Filename) { - sys::SmartScopedLock Lock(&*PluginsLock); + sys::SmartScopedLock Lock(*PluginsLock); std::string Error; if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) { cerr << "Error opening '" << Filename << "': " << Error @@ -36,12 +36,12 @@ } unsigned PluginLoader::getNumPlugins() { - sys::SmartScopedLock Lock(&*PluginsLock); + sys::SmartScopedLock Lock(*PluginsLock); return Plugins.isConstructed() ? Plugins->size() : 0; } std::string &PluginLoader::getPlugin(unsigned num) { - sys::SmartScopedLock Lock(&*PluginsLock); + sys::SmartScopedLock Lock(*PluginsLock); assert(Plugins.isConstructed() && num < Plugins->size() && "Asking for an out of bounds plugin"); return (*Plugins)[num]; Modified: llvm/trunk/lib/Support/Statistic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Statistic.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/Support/Statistic.cpp (original) +++ llvm/trunk/lib/Support/Statistic.cpp Tue Jul 7 13:33:04 2009 @@ -65,7 +65,7 @@ void Statistic::RegisterStatistic() { // If stats are enabled, inform StatInfo that this statistic should be // printed. - sys::ScopedLock Writer(&*StatLock); + sys::ScopedLock Writer(*StatLock); if (!Initialized) { if (Enabled) StatInfo->addStatistic(this); Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Tue Jul 7 13:33:04 2009 @@ -145,7 +145,7 @@ static ManagedStatic > ActiveTimers; void Timer::startTimer() { - sys::SmartScopedLock L(&Lock); + sys::SmartScopedLock L(Lock); Started = true; ActiveTimers->push_back(this); TimeRecord TR = getTimeRecord(true); @@ -157,7 +157,7 @@ } void Timer::stopTimer() { - sys::SmartScopedLock L(&Lock); + sys::SmartScopedLock L(Lock); TimeRecord TR = getTimeRecord(false); Elapsed += TR.Elapsed; UserTime += TR.UserTime; @@ -229,7 +229,7 @@ static ManagedStatic NamedGroupedTimers; static Timer &getNamedRegionTimer(const std::string &Name) { - sys::SmartScopedLock L(&*TimerLock); + sys::SmartScopedLock L(*TimerLock); Name2Timer::iterator I = NamedTimers->find(Name); if (I != NamedTimers->end()) return I->second; @@ -239,7 +239,7 @@ static Timer &getNamedRegionTimer(const std::string &Name, const std::string &GroupName) { - sys::SmartScopedLock L(&*TimerLock); + sys::SmartScopedLock L(*TimerLock); Name2Pair::iterator I = NamedGroupedTimers->find(GroupName); if (I == NamedGroupedTimers->end()) { @@ -365,7 +365,7 @@ void TimerGroup::removeTimer() { - sys::SmartScopedLock L(&*TimerLock); + sys::SmartScopedLock L(*TimerLock); if (--NumTimers == 0 && !TimersToPrint.empty()) { // Print timing report... // Sort the timers in descending order by amount of time taken... std::sort(TimersToPrint.begin(), TimersToPrint.end(), @@ -434,12 +434,12 @@ } void TimerGroup::addTimer() { - sys::SmartScopedLock L(&*TimerLock); + sys::SmartScopedLock L(*TimerLock); ++NumTimers; } void TimerGroup::addTimerToPrint(const Timer &T) { - sys::SmartScopedLock L(&*TimerLock); + sys::SmartScopedLock L(*TimerLock); TimersToPrint.push_back(Timer(true, T)); } Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Tue Jul 7 13:33:04 2009 @@ -352,7 +352,7 @@ if (!LayoutInfo.isConstructed()) return; - sys::SmartScopedLock Lock(&*LayoutLock); + sys::SmartScopedLock Lock(*LayoutLock); // Remove any layouts for this TD. LayoutInfoTy &TheMap = *LayoutInfo; for (LayoutInfoTy::iterator I = TheMap.begin(), E = TheMap.end(); I != E; ) { @@ -369,7 +369,7 @@ const StructLayout *TargetData::getStructLayout(const StructType *Ty) const { LayoutInfoTy &TheMap = *LayoutInfo; - sys::SmartScopedLock Lock(&*LayoutLock); + sys::SmartScopedLock Lock(*LayoutLock); StructLayout *&SL = TheMap[LayoutKey(this, Ty)]; if (SL) return SL; @@ -394,7 +394,7 @@ void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const { if (!LayoutInfo.isConstructed()) return; // No cache. - sys::SmartScopedLock Lock(&*LayoutLock); + sys::SmartScopedLock Lock(*LayoutLock); LayoutInfoTy::iterator I = LayoutInfo->find(LayoutKey(this, Ty)); if (I == LayoutInfo->end()) return; Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Tue Jul 7 13:33:04 2009 @@ -307,7 +307,7 @@ ConstantsLock->reader_release(); if (!Slot) { - sys::SmartScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(*ConstantsLock); ConstantInt *&NewSlot = (*IntConstants)[Key]; if (!Slot) { NewSlot = new ConstantInt(ITy, V); @@ -414,7 +414,7 @@ ConstantsLock->reader_release(); if (!Slot) { - sys::SmartScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(*ConstantsLock); ConstantFP *&NewSlot = (*FPConstants)[Key]; if (!NewSlot) { const Type *Ty; @@ -1231,7 +1231,7 @@ /// getOrCreate - Return the specified constant from the map, creating it if /// necessary. ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { - sys::SmartScopedLock Lock(&ValueMapLock); + sys::SmartScopedLock Lock(ValueMapLock); MapKey Lookup(Ty, V); ConstantClass* Result = 0; @@ -1249,7 +1249,7 @@ } void remove(ConstantClass *CP) { - sys::SmartScopedLock Lock(&ValueMapLock); + sys::SmartScopedLock Lock(ValueMapLock); typename MapTy::iterator I = FindExistingElement(CP); assert(I != Map.end() && "Constant not found in constant table!"); assert(I->second == CP && "Didn't find correct element?"); @@ -1334,7 +1334,7 @@ } void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { - sys::SmartScopedLock Lock(&ValueMapLock); + sys::SmartScopedLock Lock(ValueMapLock); typename AbstractTypeMapTy::iterator I = AbstractTypeMap.find(cast(OldTy)); @@ -1793,7 +1793,7 @@ static ManagedStatic > MDStringCache; MDString *MDString::get(const char *StrBegin, const char *StrEnd) { - sys::SmartScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(*ConstantsLock); StringMapEntry &Entry = MDStringCache->GetOrCreateValue( StrBegin, StrEnd); MDString *&S = Entry.getValue(); @@ -1804,7 +1804,7 @@ } MDString *MDString::get(const std::string &Str) { - sys::SmartScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(*ConstantsLock); StringMapEntry &Entry = MDStringCache->GetOrCreateValue( Str.data(), Str.data() + Str.size()); MDString *&S = Entry.getValue(); @@ -1815,7 +1815,7 @@ } void MDString::destroyConstant() { - sys::SmartScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(*ConstantsLock); MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); destroyConstantImpl(); } @@ -1847,7 +1847,7 @@ ConstantsLock->reader_release(); if (!N) { - sys::SmartScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(*ConstantsLock); N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); if (!N) { // InsertPoint will have been set by the FindNodeOrInsertPos call. @@ -1859,7 +1859,7 @@ } void MDNode::destroyConstant() { - sys::SmartScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(*ConstantsLock); MDNodeSet->RemoveNode(this); destroyConstantImpl(); @@ -2790,7 +2790,7 @@ Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. - sys::SmartScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(*ConstantsLock); bool Exists; ArrayConstantsTy::MapTy::iterator I = ArrayConstants->InsertOrGetItem(Lookup, Exists); @@ -2866,7 +2866,7 @@ Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. - sys::SmartScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(*ConstantsLock); bool Exists; StructConstantsTy::MapTy::iterator I = StructConstants->InsertOrGetItem(Lookup, Exists); Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Tue Jul 7 13:33:04 2009 @@ -242,18 +242,18 @@ static ManagedStatic > GCLock; bool Function::hasGC() const { - sys::SmartScopedReader Reader(&*GCLock); + sys::SmartScopedReader Reader(*GCLock); return GCNames && GCNames->count(this); } const char *Function::getGC() const { assert(hasGC() && "Function has no collector"); - sys::SmartScopedReader Reader(&*GCLock); + sys::SmartScopedReader Reader(*GCLock); return *(*GCNames)[this]; } void Function::setGC(const char *Str) { - sys::SmartScopedWriter Writer(&*GCLock); + sys::SmartScopedWriter Writer(*GCLock); if (!GCNamePool) GCNamePool = new StringPool(); if (!GCNames) @@ -262,7 +262,7 @@ } void Function::clearGC() { - sys::SmartScopedWriter Writer(&*GCLock); + sys::SmartScopedWriter Writer(*GCLock); if (GCNames) { GCNames->erase(this); if (GCNames->empty()) { Modified: llvm/trunk/lib/VMCore/LeakDetector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LeakDetector.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LeakDetector.cpp (original) +++ llvm/trunk/lib/VMCore/LeakDetector.cpp Tue Jul 7 13:33:04 2009 @@ -54,7 +54,7 @@ // immediately, it is added to the CachedValue Value. If it is // immediately removed, no set search need be performed. void addGarbage(const T* o) { - sys::SmartScopedWriter Writer(&*LeakDetectorLock); + sys::SmartScopedWriter Writer(*LeakDetectorLock); if (Cache) { assert(Ts.count(Cache) == 0 && "Object already in set!"); Ts.insert(Cache); @@ -63,7 +63,7 @@ } void removeGarbage(const T* o) { - sys::SmartScopedWriter Writer(&*LeakDetectorLock); + sys::SmartScopedWriter Writer(*LeakDetectorLock); if (o == Cache) Cache = 0; // Cache hit else @@ -73,7 +73,7 @@ bool hasGarbage(const std::string& Message) { addGarbage(0); // Flush the Cache - sys::SmartScopedReader Reader(&*LeakDetectorLock); + sys::SmartScopedReader Reader(*LeakDetectorLock); assert(Cache == 0 && "No value should be cached anymore!"); if (!Ts.empty()) { Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Tue Jul 7 13:33:04 2009 @@ -233,7 +233,7 @@ getPassRegistrar()->RegisterPass(*this); // Notify any listeners. - sys::SmartScopedLock Lock(&ListenersLock); + sys::SmartScopedLock Lock(ListenersLock); if (Listeners) for (std::vector::iterator I = Listeners->begin(), E = Listeners->end(); I != E; ++I) @@ -286,14 +286,14 @@ // PassRegistrationListener ctor - Add the current object to the list of // PassRegistrationListeners... PassRegistrationListener::PassRegistrationListener() { - sys::SmartScopedLock Lock(&ListenersLock); + sys::SmartScopedLock Lock(ListenersLock); if (!Listeners) Listeners = new std::vector(); Listeners->push_back(this); } // dtor - Remove object from list of listeners... PassRegistrationListener::~PassRegistrationListener() { - sys::SmartScopedLock Lock(&ListenersLock); + sys::SmartScopedLock Lock(ListenersLock); std::vector::iterator I = std::find(Listeners->begin(), Listeners->end(), this); assert(Listeners && I != Listeners->end() && Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Tue Jul 7 13:33:04 2009 @@ -392,7 +392,7 @@ if (dynamic_cast(P)) return; - sys::SmartScopedLock Lock(&*TimingInfoMutex); + sys::SmartScopedLock Lock(*TimingInfoMutex); std::map::iterator I = TimingData.find(P); if (I == TimingData.end()) I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first; @@ -403,7 +403,7 @@ if (dynamic_cast(P)) return; - sys::SmartScopedLock Lock(&*TimingInfoMutex); + sys::SmartScopedLock Lock(*TimingInfoMutex); std::map::iterator I = TimingData.find(P); assert(I != TimingData.end() && "passStarted/passEnded not nested right!"); I->second.stopTimer(); Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Jul 7 13:33:04 2009 @@ -1006,7 +1006,7 @@ // First, see if the type is already in the table, for which // a reader lock suffices. - sys::SmartScopedLock L(&*TypeMapLock); + sys::SmartScopedLock L(*TypeMapLock); ITy = IntegerTypes->get(IVT); if (!ITy) { @@ -1079,7 +1079,7 @@ FunctionValType VT(ReturnType, Params, isVarArg); FunctionType *FT = 0; - sys::SmartScopedLock L(&*TypeMapLock); + sys::SmartScopedLock L(*TypeMapLock); FT = FunctionTypes->get(VT); if (!FT) { @@ -1129,7 +1129,7 @@ ArrayValType AVT(ElementType, NumElements); ArrayType *AT = 0; - sys::SmartScopedLock L(&*TypeMapLock); + sys::SmartScopedLock L(*TypeMapLock); AT = ArrayTypes->get(AVT); if (!AT) { @@ -1188,7 +1188,7 @@ VectorValType PVT(ElementType, NumElements); VectorType *PT = 0; - sys::SmartScopedLock L(&*TypeMapLock); + sys::SmartScopedLock L(*TypeMapLock); PT = VectorTypes->get(PVT); if (!PT) { @@ -1250,7 +1250,7 @@ StructValType STV(ETypes, isPacked); StructType *ST = 0; - sys::SmartScopedLock L(&*TypeMapLock); + sys::SmartScopedLock L(*TypeMapLock); ST = StructTypes->get(STV); if (!ST) { @@ -1329,7 +1329,7 @@ PointerType *PT = 0; - sys::SmartScopedLock L(&*TypeMapLock); + sys::SmartScopedLock L(*TypeMapLock); PT = PointerTypes->get(PVT); if (!PT) { @@ -1488,7 +1488,7 @@ void DerivedType::refineAbstractTypeTo(const Type *NewType) { // All recursive calls will go through unlockedRefineAbstractTypeTo, // to avoid deadlock problems. - sys::SmartScopedLock L(&*TypeMapLock); + sys::SmartScopedLock L(*TypeMapLock); unlockedRefineAbstractTypeTo(NewType); } Modified: llvm/trunk/lib/VMCore/TypeSymbolTable.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/TypeSymbolTable.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/TypeSymbolTable.cpp (original) +++ llvm/trunk/lib/VMCore/TypeSymbolTable.cpp Tue Jul 7 13:33:04 2009 @@ -37,7 +37,7 @@ std::string TypeSymbolTable::getUniqueName(const std::string &BaseName) const { std::string TryName = BaseName; - sys::SmartScopedReader Reader(&*TypeSymbolTableLock); + sys::SmartScopedReader Reader(*TypeSymbolTableLock); const_iterator End = tmap.end(); @@ -49,7 +49,7 @@ // lookup a type by name - returns null on failure Type* TypeSymbolTable::lookup(const std::string& Name) const { - sys::SmartScopedReader Reader(&*TypeSymbolTableLock); + sys::SmartScopedReader Reader(*TypeSymbolTableLock); const_iterator TI = tmap.find(Name); Type* result = 0; @@ -134,7 +134,7 @@ // This function is called when one of the types in the type plane are refined void TypeSymbolTable::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - sys::SmartScopedReader Reader(&*TypeSymbolTableLock); + sys::SmartScopedReader Reader(*TypeSymbolTableLock); // Loop over all of the types in the symbol table, replacing any references // to OldType with references to NewType. Note that there may be multiple @@ -165,7 +165,7 @@ // Loop over all of the types in the symbol table, dropping any abstract // type user entries for AbsTy which occur because there are names for the // type. - sys::SmartScopedReader Reader(&*TypeSymbolTableLock); + sys::SmartScopedReader Reader(*TypeSymbolTableLock); for (iterator TI = begin(), TE = end(); TI != TE; ++TI) if (TI->second == const_cast(static_cast(AbsTy))) AbsTy->removeAbstractTypeUser(this); @@ -179,7 +179,7 @@ void TypeSymbolTable::dump() const { cerr << "TypeSymbolPlane: "; - sys::SmartScopedReader Reader(&*TypeSymbolTableLock); + sys::SmartScopedReader Reader(*TypeSymbolTableLock); for_each(tmap.begin(), tmap.end(), DumpTypes); } Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=74931&r1=74930&r2=74931&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Tue Jul 7 13:33:04 2009 @@ -430,7 +430,7 @@ if (VP->HasValueHandle) { // If this value already has a ValueHandle, then it must be in the // ValueHandles map already. - sys::SmartScopedReader Reader(&*ValueHandlesLock); + sys::SmartScopedReader Reader(*ValueHandlesLock); ValueHandleBase *&Entry = (*ValueHandles)[VP]; assert(Entry != 0 && "Value doesn't have any handles?"); AddToExistingUseList(&Entry); @@ -442,7 +442,7 @@ // reallocate itself, which would invalidate all of the PrevP pointers that // point into the old table. Handle this by checking for reallocation and // updating the stale pointers only if needed. - sys::SmartScopedWriter Writer(&*ValueHandlesLock); + sys::SmartScopedWriter Writer(*ValueHandlesLock); ValueHandlesTy &Handles = *ValueHandles; const void *OldBucketPtr = Handles.getPointerIntoBucketsArray(); @@ -484,7 +484,7 @@ // If the Next pointer was null, then it is possible that this was the last // ValueHandle watching VP. If so, delete its entry from the ValueHandles // map. - sys::SmartScopedWriter Writer(&*ValueHandlesLock); + sys::SmartScopedWriter Writer(*ValueHandlesLock); ValueHandlesTy &Handles = *ValueHandles; if (Handles.isPointerIntoBucketsArray(PrevPtr)) { Handles.erase(VP); From brukman at gmail.com Tue Jul 7 13:35:41 2009 From: brukman at gmail.com (Misha Brukman) Date: Tue, 7 Jul 2009 14:35:41 -0400 Subject: [llvm-commits] [llvm] r74929 - /llvm/trunk/include/llvm/CodeGen/BinaryObject.h In-Reply-To: <200907071828.n67ISaxY024878@zion.cs.uiuc.edu> References: <200907071828.n67ISaxY024878@zion.cs.uiuc.edu> Message-ID: 2009/7/7 Chris Lattner > - Data.push_back((W >> 0) & 255); > - Data.push_back((W >> 8) & 255); > + Data.push_back((uint8_t)(W >> 0)); > + Data.push_back((uint8_t)(W >> 8)); These are all C-style casts, rather than C++-style casts, e.g. static_cast(value) . Is there a preference for C-style casts in LLVM? I thought we were trying to stick with C++ here. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090707/537a8e7c/attachment.html From sabre at nondot.org Tue Jul 7 13:40:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 18:40:11 -0000 Subject: [llvm-commits] [llvm] r74932 - /llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Message-ID: <200907071840.n67IeHsG025328@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 13:39:49 2009 New Revision: 74932 URL: http://llvm.org/viewvc/llvm-project?rev=74932&view=rev Log: fix some type confusion in ReadVBR64: "Piece" should be only 32 bits, not 64, because we read at most 32 bits at a time. OTOH, "Result" must be 64-bits and insertion into it must be 64-bit clean. Thanks to Ivan Sorokin for bringing this up. Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=74932&r1=74931&r2=74932&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Tue Jul 7 13:39:49 2009 @@ -260,6 +260,7 @@ uint32_t Read(unsigned NumBits) { + assert(NumBits <= 32 && "Cannot return more than 32 bits!"); // If the field is fully contained by CurWord, return it quickly. if (BitsInCurWord >= NumBits) { uint32_t R = CurWord & ((1U << NumBits)-1); @@ -322,17 +323,19 @@ } } + // ReadVBR64 - Read a VBR that may have a value up to 64-bits in size. The + // chunk size of the VBR must still be <= 32 bits though. uint64_t ReadVBR64(unsigned NumBits) { - uint64_t Piece = Read(NumBits); - if ((Piece & (uint64_t(1) << (NumBits-1))) == 0) - return Piece; + uint32_t Piece = Read(NumBits); + if ((Piece & (1U << (NumBits-1))) == 0) + return uint64_t(Piece); uint64_t Result = 0; unsigned NextBit = 0; while (1) { - Result |= (Piece & ((1U << (NumBits-1))-1)) << NextBit; + Result |= uint64_t(Piece & ((1U << (NumBits-1))-1)) << NextBit; - if ((Piece & (uint64_t(1) << (NumBits-1))) == 0) + if ((Piece & (1U << (NumBits-1))) == 0) return Result; NextBit += NumBits-1; From sabre at nondot.org Tue Jul 7 13:43:49 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 18:43:49 -0000 Subject: [llvm-commits] [llvm] r74933 - /llvm/trunk/include/llvm/ADT/PostOrderIterator.h Message-ID: <200907071843.n67Ihnsi025447@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 13:43:48 2009 New Revision: 74933 URL: http://llvm.org/viewvc/llvm-project?rev=74933&view=rev Log: fix a bug in post-order iterators with external storage, patch by Olaf Krzikalla! Modified: llvm/trunk/include/llvm/ADT/PostOrderIterator.h Modified: llvm/trunk/include/llvm/ADT/PostOrderIterator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PostOrderIterator.h?rev=74933&r1=74932&r2=74933&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/PostOrderIterator.h (original) +++ llvm/trunk/include/llvm/ADT/PostOrderIterator.h Tue Jul 7 13:43:48 2009 @@ -71,7 +71,7 @@ inline po_iterator() {} // End is when stack is empty. inline po_iterator(NodeType *BB, SetType &S) : - po_iterator_storage(&S) { + po_iterator_storage(S) { if(!S.count(BB)) { this->Visited.insert(BB); VisitStack.push(std::make_pair(BB, GT::child_begin(BB))); @@ -80,7 +80,7 @@ } inline po_iterator(SetType &S) : - po_iterator_storage(&S) { + po_iterator_storage(S) { } // End is when stack is empty. public: typedef typename super::pointer pointer; From resistor at mac.com Tue Jul 7 13:44:16 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Jul 2009 18:44:16 -0000 Subject: [llvm-commits] [llvm] r74934 - in /llvm/trunk/lib/AsmParser: LLLexer.cpp LLLexer.h LLParser.h Message-ID: <200907071844.n67IiGth025476@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 13:44:11 2009 New Revision: 74934 URL: http://llvm.org/viewvc/llvm-project?rev=74934&view=rev Log: Use LLVMContext in the LLLexer. Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLLexer.h llvm/trunk/lib/AsmParser/LLParser.h Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=74934&r1=74933&r2=74934&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Tue Jul 7 13:44:11 2009 @@ -14,6 +14,7 @@ #include "LLLexer.h" #include "llvm/DerivedTypes.h" #include "llvm/Instruction.h" +#include "llvm/LLVMContext.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/SourceMgr.h" @@ -180,8 +181,9 @@ // Lexer definition. //===----------------------------------------------------------------------===// -LLLexer::LLLexer(MemoryBuffer *StartBuf, SourceMgr &sm, SMDiagnostic &Err) - : CurBuf(StartBuf), ErrorInfo(Err), SM(sm), APFloatVal(0.0) { +LLLexer::LLLexer(MemoryBuffer *StartBuf, SourceMgr &sm, SMDiagnostic &Err, + LLVMContext &C) + : CurBuf(StartBuf), ErrorInfo(Err), SM(sm), Context(C), APFloatVal(0.0) { CurPtr = CurBuf->getBufferStart(); } @@ -452,7 +454,7 @@ Error("bitwidth for integer type out of range!"); return lltok::Error; } - TyVal = IntegerType::get(NumBits); + TyVal = Context.getIntegerType(NumBits); return lltok::Type; } Modified: llvm/trunk/lib/AsmParser/LLLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.h?rev=74934&r1=74933&r2=74934&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.h (original) +++ llvm/trunk/lib/AsmParser/LLLexer.h Tue Jul 7 13:44:11 2009 @@ -24,12 +24,14 @@ class MemoryBuffer; class Type; class SMDiagnostic; + class LLVMContext; class LLLexer { const char *CurPtr; MemoryBuffer *CurBuf; SMDiagnostic &ErrorInfo; SourceMgr &SM; + LLVMContext &Context; // Information about the current token. const char *TokStart; @@ -42,7 +44,8 @@ std::string TheError; public: - explicit LLLexer(MemoryBuffer *StartBuf, SourceMgr &SM, SMDiagnostic &); + explicit LLLexer(MemoryBuffer *StartBuf, SourceMgr &SM, SMDiagnostic &, + LLVMContext &C); ~LLLexer() {} lltok::Kind Lex() { Modified: llvm/trunk/lib/AsmParser/LLParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=74934&r1=74933&r2=74934&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.h (original) +++ llvm/trunk/lib/AsmParser/LLParser.h Tue Jul 7 13:44:11 2009 @@ -74,7 +74,7 @@ std::vector NumberedVals; public: LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) : - Context(m->getContext()), Lex(F, SM, Err), M(m) {} + Context(m->getContext()), Lex(F, SM, Err, m->getContext()), M(m) {} bool Run(); LLVMContext& getContext() { return Context; } From devang.patel at gmail.com Tue Jul 7 13:44:34 2009 From: devang.patel at gmail.com (Devang Patel) Date: Tue, 7 Jul 2009 11:44:34 -0700 Subject: [llvm-commits] [llvm] r74920 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp In-Reply-To: <200907071712.n67HCxXb021589@zion.cs.uiuc.edu> References: <200907071712.n67HCxXb021589@zion.cs.uiuc.edu> Message-ID: <352a1fb20907071144l5869e350qe299935b908554@mail.gmail.com> Thanks! - Devang On Tue, Jul 7, 2009 at 10:12 AM, Owen Anderson wrote: > Author: resistor > Date: Tue Jul ?7 12:12:53 2009 > New Revision: 74920 > > URL: http://llvm.org/viewvc/llvm-project?rev=74920&view=rev > Log: > Re-LLVMContext-ize DebugInfo, now with less breakage. > > Modified: > ? ?llvm/trunk/include/llvm/Analysis/DebugInfo.h > ? ?llvm/trunk/lib/Analysis/DebugInfo.cpp > > Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=74920&r1=74919&r2=74920&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) > +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Jul ?7 12:12:53 2009 > @@ -39,6 +39,7 @@ > ? class DebugLoc; > ? class DebugLocTracker; > ? class Instruction; > + ?class LLVMContext; > > ? class DIDescriptor { > ? protected: > @@ -407,6 +408,8 @@ > ? /// descriptors. > ? class DIFactory { > ? ? Module &M; > + ? ?LLVMContext& VMContext; > + > ? ? // Cached values for uniquing and faster lookups. > ? ? const Type *EmptyStructPtr; // "{}*". > ? ? Function *StopPointFn; ? // llvm.dbg.stoppoint > > Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=74920&r1=74919&r2=74920&view=diff > > ============================================================================== > --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) > +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Jul ?7 12:12:53 2009 > @@ -18,6 +18,7 @@ > ?#include "llvm/Intrinsics.h" > ?#include "llvm/IntrinsicInst.h" > ?#include "llvm/Instructions.h" > +#include "llvm/LLVMContext.h" > ?#include "llvm/Module.h" > ?#include "llvm/Analysis/ValueTracking.h" > ?#include "llvm/Support/Dwarf.h" > @@ -453,22 +454,23 @@ > ?//===----------------------------------------------------------------------===// > > ?DIFactory::DIFactory(Module &m) > - ?: M(m), StopPointFn(0), FuncStartFn(0), RegionStartFn(0), RegionEndFn(0), > + ?: M(m), VMContext(M.getContext()), StopPointFn(0), FuncStartFn(0), > + ? ?RegionStartFn(0), RegionEndFn(0), > ? ? DeclareFn(0) { > - ?EmptyStructPtr = PointerType::getUnqual(StructType::get()); > + ?EmptyStructPtr = VMContext.getPointerTypeUnqual(VMContext.getStructType()); > ?} > > ?/// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'. > ?/// This is only valid when the descriptor is non-null. > ?Constant *DIFactory::getCastToEmpty(DIDescriptor D) { > ? if (D.isNull()) return Constant::getNullValue(EmptyStructPtr); > - ?return ConstantExpr::getBitCast(D.getGV(), EmptyStructPtr); > + ?return VMContext.getConstantExprBitCast(D.getGV(), EmptyStructPtr); > ?} > > ?Constant *DIFactory::GetTagConstant(unsigned TAG) { > ? assert((TAG & LLVMDebugVersionMask) == 0 && > ? ? ? ? ?"Tag too large for debug encoding!"); > - ?return ConstantInt::get(Type::Int32Ty, TAG | LLVMDebugVersion); > + ?return VMContext.getConstantInt(Type::Int32Ty, TAG | LLVMDebugVersion); > ?} > > ?Constant *DIFactory::GetStringConstant(const std::string &String) { > @@ -478,21 +480,21 @@ > ? // Return Constant if previously defined. > ? if (Slot) return Slot; > > - ?const PointerType *DestTy = PointerType::getUnqual(Type::Int8Ty); > + ?const PointerType *DestTy = VMContext.getPointerTypeUnqual(Type::Int8Ty); > > ? // If empty string then use a i8* null instead. > ? if (String.empty()) > - ? ?return Slot = ConstantPointerNull::get(DestTy); > + ? ?return Slot = VMContext.getConstantPointerNull(DestTy); > > ? // Construct string as an llvm constant. > - ?Constant *ConstStr = ConstantArray::get(String); > + ?Constant *ConstStr = VMContext.getConstantArray(String); > > ? // Otherwise create and return a new string global. > ? GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GlobalVariable::InternalLinkage, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ConstStr, ".str", &M); > ? StrGV->setSection("llvm.metadata"); > - ?return Slot = ConstantExpr::getBitCast(StrGV, DestTy); > + ?return Slot = VMContext.getConstantExprBitCast(StrGV, DestTy); > ?} > > ?//===----------------------------------------------------------------------===// > @@ -507,7 +509,7 @@ > ? for (unsigned i = 0; i != NumTys; ++i) > ? ? Elts.push_back(getCastToEmpty(Tys[i])); > > - ?Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr, > + ?Constant *Init = VMContext.getConstantArray(VMContext.getArrayType(EmptyStructPtr, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Elts.size()), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Elts.data(), Elts.size()); > ? // If we already have this array, just return the uniqued version. > @@ -527,11 +529,12 @@ > ?DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) { > ? Constant *Elts[] = { > ? ? GetTagConstant(dwarf::DW_TAG_subrange_type), > - ? ?ConstantInt::get(Type::Int64Ty, Lo), > - ? ?ConstantInt::get(Type::Int64Ty, Hi) > + ? ?VMContext.getConstantInt(Type::Int64Ty, Lo), > + ? ?VMContext.getConstantInt(Type::Int64Ty, Hi) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? // If we already have this range, just return the uniqued version. > ? DIDescriptor &Entry = SimpleConstantCache[Init]; > @@ -561,18 +564,19 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned RunTimeVer) { > ? Constant *Elts[] = { > ? ? GetTagConstant(dwarf::DW_TAG_compile_unit), > - ? ?Constant::getNullValue(EmptyStructPtr), > - ? ?ConstantInt::get(Type::Int32Ty, LangID), > + ? ?VMContext.getNullValue(EmptyStructPtr), > + ? ?VMContext.getConstantInt(Type::Int32Ty, LangID), > ? ? GetStringConstant(Filename), > ? ? GetStringConstant(Directory), > ? ? GetStringConstant(Producer), > - ? ?ConstantInt::get(Type::Int1Ty, isMain), > - ? ?ConstantInt::get(Type::Int1Ty, isOptimized), > + ? ?VMContext.getConstantInt(Type::Int1Ty, isMain), > + ? ?VMContext.getConstantInt(Type::Int1Ty, isOptimized), > ? ? GetStringConstant(Flags), > - ? ?ConstantInt::get(Type::Int32Ty, RunTimeVer) > + ? ?VMContext.getConstantInt(Type::Int32Ty, RunTimeVer) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? M.addTypeName("llvm.dbg.compile_unit.type", Init->getType()); > ? GlobalVariable *GV = new GlobalVariable(Init->getType(), true, > @@ -587,10 +591,11 @@ > ? Constant *Elts[] = { > ? ? GetTagConstant(dwarf::DW_TAG_enumerator), > ? ? GetStringConstant(Name), > - ? ?ConstantInt::get(Type::Int64Ty, Val) > + ? ?VMContext.getConstantInt(Type::Int64Ty, Val) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? M.addTypeName("llvm.dbg.enumerator.type", Init->getType()); > ? GlobalVariable *GV = new GlobalVariable(Init->getType(), true, > @@ -615,15 +620,16 @@ > ? ? getCastToEmpty(Context), > ? ? GetStringConstant(Name), > ? ? getCastToEmpty(CompileUnit), > - ? ?ConstantInt::get(Type::Int32Ty, LineNumber), > - ? ?ConstantInt::get(Type::Int64Ty, SizeInBits), > - ? ?ConstantInt::get(Type::Int64Ty, AlignInBits), > - ? ?ConstantInt::get(Type::Int64Ty, OffsetInBits), > - ? ?ConstantInt::get(Type::Int32Ty, Flags), > - ? ?ConstantInt::get(Type::Int32Ty, Encoding) > + ? ?VMContext.getConstantInt(Type::Int32Ty, LineNumber), > + ? ?VMContext.getConstantInt(Type::Int64Ty, SizeInBits), > + ? ?VMContext.getConstantInt(Type::Int64Ty, AlignInBits), > + ? ?VMContext.getConstantInt(Type::Int64Ty, OffsetInBits), > + ? ?VMContext.getConstantInt(Type::Int32Ty, Flags), > + ? ?VMContext.getConstantInt(Type::Int32Ty, Encoding) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? M.addTypeName("llvm.dbg.basictype.type", Init->getType()); > ? GlobalVariable *GV = new GlobalVariable(Init->getType(), true, > @@ -650,15 +656,16 @@ > ? ? getCastToEmpty(Context), > ? ? GetStringConstant(Name), > ? ? getCastToEmpty(CompileUnit), > - ? ?ConstantInt::get(Type::Int32Ty, LineNumber), > - ? ?ConstantInt::get(Type::Int64Ty, SizeInBits), > - ? ?ConstantInt::get(Type::Int64Ty, AlignInBits), > - ? ?ConstantInt::get(Type::Int64Ty, OffsetInBits), > - ? ?ConstantInt::get(Type::Int32Ty, Flags), > + ? ?VMContext.getConstantInt(Type::Int32Ty, LineNumber), > + ? ?VMContext.getConstantInt(Type::Int64Ty, SizeInBits), > + ? ?VMContext.getConstantInt(Type::Int64Ty, AlignInBits), > + ? ?VMContext.getConstantInt(Type::Int64Ty, OffsetInBits), > + ? ?VMContext.getConstantInt(Type::Int32Ty, Flags), > ? ? getCastToEmpty(DerivedFrom) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? M.addTypeName("llvm.dbg.derivedtype.type", Init->getType()); > ? GlobalVariable *GV = new GlobalVariable(Init->getType(), true, > @@ -687,17 +694,18 @@ > ? ? getCastToEmpty(Context), > ? ? GetStringConstant(Name), > ? ? getCastToEmpty(CompileUnit), > - ? ?ConstantInt::get(Type::Int32Ty, LineNumber), > - ? ?ConstantInt::get(Type::Int64Ty, SizeInBits), > - ? ?ConstantInt::get(Type::Int64Ty, AlignInBits), > - ? ?ConstantInt::get(Type::Int64Ty, OffsetInBits), > - ? ?ConstantInt::get(Type::Int32Ty, Flags), > + ? ?VMContext.getConstantInt(Type::Int32Ty, LineNumber), > + ? ?VMContext.getConstantInt(Type::Int64Ty, SizeInBits), > + ? ?VMContext.getConstantInt(Type::Int64Ty, AlignInBits), > + ? ?VMContext.getConstantInt(Type::Int64Ty, OffsetInBits), > + ? ?VMContext.getConstantInt(Type::Int32Ty, Flags), > ? ? getCastToEmpty(DerivedFrom), > ? ? getCastToEmpty(Elements), > - ? ?ConstantInt::get(Type::Int32Ty, RuntimeLang) > + ? ?VMContext.getConstantInt(Type::Int32Ty, RuntimeLang) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? M.addTypeName("llvm.dbg.composite.type", Init->getType()); > ? GlobalVariable *GV = new GlobalVariable(Init->getType(), true, > @@ -722,19 +730,20 @@ > > ? Constant *Elts[] = { > ? ? GetTagConstant(dwarf::DW_TAG_subprogram), > - ? ?Constant::getNullValue(EmptyStructPtr), > + ? ?VMContext.getNullValue(EmptyStructPtr), > ? ? getCastToEmpty(Context), > ? ? GetStringConstant(Name), > ? ? GetStringConstant(DisplayName), > ? ? GetStringConstant(LinkageName), > ? ? getCastToEmpty(CompileUnit), > - ? ?ConstantInt::get(Type::Int32Ty, LineNo), > + ? ?VMContext.getConstantInt(Type::Int32Ty, LineNo), > ? ? getCastToEmpty(Type), > - ? ?ConstantInt::get(Type::Int1Ty, isLocalToUnit), > - ? ?ConstantInt::get(Type::Int1Ty, isDefinition) > + ? ?VMContext.getConstantInt(Type::Int1Ty, isLocalToUnit), > + ? ?VMContext.getConstantInt(Type::Int1Ty, isDefinition) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? M.addTypeName("llvm.dbg.subprogram.type", Init->getType()); > ? GlobalVariable *GV = new GlobalVariable(Init->getType(), true, > @@ -754,20 +763,21 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool isDefinition, llvm::GlobalVariable *Val) { > ? Constant *Elts[] = { > ? ? GetTagConstant(dwarf::DW_TAG_variable), > - ? ?Constant::getNullValue(EmptyStructPtr), > + ? ?VMContext.getNullValue(EmptyStructPtr), > ? ? getCastToEmpty(Context), > ? ? GetStringConstant(Name), > ? ? GetStringConstant(DisplayName), > ? ? GetStringConstant(LinkageName), > ? ? getCastToEmpty(CompileUnit), > - ? ?ConstantInt::get(Type::Int32Ty, LineNo), > + ? ?VMContext.getConstantInt(Type::Int32Ty, LineNo), > ? ? getCastToEmpty(Type), > - ? ?ConstantInt::get(Type::Int1Ty, isLocalToUnit), > - ? ?ConstantInt::get(Type::Int1Ty, isDefinition), > - ? ?ConstantExpr::getBitCast(Val, EmptyStructPtr) > + ? ?VMContext.getConstantInt(Type::Int1Ty, isLocalToUnit), > + ? ?VMContext.getConstantInt(Type::Int1Ty, isDefinition), > + ? ?VMContext.getConstantExprBitCast(Val, EmptyStructPtr) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? M.addTypeName("llvm.dbg.global_variable.type", Init->getType()); > ? GlobalVariable *GV = new GlobalVariable(Init->getType(), true, > @@ -788,11 +798,12 @@ > ? ? getCastToEmpty(Context), > ? ? GetStringConstant(Name), > ? ? getCastToEmpty(CompileUnit), > - ? ?ConstantInt::get(Type::Int32Ty, LineNo), > + ? ?VMContext.getConstantInt(Type::Int32Ty, LineNo), > ? ? getCastToEmpty(Type) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? M.addTypeName("llvm.dbg.variable.type", Init->getType()); > ? GlobalVariable *GV = new GlobalVariable(Init->getType(), true, > @@ -804,14 +815,15 @@ > > > ?/// CreateBlock - This creates a descriptor for a lexical block with the > -/// specified parent context. > +/// specified parent VMContext. > ?DIBlock DIFactory::CreateBlock(DIDescriptor Context) { > ? Constant *Elts[] = { > ? ? GetTagConstant(dwarf::DW_TAG_lexical_block), > ? ? getCastToEmpty(Context) > ? }; > > - ?Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0])); > + ?Constant *Init = VMContext.getConstantStruct(Elts, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(Elts)/sizeof(Elts[0])); > > ? M.addTypeName("llvm.dbg.block.type", Init->getType()); > ? GlobalVariable *GV = new GlobalVariable(Init->getType(), true, > @@ -838,8 +850,8 @@ > > ? // Invoke llvm.dbg.stoppoint > ? Value *Args[] = { > - ? ?llvm::ConstantInt::get(llvm::Type::Int32Ty, LineNo), > - ? ?llvm::ConstantInt::get(llvm::Type::Int32Ty, ColNo), > + ? ?VMContext.getConstantInt(llvm::Type::Int32Ty, LineNo), > + ? ?VMContext.getConstantInt(llvm::Type::Int32Ty, ColNo), > ? ? getCastToEmpty(CU) > ? }; > ? CallInst::Create(StopPointFn, Args, Args+3, "", BB); > @@ -939,10 +951,12 @@ > > ? Value *findDbgGlobalDeclare(GlobalVariable *V) { > ? ? const Module *M = V->getParent(); > + ? ?LLVMContext& Context = M->getContext(); > + > ? ? const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type"); > ? ? if (!Ty) return 0; > > - ? ?Ty = PointerType::get(Ty, 0); > + ? ?Ty = Context.getPointerType(Ty, 0); > > ? ? Value *Val = V->stripPointerCasts(); > ? ? for (Value::use_iterator I = Val->use_begin(), E = Val->use_end(); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- - Devang From mrs at apple.com Tue Jul 7 13:52:17 2009 From: mrs at apple.com (Mike Stump) Date: Tue, 07 Jul 2009 18:52:17 -0000 Subject: [llvm-commits] [llvm] r74936 - /llvm/trunk/lib/Support/CMakeLists.txt Message-ID: <200907071852.n67IqHFt025917@zion.cs.uiuc.edu> Author: mrs Date: Tue Jul 7 13:52:14 2009 New Revision: 74936 URL: http://llvm.org/viewvc/llvm-project?rev=74936&view=rev Log: Fix build. Modified: llvm/trunk/lib/Support/CMakeLists.txt Modified: llvm/trunk/lib/Support/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=74936&r1=74935&r2=74936&view=diff ============================================================================== --- llvm/trunk/lib/Support/CMakeLists.txt (original) +++ llvm/trunk/lib/Support/CMakeLists.txt Tue Jul 7 13:52:14 2009 @@ -8,6 +8,7 @@ ConstantRange.cpp Debug.cpp Dwarf.cpp + ErrorHandling.cpp FileUtilities.cpp FoldingSet.cpp GraphWriter.cpp From devang.patel at gmail.com Tue Jul 7 13:54:35 2009 From: devang.patel at gmail.com (Devang Patel) Date: Tue, 7 Jul 2009 11:54:35 -0700 Subject: [llvm-commits] [llvm] r74883 - /llvm/trunk/include/llvm/CodeGen/MachineOperand.h In-Reply-To: <40BDA519-E5B7-4081-A095-6A5C6739D661@apple.com> References: <200907062346.n66Nk4Zo009321@zion.cs.uiuc.edu> <352a1fb20907061834m1e2f102m851dc27d592105d1@mail.gmail.com> <40BDA519-E5B7-4081-A095-6A5C6739D661@apple.com> Message-ID: <352a1fb20907071154w588690beka08df3261e3bb91e@mail.gmail.com> Chris, On Mon, Jul 6, 2009 at 9:37 PM, Chris Lattner wrote: > > On Jul 6, 2009, at 6:34 PM, Devang Patel wrote: > >> Chris, >> >> On Mon, Jul 6, 2009 at 6:09 PM, Chris Lattner >> wrote: >>> >>> On Jul 6, 2009, at 4:46 PM, Devang Patel wrote: >>> >>>> Author: dpatel >>>> Date: Mon Jul ?6 18:46:02 2009 >>>> New Revision: 74883 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=74883&view=rev >>>> Log: >>>> Add isMetadata() to check metadata operand. >>> >>> Hey Devang, >>> >>> What is your plan to use MetaData MachineInstr operands? ?Can you >>> elaborate on how you plan to use these? >> >> My near term goal is to replace all Global Variables used to encode >> debug info (llvm.dbg.*) by MDNodes. As a step towards this goal, I >> need MetaData as machine instruction operand to handle printDeclare(). > > Do we really want to propagate llvm.declare intrinsics into > machineinstrs? No. The question was "now or later " ? I'll fix it now :) >?Why not have ISel tag the stack slot with the MDNode > instead of lowering to a machineinstr? - Devang From edwintorok at gmail.com Tue Jul 7 13:54:34 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Tue, 07 Jul 2009 21:54:34 +0300 Subject: [llvm-commits] [llvm] r74936 - /llvm/trunk/lib/Support/CMakeLists.txt In-Reply-To: <200907071852.n67IqHFt025917@zion.cs.uiuc.edu> References: <200907071852.n67IqHFt025917@zion.cs.uiuc.edu> Message-ID: <4A5399EA.1000704@gmail.com> On 2009-07-07 21:52, Mike Stump wrote: > Author: mrs > Date: Tue Jul 7 13:52:14 2009 > New Revision: 74936 > > URL: http://llvm.org/viewvc/llvm-project?rev=74936&view=rev > Log: > Fix build. > > Thanks, I forgot that CMake needs to be told about new files. Best regards, --Edwin From evan.cheng at apple.com Tue Jul 7 14:16:57 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Jul 2009 19:16:57 -0000 Subject: [llvm-commits] [llvm] r74938 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <200907071917.n67JH4J3026913@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jul 7 14:16:24 2009 New Revision: 74938 URL: http://llvm.org/viewvc/llvm-project?rev=74938&view=rev Log: Add BX and BXr9 encodings. Patch by Sean Callanan. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=74938&r1=74937&r2=74938&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Jul 7 14:16:24 2009 @@ -618,7 +618,11 @@ // ARMv4T def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops), "mov lr, pc\n\tbx $func", - [(ARMcall_nolink GPR:$func)]>, Requires<[IsNotDarwin]>; + [(ARMcall_nolink GPR:$func)]>, Requires<[IsNotDarwin]> { + let Inst{7-4} = 0b0001; + let Inst{19-8} = 0b111111111111; + let Inst{27-20} = 0b00010010; + } } } @@ -647,7 +651,11 @@ // ARMv4T def BXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops), "mov lr, pc\n\tbx $func", - [(ARMcall_nolink GPR:$func)]>, Requires<[IsDarwin]>; + [(ARMcall_nolink GPR:$func)]>, Requires<[IsDarwin]> { + let Inst{7-4} = 0b0001; + let Inst{19-8} = 0b111111111111; + let Inst{27-20} = 0b00010010; + } } } From mrs at apple.com Tue Jul 7 14:37:32 2009 From: mrs at apple.com (Mike Stump) Date: Tue, 7 Jul 2009 12:37:32 -0700 Subject: [llvm-commits] [llvm] r74936 - /llvm/trunk/lib/Support/CMakeLists.txt In-Reply-To: <4A5399EA.1000704@gmail.com> References: <200907071852.n67IqHFt025917@zion.cs.uiuc.edu> <4A5399EA.1000704@gmail.com> Message-ID: On Jul 7, 2009, at 11:54 AM, T?r?k Edwin wrote: > On 2009-07-07 21:52, Mike Stump wrote: >> URL: http://llvm.org/viewvc/llvm-project?rev=74936&view=rev >> Log: >> Fix build. > > Thanks, I forgot that CMake needs to be told about new files. We could do *.cpp in there... In some respects, this would promote a cleaner code... From mai4 at uiuc.edu Tue Jul 7 14:58:03 2009 From: mai4 at uiuc.edu (Haohui Mai) Date: Tue, 07 Jul 2009 19:58:03 -0000 Subject: [llvm-commits] [poolalloc] r74939 - in /poolalloc/trunk/lib/PoolAllocate: PAMultipleGlobalPool.cpp PASimple.cpp Message-ID: <200907071958.n67Jw5g4028267@zion.cs.uiuc.edu> Author: mai4 Date: Tue Jul 7 14:57:47 2009 New Revision: 74939 URL: http://llvm.org/viewvc/llvm-project?rev=74939&view=rev Log: Rename poolalloc.init into __poolalloc_init and mark them as external linkage to make sure clients can call them. Modified: poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Modified: poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp?rev=74939&r1=74938&r2=74939&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp Tue Jul 7 14:57:47 2009 @@ -98,7 +98,7 @@ // clones. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { std::string name = I->getName(); - if (name == "poolalloc.init") continue; + if (name == "__poolalloc_init") continue; if (!(I->isDeclaration())) ProcessFunctionBodySimple(*I, TD); } @@ -308,7 +308,7 @@ Function *InitFunc = Function::Create (FunctionType::get(Type::VoidTy, std::vector(), false), - GlobalValue::InternalLinkage, "poolalloc.init", &M); + GlobalValue::ExternalLinkage, "__poolalloc_init", &M); BasicBlock * BB = BasicBlock::Create("entry", InitFunc); Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=74939&r1=74938&r2=74939&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Tue Jul 7 14:57:47 2009 @@ -139,7 +139,7 @@ // clones. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { std::string name = I->getName(); - if (name == "poolalloc.init") continue; + if (name == "__poolalloc_init") continue; if (!(I->isDeclaration())) ProcessFunctionBodySimple(*I, TD); } @@ -359,7 +359,7 @@ Function *InitFunc = Function::Create (FunctionType::get(Type::VoidTy, std::vector(), false), - GlobalValue::InternalLinkage, "poolalloc.init", &M); + GlobalValue::ExternalLinkage, "__poolalloc_init", &M); BasicBlock * BB = BasicBlock::Create("entry", InitFunc); Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize); From mai4 at uiuc.edu Tue Jul 7 14:59:08 2009 From: mai4 at uiuc.edu (Haohui Mai) Date: Tue, 07 Jul 2009 19:59:08 -0000 Subject: [llvm-commits] [poolalloc] r74940 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/Steensgaard.cpp Message-ID: <200907071959.n67Jx8X4028306@zion.cs.uiuc.edu> Author: mai4 Date: Tue Jul 7 14:59:07 2009 New Revision: 74940 URL: http://llvm.org/viewvc/llvm-project?rev=74940&view=rev Log: Bug fix on handling globals graph. Modified: poolalloc/trunk/include/dsa/DataStructure.h poolalloc/trunk/lib/DSA/Steensgaard.cpp Modified: poolalloc/trunk/include/dsa/DataStructure.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=74940&r1=74939&r2=74940&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DataStructure.h (original) +++ poolalloc/trunk/include/dsa/DataStructure.h Tue Jul 7 14:59:07 2009 @@ -430,6 +430,7 @@ virtual void releaseMemory(); virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); AU.addRequired(); AU.setPreservesAll(); } Modified: poolalloc/trunk/lib/DSA/Steensgaard.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Steensgaard.cpp?rev=74940&r1=74939&r2=74940&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Steensgaard.cpp (original) +++ poolalloc/trunk/lib/DSA/Steensgaard.cpp Tue Jul 7 14:59:07 2009 @@ -27,10 +27,10 @@ void SteensgaardDataStructures::releaseMemory() { - // Here we don't need to delete the result graph, because it aliases with the - // GlobalsGraph, which is deleted by DataStructures::releaseMemory(). + // Here we don't need to delete the result graph, because it aliases with the + // GlobalsGraph, which is deleted by DataStructures::releaseMemory(). ResultGraph = 0; - DataStructures::releaseMemory(); + DataStructures::releaseMemory(); } // print - Implement the Pass::print method... @@ -51,17 +51,23 @@ bool SteensgaardDataStructures::runOnModule(Module &M) { DS = &getAnalysis(); + init(&getAnalysis()); return runOnModuleInternal(M); } bool SteensgaardDataStructures::runOnModuleInternal(Module &M) { assert(ResultGraph == 0 && "Result graph already allocated!"); + // Create a new, empty, graph... ResultGraph = new DSGraph(GlobalECs, getTargetData()); + ResultGraph->setGlobalsGraph(ResultGraph); ResultGraph->spliceFrom(DS->getGlobalsGraph()); + // Assign the result graph to globals graph. It should be the same. + GlobalsGraph = ResultGraph; + // Loop over the rest of the module, merging graphs for non-external functions // into this graph. // @@ -130,10 +136,8 @@ // Remove any nodes that are dead after all of the merging we have done... // FIXME: We should be able to disable the globals graph for steens! - ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals); + // ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals); - // Assign the result graph to globals graph. It should be the same. - GlobalsGraph = ResultGraph; print(DOUT, &M); return false; } From gohman at apple.com Tue Jul 7 15:05:34 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 07 Jul 2009 20:05:34 -0000 Subject: [llvm-commits] [llvm] r74941 - /llvm/trunk/docs/ReleaseNotes-2.6.html Message-ID: <200907072005.n67K5Zpr028923@zion.cs.uiuc.edu> Author: djg Date: Tue Jul 7 15:05:15 2009 New Revision: 74941 URL: http://llvm.org/viewvc/llvm-project?rev=74941&view=rev Log: Add a paragraph about the Add->FAdd API change. Modified: llvm/trunk/docs/ReleaseNotes-2.6.html Modified: llvm/trunk/docs/ReleaseNotes-2.6.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes-2.6.html?rev=74941&r1=74940&r2=74941&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes-2.6.html (original) +++ llvm/trunk/docs/ReleaseNotes-2.6.html Tue Jul 7 15:05:15 2009 @@ -441,6 +441,14 @@ context which can be passed in any and all cases where a context is required.
  • The getABITypeSize methods are now called getAllocSize.
  • +
  • The Add, Sub, and Mul operators are no longer + overloaded for floating-point types. Floating-point addition, subtraction, + and multiplication are now represented with new operators FAdd, + FSub, and FMul. In the IRBuilder API, + CreateAdd, CreateSub, CreateMul, and + CreateNeg should only be used for integer arithmetic now; + CreateFAdd, CreateFSub, CreateFMul, and + CreateFNeg should now be used for floating-point arithmetic.
  • From clattner at apple.com Tue Jul 7 15:11:29 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 13:11:29 -0700 Subject: [llvm-commits] [llvm] r74929 - /llvm/trunk/include/llvm/CodeGen/BinaryObject.h In-Reply-To: References: <200907071828.n67ISaxY024878@zion.cs.uiuc.edu> Message-ID: <9AB82B78-CBF9-403F-8292-8805B8AA52DA@apple.com> On Jul 7, 2009, at 11:35 AM, Misha Brukman wrote: > 2009/7/7 Chris Lattner > - Data.push_back((W >> 0) & 255); > - Data.push_back((W >> 8) & 255); > + Data.push_back((uint8_t)(W >> 0)); > + Data.push_back((uint8_t)(W >> 8)); > > These are all C-style casts, rather than C++-style casts, e.g. > static_cast(value) . > Is there a preference for C-style casts in LLVM? I thought we were > trying to stick with C++ here. We don't use one consistently over the other. I don't think there is a clear win to using c++ style casts here, in the sense that they don't add any value. OTOH, for const_cast, I think that using the c++ style cast makes the intention more clear. -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090707/63e0a903/attachment.html From clattner at apple.com Tue Jul 7 15:16:06 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 13:16:06 -0700 Subject: [llvm-commits] PATCH: remove VICmp and VFCmp. In-Reply-To: <05085D11-65C9-478A-B854-1EAC52FD9E42@apple.com> References: <4A518899.80806@mxc.ca> <7ABB6DFD-7F2E-4F31-A7D9-FC86362095E6@apple.com> <05085D11-65C9-478A-B854-1EAC52FD9E42@apple.com> Message-ID: On Jul 7, 2009, at 11:30 AM, Dan Gohman wrote: > On Jul 6, 2009, at 10:10 AM, Chris Lattner wrote: > On Jul 5, 2009, at 10:16 PM, Nick Lewycky wrote: >>> This patch removes vicmp and vfcmp, which has the positive side that >>> >>> it fixes existing type-safety bugs and simplifies some code, but a >>> >>> downside in that it XFAILs 9 CodeGen tests. >>> >> >> I haven't had a chance to look at the patch, but removing v[fi]cmp >> will almost certainly break clang (which generates them for vector >> comparisons in opencl/ext_vector mode). The right way to remove this >> is to make codegen pattern match [fi]cmp+sext to the same nodes it is >> using for v[fi]cmp, then change clang to generate [fi]cmp+sext >> instead >> of v[if]cmp, then nuke v[fi]cmp. This way we won't loose any codegen >> capability and clang will still build :). > > Vector [fi]cmp are not yet ready to replace v[fi]cmp, and there's > more work required than just adding patterns. > > Work has been one to support vector [fi]cmp in the IR, however no > work has been done to support it in CodeGen yet. Adding support in > CodeGen will require a variety of fairly straight-forward > changes, plus finding a solution for vectors of i1 in CodeGen. I don't see a need to fix the "vector of i1" issue right now. In fact, I don't see an issue at all. There are two things we care about: making compare+sext turn into the current nice code that v*cmp produces, and eventually handling compare +select. Both of these idioms are trivial enough that they could be handled by pre-legalize dag combine, forming (e.g.) ISD::VSETCC nodes. Then legalize won't ever see vectors of i1 in code that we care about. -Chris From resistor at mac.com Tue Jul 7 15:19:10 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Jul 2009 20:19:10 -0000 Subject: [llvm-commits] [llvm] r74942 - in /llvm/trunk/lib/Bitcode/Reader: BitcodeReader.cpp BitcodeReader.h Message-ID: <200907072019.n67KJB4e029461@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 15:18:58 2009 New Revision: 74942 URL: http://llvm.org/viewvc/llvm-project?rev=74942&view=rev Log: LLVMContext-ify the bitcode reader. Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=74942&r1=74941&r2=74942&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jul 7 15:18:58 2009 @@ -17,6 +17,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/InlineAsm.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/MDNode.h" #include "llvm/Module.h" #include "llvm/AutoUpgrade.h" @@ -137,9 +138,9 @@ void *operator new(size_t s) { return User::operator new(s, 1); } - explicit ConstantPlaceHolder(const Type *Ty) + explicit ConstantPlaceHolder(const Type *Ty, LLVMContext& Context) : ConstantExpr(Ty, Instruction::UserOp1, &Op<0>(), 1) { - Op<0>() = UndefValue::get(Type::Int32Ty); + Op<0>() = Context.getUndef(Type::Int32Ty); } /// @brief Methods to support type inquiry through isa, cast, and dyn_cast. @@ -202,7 +203,7 @@ } // Create and return a placeholder, which will later be RAUW'd. - Constant *C = new ConstantPlaceHolder(Ty); + Constant *C = new ConstantPlaceHolder(Ty, Context); ValuePtrs[Idx] = C; return C; } @@ -285,12 +286,13 @@ // Make the new constant. Constant *NewC; if (ConstantArray *UserCA = dyn_cast(UserC)) { - NewC = ConstantArray::get(UserCA->getType(), &NewOps[0], NewOps.size()); + NewC = Context.getConstantArray(UserCA->getType(), &NewOps[0], + NewOps.size()); } else if (ConstantStruct *UserCS = dyn_cast(UserC)) { - NewC = ConstantStruct::get(&NewOps[0], NewOps.size(), - UserCS->getType()->isPacked()); + NewC = Context.getConstantStruct(&NewOps[0], NewOps.size(), + UserCS->getType()->isPacked()); } else if (isa(UserC)) { - NewC = ConstantVector::get(&NewOps[0], NewOps.size()); + NewC = Context.getConstantVector(&NewOps[0], NewOps.size()); } else { assert(isa(UserC) && "Must be a ConstantExpr."); NewC = cast(UserC)->getWithOperands(&NewOps[0], @@ -318,7 +320,7 @@ // The type table allows forward references. Push as many Opaque types as // needed to get up to ID. while (TypeList.size() <= ID) - TypeList.push_back(OpaqueType::get()); + TypeList.push_back(Context.getOpaqueType()); return TypeList.back().get(); } @@ -508,7 +510,7 @@ if (Record.size() < 1) return Error("Invalid Integer type record"); - ResultTy = IntegerType::get(Record[0]); + ResultTy = Context.getIntegerType(Record[0]); break; case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or // [pointee type, address space] @@ -517,7 +519,8 @@ unsigned AddressSpace = 0; if (Record.size() == 2) AddressSpace = Record[1]; - ResultTy = PointerType::get(getTypeByID(Record[0], true), AddressSpace); + ResultTy = Context.getPointerType(getTypeByID(Record[0], true), + AddressSpace); break; } case bitc::TYPE_CODE_FUNCTION: { @@ -529,7 +532,7 @@ for (unsigned i = 3, e = Record.size(); i != e; ++i) ArgTys.push_back(getTypeByID(Record[i], true)); - ResultTy = FunctionType::get(getTypeByID(Record[2], true), ArgTys, + ResultTy = Context.getFunctionType(getTypeByID(Record[2], true), ArgTys, Record[0]); break; } @@ -539,24 +542,24 @@ std::vector EltTys; for (unsigned i = 1, e = Record.size(); i != e; ++i) EltTys.push_back(getTypeByID(Record[i], true)); - ResultTy = StructType::get(EltTys, Record[0]); + ResultTy = Context.getStructType(EltTys, Record[0]); break; } case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty] if (Record.size() < 2) return Error("Invalid ARRAY type record"); - ResultTy = ArrayType::get(getTypeByID(Record[1], true), Record[0]); + ResultTy = Context.getArrayType(getTypeByID(Record[1], true), Record[0]); break; case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty] if (Record.size() < 2) return Error("Invalid VECTOR type record"); - ResultTy = VectorType::get(getTypeByID(Record[1], true), Record[0]); + ResultTy = Context.getVectorType(getTypeByID(Record[1], true), Record[0]); break; } if (NumRecords == TypeList.size()) { // If this is a new type slot, just append it. - TypeList.push_back(ResultTy ? ResultTy : OpaqueType::get()); + TypeList.push_back(ResultTy ? ResultTy : Context.getOpaqueType()); ++NumRecords; } else if (ResultTy == 0) { // Otherwise, this was forward referenced, so an opaque type was created, @@ -777,7 +780,7 @@ switch (Stream.ReadRecord(Code, Record)) { default: // Default behavior: unknown constant case bitc::CST_CODE_UNDEF: // UNDEF - V = UndefValue::get(CurTy); + V = Context.getUndef(CurTy); break; case bitc::CST_CODE_SETTYPE: // SETTYPE: [typeid] if (Record.empty()) @@ -787,12 +790,12 @@ CurTy = TypeList[Record[0]]; continue; // Skip the ValueList manipulation. case bitc::CST_CODE_NULL: // NULL - V = Constant::getNullValue(CurTy); + V = Context.getNullValue(CurTy); break; case bitc::CST_CODE_INTEGER: // INTEGER: [intval] if (!isa(CurTy) || Record.empty()) return Error("Invalid CST_INTEGER record"); - V = ConstantInt::get(CurTy, DecodeSignRotatedValue(Record[0])); + V = Context.getConstantInt(CurTy, DecodeSignRotatedValue(Record[0])); break; case bitc::CST_CODE_WIDE_INTEGER: {// WIDE_INTEGER: [n x intval] if (!isa(CurTy) || Record.empty()) @@ -803,7 +806,7 @@ Words.resize(NumWords); for (unsigned i = 0; i != NumWords; ++i) Words[i] = DecodeSignRotatedValue(Record[i]); - V = ConstantInt::get(APInt(cast(CurTy)->getBitWidth(), + V = Context.getConstantInt(APInt(cast(CurTy)->getBitWidth(), NumWords, &Words[0])); break; } @@ -811,21 +814,21 @@ if (Record.empty()) return Error("Invalid FLOAT record"); if (CurTy == Type::FloatTy) - V = ConstantFP::get(APFloat(APInt(32, (uint32_t)Record[0]))); + V = Context.getConstantFP(APFloat(APInt(32, (uint32_t)Record[0]))); else if (CurTy == Type::DoubleTy) - V = ConstantFP::get(APFloat(APInt(64, Record[0]))); + V = Context.getConstantFP(APFloat(APInt(64, Record[0]))); else if (CurTy == Type::X86_FP80Ty) { // Bits are not stored the same way as a normal i80 APInt, compensate. uint64_t Rearrange[2]; Rearrange[0] = (Record[1] & 0xffffLL) | (Record[0] << 16); Rearrange[1] = Record[0] >> 48; - V = ConstantFP::get(APFloat(APInt(80, 2, Rearrange))); + V = Context.getConstantFP(APFloat(APInt(80, 2, Rearrange))); } else if (CurTy == Type::FP128Ty) - V = ConstantFP::get(APFloat(APInt(128, 2, &Record[0]), true)); + V = Context.getConstantFP(APFloat(APInt(128, 2, &Record[0]), true)); else if (CurTy == Type::PPC_FP128Ty) - V = ConstantFP::get(APFloat(APInt(128, 2, &Record[0]))); + V = Context.getConstantFP(APFloat(APInt(128, 2, &Record[0]))); else - V = UndefValue::get(CurTy); + V = Context.getUndef(CurTy); break; } @@ -840,19 +843,19 @@ for (unsigned i = 0; i != Size; ++i) Elts.push_back(ValueList.getConstantFwdRef(Record[i], STy->getElementType(i))); - V = ConstantStruct::get(STy, Elts); + V = Context.getConstantStruct(STy, Elts); } else if (const ArrayType *ATy = dyn_cast(CurTy)) { const Type *EltTy = ATy->getElementType(); for (unsigned i = 0; i != Size; ++i) Elts.push_back(ValueList.getConstantFwdRef(Record[i], EltTy)); - V = ConstantArray::get(ATy, Elts); + V = Context.getConstantArray(ATy, Elts); } else if (const VectorType *VTy = dyn_cast(CurTy)) { const Type *EltTy = VTy->getElementType(); for (unsigned i = 0; i != Size; ++i) Elts.push_back(ValueList.getConstantFwdRef(Record[i], EltTy)); - V = ConstantVector::get(Elts); + V = Context.getConstantVector(Elts); } else { - V = UndefValue::get(CurTy); + V = Context.getUndef(CurTy); } break; } @@ -866,8 +869,8 @@ unsigned Size = Record.size(); std::vector Elts; for (unsigned i = 0; i != Size; ++i) - Elts.push_back(ConstantInt::get(EltTy, Record[i])); - V = ConstantArray::get(ATy, Elts); + Elts.push_back(Context.getConstantInt(EltTy, Record[i])); + V = Context.getConstantArray(ATy, Elts); break; } case bitc::CST_CODE_CSTRING: { // CSTRING: [values] @@ -880,20 +883,20 @@ unsigned Size = Record.size(); std::vector Elts; for (unsigned i = 0; i != Size; ++i) - Elts.push_back(ConstantInt::get(EltTy, Record[i])); - Elts.push_back(Constant::getNullValue(EltTy)); - V = ConstantArray::get(ATy, Elts); + Elts.push_back(Context.getConstantInt(EltTy, Record[i])); + Elts.push_back(Context.getNullValue(EltTy)); + V = Context.getConstantArray(ATy, Elts); break; } case bitc::CST_CODE_CE_BINOP: { // CE_BINOP: [opcode, opval, opval] if (Record.size() < 3) return Error("Invalid CE_BINOP record"); int Opc = GetDecodedBinaryOpcode(Record[0], CurTy); if (Opc < 0) { - V = UndefValue::get(CurTy); // Unknown binop. + V = Context.getUndef(CurTy); // Unknown binop. } else { Constant *LHS = ValueList.getConstantFwdRef(Record[1], CurTy); Constant *RHS = ValueList.getConstantFwdRef(Record[2], CurTy); - V = ConstantExpr::get(Opc, LHS, RHS); + V = Context.getConstantExpr(Opc, LHS, RHS); } break; } @@ -901,12 +904,12 @@ if (Record.size() < 3) return Error("Invalid CE_CAST record"); int Opc = GetDecodedCastOpcode(Record[0]); if (Opc < 0) { - V = UndefValue::get(CurTy); // Unknown cast. + V = Context.getUndef(CurTy); // Unknown cast. } else { const Type *OpTy = getTypeByID(Record[1]); if (!OpTy) return Error("Invalid CE_CAST record"); Constant *Op = ValueList.getConstantFwdRef(Record[2], OpTy); - V = ConstantExpr::getCast(Opc, Op, CurTy); + V = Context.getConstantExprCast(Opc, Op, CurTy); } break; } @@ -918,12 +921,13 @@ if (!ElTy) return Error("Invalid CE_GEP record"); Elts.push_back(ValueList.getConstantFwdRef(Record[i+1], ElTy)); } - V = ConstantExpr::getGetElementPtr(Elts[0], &Elts[1], Elts.size()-1); + V = Context.getConstantExprGetElementPtr(Elts[0], &Elts[1], + Elts.size()-1); break; } case bitc::CST_CODE_CE_SELECT: // CE_SELECT: [opval#, opval#, opval#] if (Record.size() < 3) return Error("Invalid CE_SELECT record"); - V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0], + V = Context.getConstantExprSelect(ValueList.getConstantFwdRef(Record[0], Type::Int1Ty), ValueList.getConstantFwdRef(Record[1],CurTy), ValueList.getConstantFwdRef(Record[2],CurTy)); @@ -935,7 +939,7 @@ if (OpTy == 0) return Error("Invalid CE_EXTRACTELT record"); Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[2], Type::Int32Ty); - V = ConstantExpr::getExtractElement(Op0, Op1); + V = Context.getConstantExprExtractElement(Op0, Op1); break; } case bitc::CST_CODE_CE_INSERTELT: { // CE_INSERTELT: [opval, opval, opval] @@ -946,7 +950,7 @@ Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy->getElementType()); Constant *Op2 = ValueList.getConstantFwdRef(Record[2], Type::Int32Ty); - V = ConstantExpr::getInsertElement(Op0, Op1, Op2); + V = Context.getConstantExprInsertElement(Op0, Op1, Op2); break; } case bitc::CST_CODE_CE_SHUFFLEVEC: { // CE_SHUFFLEVEC: [opval, opval, opval] @@ -955,9 +959,10 @@ return Error("Invalid CE_SHUFFLEVEC record"); Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy); - const Type *ShufTy=VectorType::get(Type::Int32Ty, OpTy->getNumElements()); + const Type *ShufTy = Context.getVectorType(Type::Int32Ty, + OpTy->getNumElements()); Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy); - V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); + V = Context.getConstantExprShuffleVector(Op0, Op1, Op2); break; } case bitc::CST_CODE_CE_SHUFVEC_EX: { // [opty, opval, opval, opval] @@ -967,9 +972,10 @@ return Error("Invalid CE_SHUFVEC_EX record"); Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy); - const Type *ShufTy=VectorType::get(Type::Int32Ty, RTy->getNumElements()); + const Type *ShufTy = Context.getVectorType(Type::Int32Ty, + RTy->getNumElements()); Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy); - V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); + V = Context.getConstantExprShuffleVector(Op0, Op1, Op2); break; } case bitc::CST_CODE_CE_CMP: { // CE_CMP: [opty, opval, opval, pred] @@ -980,13 +986,13 @@ Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy); if (OpTy->isFloatingPoint()) - V = ConstantExpr::getFCmp(Record[3], Op0, Op1); + V = Context.getConstantExprFCmp(Record[3], Op0, Op1); else if (!isa(OpTy)) - V = ConstantExpr::getICmp(Record[3], Op0, Op1); + V = Context.getConstantExprICmp(Record[3], Op0, Op1); else if (OpTy->isFPOrFPVector()) - V = ConstantExpr::getVFCmp(Record[3], Op0, Op1); + V = Context.getConstantExprVFCmp(Record[3], Op0, Op1); else - V = ConstantExpr::getVICmp(Record[3], Op0, Op1); + V = Context.getConstantExprVICmp(Record[3], Op0, Op1); break; } case bitc::CST_CODE_INLINEASM: { @@ -1015,7 +1021,7 @@ String.resize(MDStringLength); for (unsigned i = 0; i != MDStringLength; ++i) String[i] = Record[i]; - V = MDString::get(String.c_str(), String.c_str() + MDStringLength); + V = Context.getMDString(String.c_str(), String.c_str() + MDStringLength); break; } case bitc::CST_CODE_MDNODE: { @@ -1031,7 +1037,7 @@ else Elts.push_back(NULL); } - V = MDNode::get(&Elts[0], Elts.size()); + V = Context.getMDNode(&Elts[0], Elts.size()); break; } } @@ -1693,7 +1699,7 @@ if (Vs.size() > 1 || (isa(ReturnType) && (Vs.empty() || Vs[0]->getType() != ReturnType))) { - Value *RV = UndefValue::get(ReturnType); + Value *RV = Context.getUndef(ReturnType); for (unsigned i = 0, e = Vs.size(); i != e; ++i) { I = InsertValueInst::Create(RV, Vs[i], i, "mrv"); CurBB->getInstList().push_back(I); @@ -1879,7 +1885,8 @@ unsigned OpNum = 0; Value *Val, *Ptr; if (getValueTypePair(Record, OpNum, NextValueNo, Val) || - getValue(Record, OpNum, PointerType::getUnqual(Val->getType()), Ptr)|| + getValue(Record, OpNum, + Context.getPointerTypeUnqual(Val->getType()), Ptr)|| OpNum+2 != Record.size()) return Error("Invalid STORE record"); @@ -1972,7 +1979,7 @@ // We found at least one unresolved value. Nuke them all to avoid leaks. for (unsigned i = ModuleValueListSize, e = ValueList.size(); i != e; ++i){ if ((A = dyn_cast(ValueList.back())) && A->getParent() == 0) { - A->replaceAllUsesWith(UndefValue::get(A->getType())); + A->replaceAllUsesWith(Context.getUndef(A->getType())); delete A; } } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h?rev=74942&r1=74941&r2=74942&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h Tue Jul 7 15:18:58 2009 @@ -44,8 +44,9 @@ /// number that holds the resolved value. typedef std::vector > ResolveConstantsTy; ResolveConstantsTy ResolveConstants; + LLVMContext& Context; public: - BitcodeReaderValueList() {} + BitcodeReaderValueList(LLVMContext& C) : Context(C) {} ~BitcodeReaderValueList() { assert(ResolveConstants.empty() && "Constants not resolved?"); } @@ -126,7 +127,7 @@ DenseMap > DeferredFunctionInfo; public: explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext& C) - : Context(C), Buffer(buffer), ErrorString(0) { + : Context(C), Buffer(buffer), ErrorString(0), ValueList(C) { HasReversedFunctionsWithBodies = false; } ~BitcodeReader() { From sabre at nondot.org Tue Jul 7 15:30:48 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 20:30:48 -0000 Subject: [llvm-commits] [llvm] r74944 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp test/MC/AsmParser/directive_comm.s tools/llvm-mc/AsmParser.cpp tools/llvm-mc/AsmParser.h Message-ID: <200907072030.n67KUnY0029857@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 15:30:46 2009 New Revision: 74944 URL: http://llvm.org/viewvc/llvm-project?rev=74944&view=rev Log: Implement parsing support for the .comm directive. Patch by Kevin Enderby! Added: llvm/trunk/test/MC/AsmParser/directive_comm.s Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/tools/llvm-mc/AsmParser.cpp llvm/trunk/tools/llvm-mc/AsmParser.h Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=74944&r1=74943&r2=74944&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Tue Jul 7 15:30:46 2009 @@ -115,6 +115,15 @@ virtual void EmitSymbolAttribute(MCSymbol *Symbol, SymbolAttr Attribute) = 0; + /// EmitCommonSymbol - Emit a common symbol of @param Size with the @param + /// Pow2Alignment if non-zero. + /// + /// @param Symbol - The common symbol to emit. + /// @param Size - The size of the common symbol. + /// @param Pow2Alignment - The alignment of the common symbol if non-zero. + virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, + unsigned Pow2Alignment) = 0; + /// @} /// @name Generating Data /// @{ Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=74944&r1=74943&r2=74944&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Tue Jul 7 15:30:46 2009 @@ -41,6 +41,9 @@ virtual void EmitSymbolAttribute(MCSymbol *Symbol, SymbolAttr Attribute); + virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, + unsigned Pow2Alignment); + virtual void EmitBytes(const char *Data, unsigned Length); virtual void EmitValue(const MCValue &Value, unsigned Size); @@ -142,6 +145,15 @@ OS << ' ' << Symbol->getName() << '\n'; } +void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, + unsigned Pow2Alignment) { + OS << ".comm"; + OS << ' ' << Symbol->getName() << ',' << Size; + if (Pow2Alignment != 0) + OS << ',' << Pow2Alignment; + OS << '\n'; +} + void MCAsmStreamer::EmitBytes(const char *Data, unsigned Length) { assert(CurSection && "Cannot emit contents before setting section!"); for (unsigned i = 0; i != Length; ++i) Added: llvm/trunk/test/MC/AsmParser/directive_comm.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_comm.s?rev=74944&view=auto ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_comm.s (added) +++ llvm/trunk/test/MC/AsmParser/directive_comm.s Tue Jul 7 15:30:46 2009 @@ -0,0 +1,8 @@ +# RUN: llvm-mc %s > %t + +# RUN: grep -A 3 TEST0 %t > %t2 +# RUN: grep ".comm a,6,2" %t2 | count 1 +# RUN: grep ".comm b,8" %t2 | count 1 +TEST0: + .comm a, 4+2, 2 + .comm b,8 Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=74944&r1=74943&r2=74944&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Tue Jul 7 15:30:46 2009 @@ -520,6 +520,9 @@ if (!strcmp(IDVal, ".weak_reference")) return ParseDirectiveSymbolAttribute(MCStreamer::WeakReference); + if (!strcmp(IDVal, ".comm")) + return ParseDirectiveComm(); + Warning(IDLoc, "ignoring directive for now"); EatToEndOfStatement(); return false; @@ -896,3 +899,59 @@ Lexer.Lex(); return false; } + +/// ParseDirectiveComm +/// ::= .comm identifier , size_expression [ , align_expression ] +bool AsmParser::ParseDirectiveComm() { + if (Lexer.isNot(asmtok::Identifier)) + return TokError("expected identifier in directive"); + + // handle the identifier as the key symbol. + SMLoc IDLoc = Lexer.getLoc(); + MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal()); + Lexer.Lex(); + + if (Lexer.isNot(asmtok::Comma)) + return TokError("unexpected token in directive"); + Lexer.Lex(); + + int64_t Size; + SMLoc SizeLoc = Lexer.getLoc(); + if (ParseAbsoluteExpression(Size)) + return true; + + int64_t Pow2Alignment = 0; + SMLoc Pow2AlignmentLoc; + if (Lexer.is(asmtok::Comma)) { + Lexer.Lex(); + Pow2AlignmentLoc = Lexer.getLoc(); + if (ParseAbsoluteExpression(Pow2Alignment)) + return true; + } + + if (Lexer.isNot(asmtok::EndOfStatement)) + return TokError("unexpected token in '.comm' directive"); + + Lexer.Lex(); + + // NOTE: a size of zero should create a undefined symbol + if (Size < 0) + return Error(SizeLoc, "invalid '.comm' size, can't be less than zero"); + + // NOTE: The alignment in the directive is a power of 2 value, the assember + // may internally end up wanting an alignment in bytes. + // FIXME: Diagnose overflow. + if (Pow2Alignment < 0) + return Error(Pow2AlignmentLoc, "invalid '.comm' alignment, can't be less " + "than zero"); + + // TODO: Symbol must be undefined or it is a error to re-defined the symbol + if (Sym->getSection() || Ctx.GetSymbolValue(Sym)) + return Error(IDLoc, "invalid symbol redefinition"); + + // TODO: Symbol to be made into a common with this Size and Pow2Alignment + + Out.EmitCommonSymbol(Sym, Size, Pow2Alignment); + + return false; +} Modified: llvm/trunk/tools/llvm-mc/AsmParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=74944&r1=74943&r2=74944&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.h (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.h Tue Jul 7 15:30:46 2009 @@ -109,6 +109,8 @@ /// ParseDirectiveSymbolAttribute - Parse a directive like ".globl" which /// accepts a single symbol (which should be a label or an external). bool ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr); + + bool ParseDirectiveComm(); // ".comm" }; From evan.cheng at apple.com Tue Jul 7 15:38:18 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Jul 2009 20:38:18 -0000 Subject: [llvm-commits] [llvm] r74945 - in /llvm/trunk/test/CodeGen/Thumb: long_shift.ll mul.ll Message-ID: <200907072038.n67KcJN2030074@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jul 7 15:38:08 2009 New Revision: 74945 URL: http://llvm.org/viewvc/llvm-project?rev=74945&view=rev Log: Add missing tests. Added: llvm/trunk/test/CodeGen/Thumb/long_shift.ll llvm/trunk/test/CodeGen/Thumb/mul.ll Added: llvm/trunk/test/CodeGen/Thumb/long_shift.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/long_shift.ll?rev=74945&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/long_shift.ll (added) +++ llvm/trunk/test/CodeGen/Thumb/long_shift.ll Tue Jul 7 15:38:08 2009 @@ -0,0 +1,26 @@ +; RUN: llvm-as < %s | llc -march=thumb + +define i64 @f0(i64 %A, i64 %B) { + %tmp = bitcast i64 %A to i64 + %tmp2 = lshr i64 %B, 1 + %tmp3 = sub i64 %tmp, %tmp2 + ret i64 %tmp3 +} + +define i32 @f1(i64 %x, i64 %y) { + %a = shl i64 %x, %y + %b = trunc i64 %a to i32 + ret i32 %b +} + +define i32 @f2(i64 %x, i64 %y) { + %a = ashr i64 %x, %y + %b = trunc i64 %a to i32 + ret i32 %b +} + +define i32 @f3(i64 %x, i64 %y) { + %a = lshr i64 %x, %y + %b = trunc i64 %a to i32 + ret i32 %b +} Added: llvm/trunk/test/CodeGen/Thumb/mul.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/mul.ll?rev=74945&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/mul.ll (added) +++ llvm/trunk/test/CodeGen/Thumb/mul.ll Tue Jul 7 15:38:08 2009 @@ -0,0 +1,22 @@ +; RUN: llvm-as < %s | llc -march=thumb | grep mul | count 3 +; RUN: llvm-as < %s | llc -march=thumb | grep lsl | count 1 + +define i32 @f1(i32 %u) { + %tmp = mul i32 %u, %u + ret i32 %tmp +} + +define i32 @f2(i32 %u, i32 %v) { + %tmp = mul i32 %u, %v + ret i32 %tmp +} + +define i32 @f3(i32 %u) { + %tmp = mul i32 %u, 5 + ret i32 %tmp +} + +define i32 @f4(i32 %u) { + %tmp = mul i32 %u, 4 + ret i32 %tmp +} From evan.cheng at apple.com Tue Jul 7 15:39:04 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Jul 2009 20:39:04 -0000 Subject: [llvm-commits] [llvm] r74946 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/Thumb2/thumb2-select.ll test/CodeGen/Thumb2/thumb2-select_xform.ll Message-ID: <200907072039.n67Kd4ed030111@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jul 7 15:39:03 2009 New Revision: 74946 URL: http://llvm.org/viewvc/llvm-project?rev=74946&view=rev Log: Add Thumb2 movcc instructions. Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-select.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=74946&r1=74945&r2=74946&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue Jul 7 15:39:03 2009 @@ -1031,7 +1031,6 @@ return NULL; } case ARMISD::CMOV: { - bool isThumb = Subtarget->isThumb(); MVT VT = Op.getValueType(); SDValue N0 = Op.getOperand(0); SDValue N1 = Op.getOperand(1); @@ -1041,39 +1040,68 @@ assert(N2.getOpcode() == ISD::Constant); assert(N3.getOpcode() == ISD::Register); - // Pattern: (ARMcmov:i32 GPR:i32:$false, so_reg:i32:$true, (imm:i32):$cc) - // Emits: (MOVCCs:i32 GPR:i32:$false, so_reg:i32:$true, (imm:i32):$cc) - // Pattern complexity = 18 cost = 1 size = 0 - SDValue CPTmp0; - SDValue CPTmp1; - SDValue CPTmp2; - if (!isThumb && VT == MVT::i32 && - SelectShifterOperandReg(Op, N1, CPTmp0, CPTmp1, CPTmp2)) { - SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned) - cast(N2)->getZExtValue()), - MVT::i32); - SDValue Ops[] = { N0, CPTmp0, CPTmp1, CPTmp2, Tmp2, N3, InFlag }; - return CurDAG->SelectNodeTo(Op.getNode(), ARM::MOVCCs, MVT::i32, Ops, 7); - } + if (!Subtarget->isThumb1Only() && VT == MVT::i32) { + // Pattern: (ARMcmov:i32 GPR:i32:$false, so_reg:i32:$true, (imm:i32):$cc) + // Emits: (MOVCCs:i32 GPR:i32:$false, so_reg:i32:$true, (imm:i32):$cc) + // Pattern complexity = 18 cost = 1 size = 0 + SDValue CPTmp0; + SDValue CPTmp1; + SDValue CPTmp2; + if (Subtarget->isThumb()) { + if (SelectT2ShifterOperandReg(Op, N1, CPTmp0, CPTmp1)) { + SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned) + cast(N2)->getZExtValue()), + MVT::i32); + SDValue Ops[] = { N0, CPTmp0, CPTmp1, Tmp2, N3, InFlag }; + return CurDAG->SelectNodeTo(Op.getNode(), + ARM::t2MOVCCs, MVT::i32,Ops, 6); + } + } else { + if (SelectShifterOperandReg(Op, N1, CPTmp0, CPTmp1, CPTmp2)) { + SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned) + cast(N2)->getZExtValue()), + MVT::i32); + SDValue Ops[] = { N0, CPTmp0, CPTmp1, CPTmp2, Tmp2, N3, InFlag }; + return CurDAG->SelectNodeTo(Op.getNode(), + ARM::MOVCCs, MVT::i32, Ops, 7); + } + } - // Pattern: (ARMcmov:i32 GPR:i32:$false, - // (imm:i32)<><>:$true, - // (imm:i32):$cc) - // Emits: (MOVCCi:i32 GPR:i32:$false, - // (so_imm_XFORM:i32 (imm:i32):$true), (imm:i32):$cc) - // Pattern complexity = 10 cost = 1 size = 0 - if (VT == MVT::i32 && - N3.getOpcode() == ISD::Constant && - Predicate_so_imm(N3.getNode())) { - SDValue Tmp1 = CurDAG->getTargetConstant(((unsigned) - cast(N1)->getZExtValue()), - MVT::i32); - Tmp1 = Transform_so_imm_XFORM(Tmp1.getNode()); - SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned) - cast(N2)->getZExtValue()), - MVT::i32); - SDValue Ops[] = { N0, Tmp1, Tmp2, N3, InFlag }; - return CurDAG->SelectNodeTo(Op.getNode(), ARM::MOVCCi, MVT::i32, Ops, 5); + // Pattern: (ARMcmov:i32 GPR:i32:$false, + // (imm:i32)<><>:$true, + // (imm:i32):$cc) + // Emits: (MOVCCi:i32 GPR:i32:$false, + // (so_imm_XFORM:i32 (imm:i32):$true), (imm:i32):$cc) + // Pattern complexity = 10 cost = 1 size = 0 + if (N3.getOpcode() == ISD::Constant) { + if (Subtarget->isThumb()) { + if (Predicate_t2_so_imm(N3.getNode())) { + SDValue Tmp1 = CurDAG->getTargetConstant(((unsigned) + cast(N1)->getZExtValue()), + MVT::i32); + Tmp1 = Transform_t2_so_imm_XFORM(Tmp1.getNode()); + SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned) + cast(N2)->getZExtValue()), + MVT::i32); + SDValue Ops[] = { N0, Tmp1, Tmp2, N3, InFlag }; + return CurDAG->SelectNodeTo(Op.getNode(), + ARM::t2MOVCCi, MVT::i32, Ops, 5); + } + } else { + if (Predicate_so_imm(N3.getNode())) { + SDValue Tmp1 = CurDAG->getTargetConstant(((unsigned) + cast(N1)->getZExtValue()), + MVT::i32); + Tmp1 = Transform_so_imm_XFORM(Tmp1.getNode()); + SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned) + cast(N2)->getZExtValue()), + MVT::i32); + SDValue Ops[] = { N0, Tmp1, Tmp2, N3, InFlag }; + return CurDAG->SelectNodeTo(Op.getNode(), + ARM::MOVCCi, MVT::i32, Ops, 5); + } + } + } } // Pattern: (ARMcmov:i32 GPR:i32:$false, GPR:i32:$true, (imm:i32):$cc) @@ -1094,7 +1122,9 @@ default: assert(false && "Illegal conditional move type!"); break; case MVT::i32: - Opc = isThumb ? ARM::tMOVCCr : ARM::MOVCCr; + Opc = Subtarget->isThumb() + ? (Subtarget->hasThumb2() ? ARM::t2MOVCCr : ARM::tMOVCCr) + : ARM::MOVCCr; break; case MVT::f32: Opc = ARM::FCPYScc; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=74946&r1=74945&r2=74946&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Jul 7 15:39:03 2009 @@ -1028,7 +1028,24 @@ // Short range conditional branch. Looks awesome for loops. Need to figure // out how to use this one. -// FIXME: Conditional moves + +// Conditional moves +// FIXME: should be able to write a pattern for ARMcmov, but can't use +// a two-value operand where a dag node expects two operands. :( +def t2MOVCCr : T2I<(outs GPR:$dst), (ins GPR:$false, GPR:$true), + "mov", " $dst, $true", + [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>, + RegConstraint<"$false = $dst">; + +def t2MOVCCs : T2I<(outs GPR:$dst), (ins GPR:$false, t2_so_reg:$true), + "mov", " $dst, $true", +[/*(set GPR:$dst, (ARMcmov GPR:$false, t2_so_reg:$true, imm:$cc, CCR:$ccr))*/]>, + RegConstraint<"$false = $dst">; + +def t2MOVCCi : T2I<(outs GPR:$dst), (ins GPR:$false, t2_so_imm:$true), + "mov", " $dst, $true", +[/*(set GPR:$dst, (ARMcmov GPR:$false, t2_so_imm:$true, imm:$cc, CCR:$ccr))*/]>, + RegConstraint<"$false = $dst">; //===----------------------------------------------------------------------===// // Control-Flow Instructions Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-select.ll?rev=74946&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-select.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-select.ll Tue Jul 7 15:39:03 2009 @@ -0,0 +1,48 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep moveq | count 1 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movgt | count 1 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movlt | count 1 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movle | count 1 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movls | count 1 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movhi | count 1 + +define i32 @f1(i32 %a.s) { +entry: + %tmp = icmp eq i32 %a.s, 4 + %tmp1.s = select i1 %tmp, i32 2, i32 3 + ret i32 %tmp1.s +} + +define i32 @f2(i32 %a.s) { +entry: + %tmp = icmp sgt i32 %a.s, 4 + %tmp1.s = select i1 %tmp, i32 2, i32 3 + ret i32 %tmp1.s +} + +define i32 @f3(i32 %a.s, i32 %b.s) { +entry: + %tmp = icmp slt i32 %a.s, %b.s + %tmp1.s = select i1 %tmp, i32 2, i32 3 + ret i32 %tmp1.s +} + +define i32 @f4(i32 %a.s, i32 %b.s) { +entry: + %tmp = icmp sle i32 %a.s, %b.s + %tmp1.s = select i1 %tmp, i32 2, i32 3 + ret i32 %tmp1.s +} + +define i32 @f5(i32 %a.u, i32 %b.u) { +entry: + %tmp = icmp ule i32 %a.u, %b.u + %tmp1.s = select i1 %tmp, i32 2, i32 3 + ret i32 %tmp1.s +} + +define i32 @f6(i32 %a.u, i32 %b.u) { +entry: + %tmp = icmp ugt i32 %a.u, %b.u + %tmp1.s = select i1 %tmp, i32 2, i32 3 + ret i32 %tmp1.s +} Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll?rev=74946&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll Tue Jul 7 15:39:03 2009 @@ -0,0 +1,23 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | count 3 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mvn | count 1 + +define i32 @t1(i32 %a, i32 %b, i32 %c) nounwind { + %tmp1 = icmp sgt i32 %c, 10 + %tmp2 = select i1 %tmp1, i32 0, i32 2147483647 + %tmp3 = add i32 %tmp2, %b + ret i32 %tmp3 +} + +define i32 @t2(i32 %a, i32 %b, i32 %c) nounwind { + %tmp1 = icmp sgt i32 %c, 10 + %tmp2 = select i1 %tmp1, i32 0, i32 2147483648 + %tmp3 = add i32 %tmp2, %b + ret i32 %tmp3 +} + +define i32 @t3(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { + %tmp1 = icmp sgt i32 %c, 10 + %tmp2 = select i1 %tmp1, i32 0, i32 10 + %tmp3 = sub i32 %b, %tmp2 + ret i32 %tmp3 +} From gohman at apple.com Tue Jul 7 15:47:54 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 07 Jul 2009 20:47:54 -0000 Subject: [llvm-commits] [llvm] r74947 - /llvm/trunk/include/llvm/Instructions.h Message-ID: <200907072047.n67KltBR030489@zion.cs.uiuc.edu> Author: djg Date: Tue Jul 7 15:47:48 2009 New Revision: 74947 URL: http://llvm.org/viewvc/llvm-project?rev=74947&view=rev Log: Fix a typo and a grammaro in a comment. Modified: llvm/trunk/include/llvm/Instructions.h Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=74947&r1=74946&r2=74947&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Tue Jul 7 15:47:48 2009 @@ -51,7 +51,7 @@ /// bool isArrayAllocation() const; - /// getArraySize - Get the number of element allocated, for a simple + /// getArraySize - Get the number of elements allocated. For a simple /// allocation of a single element, this will return a constant 1 value. /// const Value *getArraySize() const { return getOperand(0); } From resistor at mac.com Tue Jul 7 16:07:16 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Jul 2009 21:07:16 -0000 Subject: [llvm-commits] [llvm] r74948 - /llvm/trunk/lib/Linker/LinkModules.cpp Message-ID: <200907072107.n67L7GrB031392@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 16:07:14 2009 New Revision: 74948 URL: http://llvm.org/viewvc/llvm-project?rev=74948&view=rev Log: LLVM Context-ification. Modified: llvm/trunk/lib/Linker/LinkModules.cpp Modified: llvm/trunk/lib/Linker/LinkModules.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=74948&r1=74947&r2=74948&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkModules.cpp (original) +++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Jul 7 16:07:14 2009 @@ -19,6 +19,7 @@ #include "llvm/Linker.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/TypeSymbolTable.h" #include "llvm/ValueSymbolTable.h" @@ -348,7 +349,8 @@ // RemapOperand - Use ValueMap to convert constants from one module to another. static Value *RemapOperand(const Value *In, - std::map &ValueMap) { + std::map &ValueMap, + LLVMContext &Context) { std::map::const_iterator I = ValueMap.find(In); if (I != ValueMap.end()) return I->second; @@ -363,24 +365,30 @@ if (const ConstantArray *CPA = dyn_cast(CPV)) { std::vector Operands(CPA->getNumOperands()); for (unsigned i = 0, e = CPA->getNumOperands(); i != e; ++i) - Operands[i] =cast(RemapOperand(CPA->getOperand(i), ValueMap)); - Result = ConstantArray::get(cast(CPA->getType()), Operands); + Operands[i] =cast(RemapOperand(CPA->getOperand(i), ValueMap, + Context)); + Result = + Context.getConstantArray(cast(CPA->getType()), Operands); } else if (const ConstantStruct *CPS = dyn_cast(CPV)) { std::vector Operands(CPS->getNumOperands()); for (unsigned i = 0, e = CPS->getNumOperands(); i != e; ++i) - Operands[i] =cast(RemapOperand(CPS->getOperand(i), ValueMap)); - Result = ConstantStruct::get(cast(CPS->getType()), Operands); + Operands[i] =cast(RemapOperand(CPS->getOperand(i), ValueMap, + Context)); + Result = + Context.getConstantStruct(cast(CPS->getType()), Operands); } else if (isa(CPV) || isa(CPV)) { Result = const_cast(CPV); } else if (const ConstantVector *CP = dyn_cast(CPV)) { std::vector Operands(CP->getNumOperands()); for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i) - Operands[i] = cast(RemapOperand(CP->getOperand(i), ValueMap)); - Result = ConstantVector::get(Operands); + Operands[i] = cast(RemapOperand(CP->getOperand(i), ValueMap, + Context)); + Result = Context.getConstantVector(Operands); } else if (const ConstantExpr *CE = dyn_cast(CPV)) { std::vector Ops; for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i) - Ops.push_back(cast(RemapOperand(CE->getOperand(i),ValueMap))); + Ops.push_back(cast(RemapOperand(CE->getOperand(i),ValueMap, + Context))); Result = CE->getWithOperands(Ops); } else { assert(!isa(CPV) && "Unmapped global?"); @@ -528,6 +536,7 @@ std::multimap &AppendingVars, std::string *Err) { ValueSymbolTable &DestSymTab = Dest->getValueSymbolTable(); + LLVMContext &Context = Dest->getContext(); // Loop over all of the globals in the src module, mapping them over as we go for (Module::const_global_iterator I = Src->global_begin(), @@ -631,7 +640,8 @@ // Propagate alignment, section, and visibility info. CopyGVAttributes(NewDGV, SGV); - DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV, DGV->getType())); + DGV->replaceAllUsesWith(Context.getConstantExprBitCast(NewDGV, + DGV->getType())); // DGV will conflict with NewDGV because they both had the same // name. We must erase this now so ForceRenaming doesn't assert @@ -677,7 +687,7 @@ DGV->setLinkage(NewLinkage); // Make sure to remember this mapping... - ValueMap[SGV] = ConstantExpr::getBitCast(DGV, SGV->getType()); + ValueMap[SGV] = Context.getConstantExprBitCast(DGV, SGV->getType()); } return false; } @@ -710,6 +720,8 @@ static bool LinkAlias(Module *Dest, const Module *Src, std::map &ValueMap, std::string *Err) { + LLVMContext &Context = Dest->getContext(); + // Loop over all alias in the src module for (Module::const_alias_iterator I = Src->alias_begin(), E = Src->alias_end(); I != E; ++I) { @@ -782,7 +794,7 @@ // Any uses of DGV need to change to NewGA, with cast, if needed. if (SGA->getType() != DGVar->getType()) - DGVar->replaceAllUsesWith(ConstantExpr::getBitCast(NewGA, + DGVar->replaceAllUsesWith(Context.getConstantExprBitCast(NewGA, DGVar->getType())); else DGVar->replaceAllUsesWith(NewGA); @@ -811,7 +823,7 @@ // Any uses of DF need to change to NewGA, with cast, if needed. if (SGA->getType() != DF->getType()) - DF->replaceAllUsesWith(ConstantExpr::getBitCast(NewGA, + DF->replaceAllUsesWith(Context.getConstantExprBitCast(NewGA, DF->getType())); else DF->replaceAllUsesWith(NewGA); @@ -866,7 +878,8 @@ if (SGV->hasInitializer()) { // Only process initialized GV's // Figure out what the initializer looks like in the dest module... Constant *SInit = - cast(RemapOperand(SGV->getInitializer(), ValueMap)); + cast(RemapOperand(SGV->getInitializer(), ValueMap, + Dest->getContext())); // Grab destination global variable or alias. GlobalValue *DGV = cast(ValueMap[SGV]->stripPointerCasts()); @@ -914,6 +927,7 @@ std::map &ValueMap, std::string *Err) { ValueSymbolTable &DestSymTab = Dest->getValueSymbolTable(); + LLVMContext &Context = Dest->getContext(); // Loop over all of the functions in the src module, mapping them over for (Module::const_iterator I = Src->begin(), E = Src->end(); I != E; ++I) { @@ -979,7 +993,8 @@ CopyGVAttributes(NewDF, SF); // Any uses of DF need to change to NewDF, with cast - DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDF, DGV->getType())); + DGV->replaceAllUsesWith(Context.getConstantExprBitCast(NewDF, + DGV->getType())); // DF will conflict with NewDF because they both had the same. We must // erase this now so ForceRenaming doesn't assert because DF might @@ -1017,7 +1032,7 @@ DGV->setLinkage(NewLinkage); // Make sure to remember this mapping. - ValueMap[SF] = ConstantExpr::getBitCast(DGV, SF->getType()); + ValueMap[SF] = Context.getConstantExprBitCast(DGV, SF->getType()); } return false; } @@ -1053,7 +1068,7 @@ for (Instruction::op_iterator OI = I->op_begin(), OE = I->op_end(); OI != OE; ++OI) if (!isa(*OI) && !isa(*OI)) - *OI = RemapOperand(*OI, ValueMap); + *OI = RemapOperand(*OI, ValueMap, *Dest->getContext()); // There is no need to map the arguments anymore. for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end(); @@ -1094,6 +1109,8 @@ std::string *ErrorMsg) { if (AppendingVars.empty()) return false; // Nothing to do. + LLVMContext &Context = M->getContext(); + // Loop over the multimap of appending vars, processing any variables with the // same name, forming a new appending global variable with both of the // initializers merged together, then rewrite references to the old variables @@ -1132,7 +1149,8 @@ "Appending variables with different section name need to be linked!"); unsigned NewSize = T1->getNumElements() + T2->getNumElements(); - ArrayType *NewType = ArrayType::get(T1->getElementType(), NewSize); + ArrayType *NewType = Context.getArrayType(T1->getElementType(), + NewSize); G1->setName(""); // Clear G1's name in case of a conflict! @@ -1152,7 +1170,7 @@ Inits.push_back(I->getOperand(i)); } else { assert(isa(G1->getInitializer())); - Constant *CV = Constant::getNullValue(T1->getElementType()); + Constant *CV = Context.getNullValue(T1->getElementType()); for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i) Inits.push_back(CV); } @@ -1161,11 +1179,11 @@ Inits.push_back(I->getOperand(i)); } else { assert(isa(G2->getInitializer())); - Constant *CV = Constant::getNullValue(T2->getElementType()); + Constant *CV = Context.getNullValue(T2->getElementType()); for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i) Inits.push_back(CV); } - NG->setInitializer(ConstantArray::get(NewType, Inits)); + NG->setInitializer(Context.getConstantArray(NewType, Inits)); Inits.clear(); // Replace any uses of the two global variables with uses of the new @@ -1173,8 +1191,10 @@ // FIXME: This should rewrite simple/straight-forward uses such as // getelementptr instructions to not use the Cast! - G1->replaceAllUsesWith(ConstantExpr::getBitCast(NG, G1->getType())); - G2->replaceAllUsesWith(ConstantExpr::getBitCast(NG, G2->getType())); + G1->replaceAllUsesWith(Context.getConstantExprBitCast(NG, + G1->getType())); + G2->replaceAllUsesWith(Context.getConstantExprBitCast(NG, + G2->getType())); // Remove the two globals from the module now... M->getGlobalList().erase(G1); From dpatel at apple.com Tue Jul 7 16:12:32 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 07 Jul 2009 21:12:32 -0000 Subject: [llvm-commits] [llvm] r74949 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <200907072112.n67LCWT1031690@zion.cs.uiuc.edu> Author: dpatel Date: Tue Jul 7 16:12:32 2009 New Revision: 74949 URL: http://llvm.org/viewvc/llvm-project?rev=74949&view=rev Log: Remove dead code. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=74949&r1=74948&r2=74949&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Jul 7 16:12:32 2009 @@ -1622,33 +1622,8 @@ DIVariable DV(GV); GlobalVariable *V = DV.getContext().getGV(); - // FIXME: The code that checks for the inlined local variable is a hack! - DenseMap::iterator - AI = AbstractInstanceRootMap.find(V); - - if (AI != AbstractInstanceRootMap.end()) { - // This method is called each time a DECLARE node is encountered. For an - // inlined function, this could be many, many times. We don't want to - // re-add variables to that DIE for each time. We just want to add them - // once. Check to make sure that we haven't added them already. - DenseMap >::iterator - IP = InlinedParamMap.find(V); - - if (IP != InlinedParamMap.end() && IP->second.count(GV) > 0) { - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); - return; - } - - // or GV is an inlined local variable. - Scope = AI->second; - InlinedParamMap[V].insert(GV); - InlinedFnVar = true; - } else { - // or GV is a local variable. - Scope = getOrCreateScope(V); - } + // or GV is a local variable. + Scope = getOrCreateScope(V); } } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=74949&r1=74948&r2=74949&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Jul 7 16:12:32 2009 @@ -163,11 +163,6 @@ /// attribute. DenseMap AbstractInstanceRootMap; - /// InlinedParamMap - A map keeping track of which parameters are assigned to - /// which abstract instance. - DenseMap > InlinedParamMap; - /// AbstractInstanceRootList - List of abstract instance roots of inlined /// functions. These are subroutine entries that contain a DW_AT_inline /// attribute. From resistor at mac.com Tue Jul 7 16:33:58 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Jul 2009 21:33:58 -0000 Subject: [llvm-commits] [llvm] r74950 - /llvm/trunk/lib/VMCore/Core.cpp Message-ID: <200907072133.n67LXwCf032560@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 16:33:58 2009 New Revision: 74950 URL: http://llvm.org/viewvc/llvm-project?rev=74950&view=rev Log: LLVMContext-ifiy the implementation of the C API. Modified: llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=74950&r1=74949&r2=74950&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Tue Jul 7 16:33:58 2009 @@ -128,7 +128,7 @@ LLVMTypeRef LLVMInt64Type(void) { return (LLVMTypeRef) Type::Int64Ty; } LLVMTypeRef LLVMIntType(unsigned NumBits) { - return wrap(IntegerType::get(NumBits)); + return wrap(getGlobalContext().getIntegerType(NumBits)); } unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) { @@ -152,7 +152,8 @@ for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) Tys.push_back(unwrap(*I)); - return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0)); + return wrap(getGlobalContext().getFunctionType(unwrap(ReturnType), Tys, + IsVarArg != 0)); } int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy) { @@ -183,7 +184,7 @@ *E = ElementTypes + ElementCount; I != E; ++I) Tys.push_back(unwrap(*I)); - return wrap(StructType::get(Tys, Packed != 0)); + return wrap(getGlobalContext().getStructType(Tys, Packed != 0)); } unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy) { @@ -204,15 +205,18 @@ /*--.. Operations on array, pointer, and vector types (sequence types) .....--*/ LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) { - return wrap(ArrayType::get(unwrap(ElementType), ElementCount)); + return wrap(getGlobalContext().getArrayType(unwrap(ElementType), + ElementCount)); } LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) { - return wrap(PointerType::get(unwrap(ElementType), AddressSpace)); + return wrap(getGlobalContext().getPointerType(unwrap(ElementType), + AddressSpace)); } LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) { - return wrap(VectorType::get(unwrap(ElementType), ElementCount)); + return wrap(getGlobalContext().getVectorType(unwrap(ElementType), + ElementCount)); } LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty) { @@ -237,7 +241,7 @@ LLVMTypeRef LLVMLabelType(void) { return (LLVMTypeRef) Type::LabelTy; } LLVMTypeRef LLVMOpaqueType(void) { - return wrap(llvm::OpaqueType::get()); + return wrap(getGlobalContext().getOpaqueType()); } /*--.. Operations on type handles ..........................................--*/ @@ -293,15 +297,15 @@ /*--.. Operations on constants of any type .................................--*/ LLVMValueRef LLVMConstNull(LLVMTypeRef Ty) { - return wrap(Constant::getNullValue(unwrap(Ty))); + return wrap(getGlobalContext().getNullValue(unwrap(Ty))); } LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty) { - return wrap(Constant::getAllOnesValue(unwrap(Ty))); + return wrap(getGlobalContext().getAllOnesValue(unwrap(Ty))); } LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty) { - return wrap(UndefValue::get(unwrap(Ty))); + return wrap(getGlobalContext().getUndef(unwrap(Ty))); } int LLVMIsConstant(LLVMValueRef Ty) { @@ -319,14 +323,16 @@ } LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty) { - return wrap(ConstantPointerNull::get(unwrap(Ty))); + return + wrap(getGlobalContext().getConstantPointerNull(unwrap(Ty))); } /*--.. Operations on scalar constants ......................................--*/ LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, int SignExtend) { - return wrap(ConstantInt::get(unwrap(IntTy), N, SignExtend != 0)); + return wrap(getGlobalContext().getConstantInt(unwrap(IntTy), N, + SignExtend != 0)); } static const fltSemantics &SemanticsForType(Type *Ty) { @@ -349,11 +355,12 @@ bool ignored; APN.convert(SemanticsForType(unwrap(RealTy)), APFloat::rmNearestTiesToEven, &ignored); - return wrap(ConstantFP::get(APN)); + return wrap(getGlobalContext().getConstantFP(APN)); } LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text) { - return wrap(ConstantFP::get(APFloat(SemanticsForType(unwrap(RealTy)), Text))); + return wrap(getGlobalContext().getConstantFP( + APFloat(SemanticsForType(unwrap(RealTy)), Text))); } /*--.. Operations on composite constants ...................................--*/ @@ -362,221 +369,254 @@ int DontNullTerminate) { /* Inverted the sense of AddNull because ', 0)' is a better mnemonic for null termination than ', 1)'. */ - return wrap(ConstantArray::get(std::string(Str, Length), + return wrap(getGlobalContext().getConstantArray(std::string(Str, Length), DontNullTerminate == 0)); } LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length) { - return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), + return wrap(getGlobalContext().getConstantArray( + getGlobalContext().getArrayType(unwrap(ElementTy), Length), unwrap(ConstantVals, Length), Length)); } LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, int Packed) { - return wrap(ConstantStruct::get(unwrap(ConstantVals, Count), + return wrap(getGlobalContext().getConstantStruct( + unwrap(ConstantVals, Count), Count, Packed != 0)); } LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) { - return wrap(ConstantVector::get(unwrap(ScalarConstantVals, Size), - Size)); + return wrap(getGlobalContext().getConstantVector( + unwrap(ScalarConstantVals, Size), Size)); } /*--.. Constant expressions ................................................--*/ LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty) { - return wrap(ConstantExpr::getAlignOf(unwrap(Ty))); + return wrap(getGlobalContext().getConstantExprAlignOf(unwrap(Ty))); } LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty) { - return wrap(ConstantExpr::getSizeOf(unwrap(Ty))); + return wrap(getGlobalContext().getConstantExprSizeOf(unwrap(Ty))); } LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal) { - return wrap(ConstantExpr::getNeg(unwrap(ConstantVal))); + return wrap(getGlobalContext().getConstantExprNeg( + unwrap(ConstantVal))); } LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal) { - return wrap(ConstantExpr::getNot(unwrap(ConstantVal))); + return wrap(getGlobalContext().getConstantExprNot( + unwrap(ConstantVal))); } LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getAdd(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprAdd( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getSub(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprSub( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getMul(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprMul( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getUDiv(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprUDiv( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getSDiv(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprSDiv( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getFDiv(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprFDiv( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getURem(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprURem( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getSRem(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprSRem( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getFRem(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprFRem( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getAnd(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprAnd( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getOr(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprOr( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getXor(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprXor( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getICmp(Predicate, + return wrap(getGlobalContext().getConstantExprICmp(Predicate, unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getFCmp(Predicate, + return wrap(getGlobalContext().getConstantExprFCmp(Predicate, unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getShl(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprShl( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getLShr(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprLShr( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) { - return wrap(ConstantExpr::getAShr(unwrap(LHSConstant), + return wrap(getGlobalContext().getConstantExprAShr( + unwrap(LHSConstant), unwrap(RHSConstant))); } LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices) { - return wrap(ConstantExpr::getGetElementPtr(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprGetElementPtr( + unwrap(ConstantVal), unwrap(ConstantIndices, NumIndices), NumIndices)); } LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getTrunc(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprTrunc( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getSExt(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprSExt( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getZExt(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprZExt( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getFPTrunc(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprFPTrunc( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getFPExtend(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprFPExtend( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getUIToFP(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprUIToFP( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getSIToFP(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprSIToFP(unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getFPToUI(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprFPToUI(unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getFPToSI(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprFPToSI( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getPtrToInt(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprPtrToInt( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getIntToPtr(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprIntToPtr( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getBitCast(unwrap(ConstantVal), + return wrap(getGlobalContext().getConstantExprBitCast( + unwrap(ConstantVal), unwrap(ToType))); } LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, LLVMValueRef ConstantIfTrue, LLVMValueRef ConstantIfFalse) { - return wrap(ConstantExpr::getSelect(unwrap(ConstantCondition), + return wrap(getGlobalContext().getConstantExprSelect( + unwrap(ConstantCondition), unwrap(ConstantIfTrue), unwrap(ConstantIfFalse))); } LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant) { - return wrap(ConstantExpr::getExtractElement(unwrap(VectorConstant), + return wrap(getGlobalContext().getConstantExprExtractElement( + unwrap(VectorConstant), unwrap(IndexConstant))); } LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, LLVMValueRef IndexConstant) { - return wrap(ConstantExpr::getInsertElement(unwrap(VectorConstant), + return wrap(getGlobalContext().getConstantExprInsertElement( + unwrap(VectorConstant), unwrap(ElementValueConstant), unwrap(IndexConstant))); } @@ -584,21 +624,24 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant) { - return wrap(ConstantExpr::getShuffleVector(unwrap(VectorAConstant), + return wrap(getGlobalContext().getConstantExprShuffleVector( + unwrap(VectorAConstant), unwrap(VectorBConstant), unwrap(MaskConstant))); } LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, unsigned NumIdx) { - return wrap(ConstantExpr::getExtractValue(unwrap(AggConstant), + return wrap(getGlobalContext().getConstantExprExtractValue( + unwrap(AggConstant), IdxList, NumIdx)); } LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, LLVMValueRef ElementValueConstant, unsigned *IdxList, unsigned NumIdx) { - return wrap(ConstantExpr::getInsertValue(unwrap(AggConstant), + return wrap(getGlobalContext().getConstantExprInsertValue( + unwrap(AggConstant), unwrap(ElementValueConstant), IdxList, NumIdx)); } From isanbard at gmail.com Tue Jul 7 16:53:07 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 07 Jul 2009 21:53:07 -0000 Subject: [llvm-commits] [llvm] r74952 - in /llvm/trunk/lib/Target/X86: X86RegisterInfo.cpp X86RegisterInfo.h Message-ID: <200907072153.n67Lr7bl000737@zion.cs.uiuc.edu> Author: void Date: Tue Jul 7 16:53:07 2009 New Revision: 74952 URL: http://llvm.org/viewvc/llvm-project?rev=74952&view=rev Log: DWARF requires frame moves be specified at specific times. If you have a prologue like this: __Z3fooi: Leh_func_begin1: LBB1_0: ## entry pushl %ebp Llabel1: movl %esp, %ebp Llabel2: pushl %esi Llabel3: subl $20, %esp call "L1$pb" "L1$pb": popl %esi The "pushl %ebp" needs a table entry specifying the offset. The "movl %esp, %ebp" makes %ebp the new stack frame register, so that needs to be specified in DWARF. And "pushl %esi" saves the callee-saved %esi register, which also needs to be specified in DWARF. Before, all of this logic was in one method. This didn't work too well, because as you can see there are multiple FDE line entries that need to be created. This fix creates the "MachineMove" objects directly when they're needed; instead of waiting until the end, and losing information. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.h Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=74952&r1=74951&r2=74952&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Tue Jul 7 16:53:07 2009 @@ -644,15 +644,16 @@ return Offset; } -void X86RegisterInfo::emitFrameMoves(MachineFunction &MF, - unsigned FrameLabelId, - unsigned ReadyLabelId) const { +void X86RegisterInfo::emitCalleeSavedFrameMoves(MachineFunction &MF, + unsigned LabelId) const { MachineFrameInfo *MFI = MF.getFrameInfo(); MachineModuleInfo *MMI = MFI->getMachineModuleInfo(); - if (!MMI) - return; + if (!MMI) return; + + // Add callee saved registers to move list. + const std::vector &CSI = MFI->getCalleeSavedInfo(); + if (CSI.empty()) return; - uint64_t StackSize = MFI->getStackSize(); std::vector &Moves = MMI->getFrameMoves(); const TargetData *TD = MF.getTarget().getTargetData(); @@ -662,62 +663,30 @@ TargetFrameInfo::StackGrowsUp ? TD->getPointerSize() : -TD->getPointerSize()); - MachineLocation FPDst(hasFP(MF) ? FramePtr : StackPtr); - MachineLocation FPSrc(MachineLocation::VirtualFP); - Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); - - if (StackSize) { - // Show update of SP. - if (hasFP(MF)) { - // Adjust SP - MachineLocation SPDst(MachineLocation::VirtualFP); - MachineLocation SPSrc(MachineLocation::VirtualFP, 2*stackGrowth); - Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); - } else { - MachineLocation SPDst(MachineLocation::VirtualFP); - MachineLocation SPSrc(MachineLocation::VirtualFP, - -StackSize+stackGrowth); - Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); - } - } else { - // FIXME: Verify & implement for FP - MachineLocation SPDst(StackPtr); - MachineLocation SPSrc(StackPtr, stackGrowth); - Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); - } - - // Add callee saved registers to move list. - const std::vector &CSI = MFI->getCalleeSavedInfo(); - // FIXME: This is dirty hack. The code itself is pretty mess right now. // It should be rewritten from scratch and generalized sometimes. // Determine maximum offset (minumum due to stack growth) int64_t MaxOffset = 0; - for (unsigned I = 0, E = CSI.size(); I!=E; ++I) + for (std::vector::const_iterator + I = CSI.begin(), E = CSI.end(); I != E; ++I) MaxOffset = std::min(MaxOffset, - MFI->getObjectOffset(CSI[I].getFrameIdx())); + MFI->getObjectOffset(I->getFrameIdx())); + + // Calculate offsets. + int64_t saveAreaOffset = (hasFP(MF) ? 3 : 2) * stackGrowth; + for (std::vector::const_iterator + I = CSI.begin(), E = CSI.end(); I != E; ++I) { + int64_t Offset = MFI->getObjectOffset(I->getFrameIdx()); + unsigned Reg = I->getReg(); + Offset = MaxOffset - Offset + saveAreaOffset; - // Calculate offsets - int64_t saveAreaOffset = (hasFP(MF) ? 3 : 2)*stackGrowth; - for (unsigned I = 0, E = CSI.size(); I!=E; ++I) { - int64_t Offset = MFI->getObjectOffset(CSI[I].getFrameIdx()); - unsigned Reg = CSI[I].getReg(); - Offset = (MaxOffset-Offset+saveAreaOffset); MachineLocation CSDst(MachineLocation::VirtualFP, Offset); MachineLocation CSSrc(Reg); - Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc)); - } - - if (hasFP(MF)) { - // Save FP - MachineLocation FPDst(MachineLocation::VirtualFP, 2*stackGrowth); - MachineLocation FPSrc(FramePtr); - Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); + Moves.push_back(MachineMove(LabelId, CSDst, CSSrc)); } } - void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB MachineFrameInfo *MFI = MF.getFrameInfo(); @@ -729,11 +698,9 @@ bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) || !Fn->doesNotThrow() || UnwindTablesMandatory; + bool HasFP = hasFP(MF); DebugLoc DL; - // Prepare for frame info. - unsigned FrameLabelId = 0; - // Get the number of bytes to allocate from the FrameInfo. uint64_t StackSize = MFI->getStackSize(); @@ -757,7 +724,7 @@ !MFI->hasCalls() && // No calls. !Subtarget->isTargetWin64()) { // Win64 has no Red Zone uint64_t MinSize = X86FI->getCalleeSavedFrameSize(); - if (hasFP(MF)) MinSize += SlotSize; + if (HasFP) MinSize += SlotSize; StackSize = std::max(MinSize, StackSize > 128 ? StackSize - 128 : 0); MFI->setStackSize(StackSize); @@ -774,8 +741,16 @@ MI->getOperand(3).setIsDead(); } + // uint64_t StackSize = MFI->getStackSize(); + std::vector &Moves = MMI->getFrameMoves(); + const TargetData *TD = MF.getTarget().getTargetData(); + int stackGrowth = + (MF.getTarget().getFrameInfo()->getStackGrowthDirection() == + TargetFrameInfo::StackGrowsUp ? + TD->getPointerSize() : -TD->getPointerSize()); + uint64_t NumBytes = 0; - if (hasFP(MF)) { + if (HasFP) { // Calculate required stack adjustment uint64_t FrameSize = StackSize - SlotSize; if (needsStackRealignment(MF)) @@ -783,19 +758,38 @@ NumBytes = FrameSize - X86FI->getCalleeSavedFrameSize(); - // Get the offset of the stack slot for the EBP register... which is + // Get the offset of the stack slot for the EBP register, which is // guaranteed to be the last slot by processFunctionBeforeFrameFinalized. // Update the frame offset adjustment. MFI->setOffsetAdjustment(-NumBytes); - // Save EBP into the appropriate stack slot... + // Save EBP/RBP into the appropriate stack slot... BuildMI(MBB, MBBI, DL, TII.get(Is64Bit ? X86::PUSH64r : X86::PUSH32r)) .addReg(FramePtr, RegState::Kill); if (needsFrameMoves) { // Mark effective beginning of when frame pointer becomes valid. - FrameLabelId = MMI->NextLabelID(); + unsigned FrameLabelId = MMI->NextLabelID(); BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(FrameLabelId); + + // Define the current CFA rule to use the provided offset. + if (StackSize) { + MachineLocation SPDst(MachineLocation::VirtualFP); + MachineLocation SPSrc(MachineLocation::VirtualFP, + HasFP ? 2 * stackGrowth : + -StackSize + stackGrowth); + Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); + } else { + // FIXME: Verify & implement for FP + MachineLocation SPDst(StackPtr); + MachineLocation SPSrc(StackPtr, stackGrowth); + Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); + } + + // Change the rule for the FramePtr to be an "offset" rule. + MachineLocation FPDst(MachineLocation::VirtualFP, 2 * stackGrowth); + MachineLocation FPSrc(FramePtr); + Moves.push_back(MachineMove(FrameLabelId, FPDst, FPSrc)); } // Update EBP with the new base value... @@ -803,6 +797,16 @@ TII.get(Is64Bit ? X86::MOV64rr : X86::MOV32rr), FramePtr) .addReg(StackPtr); + if (needsFrameMoves) { + unsigned FrameLabelId = MMI->NextLabelID(); + BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(FrameLabelId); + + // Define the current CFA to use the EBP/RBP register. + MachineLocation FPDst(FramePtr); + MachineLocation FPSrc(MachineLocation::VirtualFP); + Moves.push_back(MachineMove(FrameLabelId, FPDst, FPSrc)); + } + // Mark the FramePtr as live-in in every block except the entry. for (MachineFunction::iterator I = next(MF.begin()), E = MF.end(); I != E; ++I) @@ -822,10 +826,22 @@ } // Skip the callee-saved push instructions. + bool RegsSaved = false; while (MBBI != MBB.end() && (MBBI->getOpcode() == X86::PUSH32r || - MBBI->getOpcode() == X86::PUSH64r)) + MBBI->getOpcode() == X86::PUSH64r)) { + RegsSaved = true; ++MBBI; + } + + if (RegsSaved && needsFrameMoves) { + // Mark end of callee-saved push instructions. + unsigned LabelId = MMI->NextLabelID(); + BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(LabelId); + + // Emit DWARF info specifying the offsets of the callee-saved registers. + emitCalleeSavedFrameMoves(MF, LabelId); + } if (MBBI != MBB.end()) DL = MBBI->getDebugLoc(); @@ -882,14 +898,6 @@ if (NumBytes) emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit, TII); } - - if (needsFrameMoves) { - unsigned ReadyLabelId = 0; - // Mark effective beginning of when frame pointer is ready. - ReadyLabelId = MMI->NextLabelID(); - BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(ReadyLabelId); - emitFrameMoves(MF, FrameLabelId, ReadyLabelId); - } } void X86RegisterInfo::emitEpilogue(MachineFunction &MF, Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.h?rev=74952&r1=74951&r2=74952&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.h Tue Jul 7 16:53:07 2009 @@ -136,12 +136,10 @@ void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, RegScavenger *RS = NULL) const; + void emitCalleeSavedFrameMoves(MachineFunction &MF, unsigned LabelId) const; void emitPrologue(MachineFunction &MF) const; void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; - void emitFrameMoves(MachineFunction &MF, - unsigned FrameLabelId, unsigned ReadyLabelId) const; - // Debug information queries. unsigned getRARegister() const; unsigned getFrameRegister(MachineFunction &MF) const; From dpatel at apple.com Tue Jul 7 16:55:15 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 07 Jul 2009 21:55:15 -0000 Subject: [llvm-commits] [llvm] r74953 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200907072155.n67LtFaG000910@zion.cs.uiuc.edu> Author: dpatel Date: Tue Jul 7 16:55:14 2009 New Revision: 74953 URL: http://llvm.org/viewvc/llvm-project?rev=74953&view=rev Log: Accidently dropped this while removing dead code in previous commit. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=74953&r1=74952&r2=74953&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Jul 7 16:55:14 2009 @@ -1618,6 +1618,7 @@ if (SI != InlinedVariableScopes.end()) { // or GV is an inlined local variable. Scope = SI->second; + InlinedFnVar = true; } else { DIVariable DV(GV); GlobalVariable *V = DV.getContext().getGV(); From sabre at nondot.org Tue Jul 7 17:07:47 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 22:07:47 -0000 Subject: [llvm-commits] [llvm] r74954 - /llvm/trunk/test/CodeGen/X86/vfcmp.ll Message-ID: <200907072207.n67M7lsp001404@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 17:07:47 2009 New Revision: 74954 URL: http://llvm.org/viewvc/llvm-project?rev=74954&view=rev Log: verify that the fcmp version of this works just as well as the vfcmp version. We actually get better code for this silly testcase. Modified: llvm/trunk/test/CodeGen/X86/vfcmp.ll Modified: llvm/trunk/test/CodeGen/X86/vfcmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vfcmp.ll?rev=74954&r1=74953&r2=74954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vfcmp.ll (original) +++ llvm/trunk/test/CodeGen/X86/vfcmp.ll Tue Jul 7 17:07:47 2009 @@ -11,3 +11,15 @@ store <2 x i8> %6, <2 x i8>* null ret void } + +define void @t2(i32 %m_task_id, i32 %start_x, i32 %end_x) nounwind { + %A = fcmp olt <2 x double> zeroinitializer, zeroinitializer ; <<2 x i64>>:1 [#uses=1] + sext <2 x i1> %A to <2 x i64> + extractelement <2 x i64> %1, i32 1 ; :2 [#uses=1] + lshr i64 %2, 63 ; :3 [#uses=1] + trunc i64 %3 to i1 ; :4 [#uses=1] + zext i1 %4 to i8 ; :5 [#uses=1] + insertelement <2 x i8> zeroinitializer, i8 %5, i32 1 ; <<2 x i8>>:6 [#uses=1] + store <2 x i8> %6, <2 x i8>* null + ret void +} From dpatel at apple.com Tue Jul 7 17:09:42 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 07 Jul 2009 22:09:42 -0000 Subject: [llvm-commits] [llvm] r74955 - /llvm/trunk/include/llvm/Support/StandardPasses.h Message-ID: <200907072209.n67M9htk001469@zion.cs.uiuc.edu> Author: dpatel Date: Tue Jul 7 17:09:42 2009 New Revision: 74955 URL: http://llvm.org/viewvc/llvm-project?rev=74955&view=rev Log: Disable loop index split for now and let nightly tester verify its usefulness. Modified: llvm/trunk/include/llvm/Support/StandardPasses.h Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=74955&r1=74954&r2=74955&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue Jul 7 17:09:42 2009 @@ -129,7 +129,6 @@ PM->add(createLoopRotatePass()); // Rotate Loop PM->add(createLICMPass()); // Hoist loop invariants PM->add(createLoopUnswitchPass(OptimizeSize)); - PM->add(createLoopIndexSplitPass()); // Split loop index PM->add(createInstructionCombiningPass()); PM->add(createIndVarSimplifyPass()); // Canonicalize indvars PM->add(createLoopDeletionPass()); // Delete dead loops From jyasskin at google.com Tue Jul 7 17:15:37 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Tue, 07 Jul 2009 22:15:37 -0000 Subject: [llvm-commits] [llvm] r74956 - /llvm/trunk/tools/llvm-config/llvm-config.in.in Message-ID: <200907072215.n67MFb5x001649@zion.cs.uiuc.edu> Author: jyasskin Date: Tue Jul 7 17:15:37 2009 New Revision: 74956 URL: http://llvm.org/viewvc/llvm-project?rev=74956&view=rev Log: Fix http://llvm.org/PR4481: Make llvm-config print the right include paths when srcdir!=objdir. Modified: llvm/trunk/tools/llvm-config/llvm-config.in.in Modified: llvm/trunk/tools/llvm-config/llvm-config.in.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-config/llvm-config.in.in?rev=74956&r1=74955&r2=74956&view=diff ============================================================================== --- llvm/trunk/tools/llvm-config/llvm-config.in.in (original) +++ llvm/trunk/tools/llvm-config/llvm-config.in.in Tue Jul 7 17:15:37 2009 @@ -81,12 +81,15 @@ chomp($ABS_OBJ_ROOT); my $INCLUDEDIR = "$ABS_RUN_DIR/include"; +my $INCLUDEOPTION = "-I$INCLUDEDIR"; my $LIBDIR = "$ABS_RUN_DIR/lib"; my $BINDIR = "$ABS_RUN_DIR/bin"; if ($ABS_RUN_DIR eq $ABS_OBJ_ROOT) { # If we are running out of the build directory, the include dir is in the # srcdir. $INCLUDEDIR = "$LLVM_SRC_ROOT/include"; + # We need include files from both the srcdir and objdir. + $INCLUDEOPTION = "-I$INCLUDEDIR -I$LLVM_OBJ_ROOT/include" } else { # If installed, ignore the prefix the tree was configured with, use the # current prefix. @@ -120,11 +123,11 @@ } elsif ($arg eq "--libdir") { $has_opt = 1; print "$LIBDIR\n"; } elsif ($arg eq "--cppflags") { - $has_opt = 1; print "-I$INCLUDEDIR $CPPFLAGS\n"; + $has_opt = 1; print "$INCLUDEOPTION $CPPFLAGS\n"; } elsif ($arg eq "--cflags") { - $has_opt = 1; print "-I$INCLUDEDIR $CFLAGS\n"; + $has_opt = 1; print "$INCLUDEOPTION $CFLAGS\n"; } elsif ($arg eq "--cxxflags") { - $has_opt = 1; print "-I$INCLUDEDIR $CXXFLAGS\n"; + $has_opt = 1; print "$INCLUDEOPTION $CXXFLAGS\n"; } elsif ($arg eq "--ldflags") { $has_opt = 1; print "-L$LIBDIR $LDFLAGS $SYSTEM_LIBS\n"; } elsif ($arg eq "--libs") { From sabre at nondot.org Tue Jul 7 17:27:17 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 22:27:17 -0000 Subject: [llvm-commits] [llvm] r74957 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Message-ID: <200907072227.n67MRHe7002255@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 17:27:17 2009 New Revision: 74957 URL: http://llvm.org/viewvc/llvm-project?rev=74957&view=rev Log: add support for vector legalizing of *_EXTEND. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=74957&r1=74956&r2=74957&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Tue Jul 7 17:27:17 2009 @@ -72,9 +72,14 @@ case ISD::FCEIL: case ISD::FRINT: case ISD::FNEARBYINT: + case ISD::UINT_TO_FP: case ISD::SINT_TO_FP: case ISD::TRUNCATE: - case ISD::UINT_TO_FP: R = ScalarizeVecRes_UnaryOp(N); break; + case ISD::SIGN_EXTEND: + case ISD::ZERO_EXTEND: + case ISD::ANY_EXTEND: + R = ScalarizeVecRes_UnaryOp(N); + break; case ISD::ADD: case ISD::AND: @@ -91,11 +96,15 @@ case ISD::SUB: case ISD::UDIV: case ISD::UREM: - case ISD::XOR: R = ScalarizeVecRes_BinOp(N); break; + case ISD::XOR: + R = ScalarizeVecRes_BinOp(N); + break; case ISD::SHL: case ISD::SRA: - case ISD::SRL: R = ScalarizeVecRes_ShiftOp(N); break; + case ISD::SRL: + R = ScalarizeVecRes_ShiftOp(N); + break; } // If R is null, the sub-method took care of registering the result. @@ -403,8 +412,13 @@ case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: case ISD::SINT_TO_FP: + case ISD::UINT_TO_FP: case ISD::TRUNCATE: - case ISD::UINT_TO_FP: SplitVecRes_UnaryOp(N, Lo, Hi); break; + case ISD::SIGN_EXTEND: + case ISD::ZERO_EXTEND: + case ISD::ANY_EXTEND: + SplitVecRes_UnaryOp(N, Lo, Hi); + break; case ISD::ADD: case ISD::SUB: @@ -424,7 +438,9 @@ case ISD::SRL: case ISD::UREM: case ISD::SREM: - case ISD::FREM: SplitVecRes_BinOp(N, Lo, Hi); break; + case ISD::FREM: + SplitVecRes_BinOp(N, Lo, Hi); + break; } // If Lo/Hi is null, the sub-method took care of registering results etc. @@ -908,8 +924,9 @@ case ISD::BIT_CONVERT: Res = SplitVecOp_BIT_CONVERT(N); break; case ISD::EXTRACT_SUBVECTOR: Res = SplitVecOp_EXTRACT_SUBVECTOR(N); break; case ISD::EXTRACT_VECTOR_ELT:Res = SplitVecOp_EXTRACT_VECTOR_ELT(N); break; - case ISD::STORE: Res = SplitVecOp_STORE(cast(N), - OpNo); break; + case ISD::STORE: + Res = SplitVecOp_STORE(cast(N), OpNo); + break; case ISD::CTTZ: case ISD::CTLZ: @@ -917,8 +934,13 @@ case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: case ISD::SINT_TO_FP: + case ISD::UINT_TO_FP: case ISD::TRUNCATE: - case ISD::UINT_TO_FP: Res = SplitVecOp_UnaryOp(N); break; + case ISD::SIGN_EXTEND: + case ISD::ZERO_EXTEND: + case ISD::ANY_EXTEND: + Res = SplitVecOp_UnaryOp(N); + break; } } @@ -1126,21 +1148,27 @@ case ISD::UDIV: case ISD::UREM: case ISD::SUB: - case ISD::XOR: Res = WidenVecRes_Binary(N); break; + case ISD::XOR: + Res = WidenVecRes_Binary(N); + break; case ISD::SHL: case ISD::SRA: - case ISD::SRL: Res = WidenVecRes_Shift(N); break; + case ISD::SRL: + Res = WidenVecRes_Shift(N); + break; - case ISD::ANY_EXTEND: case ISD::FP_ROUND: case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: - case ISD::SIGN_EXTEND: case ISD::SINT_TO_FP: + case ISD::UINT_TO_FP: case ISD::TRUNCATE: + case ISD::SIGN_EXTEND: case ISD::ZERO_EXTEND: - case ISD::UINT_TO_FP: Res = WidenVecRes_Convert(N); break; + case ISD::ANY_EXTEND: + Res = WidenVecRes_Convert(N); + break; case ISD::CTLZ: case ISD::CTPOP: @@ -1149,7 +1177,9 @@ case ISD::FCOS: case ISD::FNEG: case ISD::FSIN: - case ISD::FSQRT: Res = WidenVecRes_Unary(N); break; + case ISD::FSQRT: + Res = WidenVecRes_Unary(N); + break; } // If Res is null, the sub-method took care of registering the result. @@ -1757,8 +1787,13 @@ case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: case ISD::SINT_TO_FP: + case ISD::UINT_TO_FP: case ISD::TRUNCATE: - case ISD::UINT_TO_FP: Res = WidenVecOp_Convert(N); break; + case ISD::SIGN_EXTEND: + case ISD::ZERO_EXTEND: + case ISD::ANY_EXTEND: + Res = WidenVecOp_Convert(N); + break; } // If Res is null, the sub-method took care of registering the result. From bob.wilson at apple.com Tue Jul 7 17:27:20 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 07 Jul 2009 22:27:20 -0000 Subject: [llvm-commits] [llvm] r74958 - /llvm/trunk/include/llvm/IntrinsicsARM.td Message-ID: <200907072227.n67MRKHo002268@zion.cs.uiuc.edu> Author: bwilson Date: Tue Jul 7 17:27:20 2009 New Revision: 74958 URL: http://llvm.org/viewvc/llvm-project?rev=74958&view=rev Log: Change NEON vldN/vstN intrinsics to specify "N" as an immediate operand instead of having a separate intrinsic for each value. Modified: llvm/trunk/include/llvm/IntrinsicsARM.td Modified: llvm/trunk/include/llvm/IntrinsicsARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsARM.td?rev=74958&r1=74957&r2=74958&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsARM.td (original) +++ llvm/trunk/include/llvm/IntrinsicsARM.td Tue Jul 7 17:27:20 2009 @@ -291,28 +291,20 @@ let TargetPrefix = "arm" in { // De-interleaving vector loads from N-element structures. - def int_arm_neon_vld3i : Intrinsic<[llvm_anyint_ty], - [llvm_ptr_ty], [IntrReadArgMem]>; - def int_arm_neon_vld3f : Intrinsic<[llvm_anyfloat_ty], - [llvm_ptr_ty], [IntrReadArgMem]>; - def int_arm_neon_vld4i : Intrinsic<[llvm_anyint_ty], - [llvm_ptr_ty], [IntrReadArgMem]>; - def int_arm_neon_vld4f : Intrinsic<[llvm_anyfloat_ty], - [llvm_ptr_ty], [IntrReadArgMem]>; + def int_arm_neon_vldi : Intrinsic<[llvm_anyint_ty], + [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; + def int_arm_neon_vldf : Intrinsic<[llvm_anyfloat_ty], + [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; // Interleaving vector stores from N-element structures. - def int_arm_neon_vst3i : Intrinsic<[llvm_void_ty], - [llvm_ptr_ty, llvm_anyint_ty], - [IntrWriteArgMem]>; - def int_arm_neon_vst3f : Intrinsic<[llvm_void_ty], - [llvm_ptr_ty, llvm_anyfloat_ty], - [IntrWriteArgMem]>; - def int_arm_neon_vst4i : Intrinsic<[llvm_void_ty], - [llvm_ptr_ty, llvm_anyint_ty], - [IntrWriteArgMem]>; - def int_arm_neon_vst4f : Intrinsic<[llvm_void_ty], - [llvm_ptr_ty, llvm_anyfloat_ty], - [IntrWriteArgMem]>; + def int_arm_neon_vsti : Intrinsic<[llvm_void_ty], + [llvm_ptr_ty, llvm_anyint_ty, llvm_i32_ty], + [IntrWriteArgMem]>; + def int_arm_neon_vstf : Intrinsic<[llvm_void_ty], + [llvm_ptr_ty, llvm_anyfloat_ty,llvm_i32_ty], + [IntrWriteArgMem]>; // Vector Table Lookup def int_arm_neon_vtbl : Intrinsic<[llvm_v8i8_ty], From sabre at nondot.org Tue Jul 7 17:28:42 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 22:28:42 -0000 Subject: [llvm-commits] [llvm] r74959 - in /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeTypes.h LegalizeVectorTypes.cpp Message-ID: <200907072228.n67MSgKw002318@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 17:28:41 2009 New Revision: 74959 URL: http://llvm.org/viewvc/llvm-project?rev=74959&view=rev Log: ScalarizeVecRes_ShiftOp and ScalarizeVecRes_BinOp are the same, eliminate the former. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=74959&r1=74958&r2=74959&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Tue Jul 7 17:28:41 2009 @@ -506,7 +506,6 @@ // Vector Result Scalarization: <1 x ty> -> ty. void ScalarizeVectorResult(SDNode *N, unsigned OpNo); SDValue ScalarizeVecRes_BinOp(SDNode *N); - SDValue ScalarizeVecRes_ShiftOp(SDNode *N); SDValue ScalarizeVecRes_UnaryOp(SDNode *N); SDValue ScalarizeVecRes_BIT_CONVERT(SDNode *N); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=74959&r1=74958&r2=74959&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Tue Jul 7 17:28:41 2009 @@ -97,13 +97,10 @@ case ISD::UDIV: case ISD::UREM: case ISD::XOR: - R = ScalarizeVecRes_BinOp(N); - break; - case ISD::SHL: case ISD::SRA: case ISD::SRL: - R = ScalarizeVecRes_ShiftOp(N); + R = ScalarizeVecRes_BinOp(N); break; } @@ -119,13 +116,6 @@ LHS.getValueType(), LHS, RHS); } -SDValue DAGTypeLegalizer::ScalarizeVecRes_ShiftOp(SDNode *N) { - SDValue LHS = GetScalarizedVector(N->getOperand(0)); - SDValue ShiftAmt = GetScalarizedVector(N->getOperand(1)); - return DAG.getNode(N->getOpcode(), N->getDebugLoc(), - LHS.getValueType(), LHS, ShiftAmt); -} - SDValue DAGTypeLegalizer::ScalarizeVecRes_BIT_CONVERT(SDNode *N) { MVT NewVT = N->getValueType(0).getVectorElementType(); return DAG.getNode(ISD::BIT_CONVERT, N->getDebugLoc(), From sabre at nondot.org Tue Jul 7 17:41:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 22:41:32 -0000 Subject: [llvm-commits] [llvm] r74960 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Message-ID: <200907072241.n67MfWBH002746@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 17:41:32 2009 New Revision: 74960 URL: http://llvm.org/viewvc/llvm-project?rev=74960&view=rev Log: lower vector icmp/fcmp to ICMP/FCMP nodes with the right result (vector of bool). Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=74960&r1=74959&r2=74960&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Tue Jul 7 17:41:32 2009 @@ -2209,7 +2209,9 @@ SDValue Op1 = getValue(I.getOperand(0)); SDValue Op2 = getValue(I.getOperand(1)); ISD::CondCode Opcode = getICmpCondCode(predicate); - setValue(&I, DAG.getSetCC(getCurDebugLoc(),MVT::i1, Op1, Op2, Opcode)); + + MVT DestVT = TLI.getValueType(I.getType()); + setValue(&I, DAG.getSetCC(getCurDebugLoc(), DestVT, Op1, Op2, Opcode)); } void SelectionDAGLowering::visitFCmp(User &I) { @@ -2221,7 +2223,8 @@ SDValue Op1 = getValue(I.getOperand(0)); SDValue Op2 = getValue(I.getOperand(1)); ISD::CondCode Condition = getFCmpCondCode(predicate); - setValue(&I, DAG.getSetCC(getCurDebugLoc(), MVT::i1, Op1, Op2, Condition)); + MVT DestVT = TLI.getValueType(I.getType()); + setValue(&I, DAG.getSetCC(getCurDebugLoc(), DestVT, Op1, Op2, Condition)); } void SelectionDAGLowering::visitVICmp(User &I) { From sabre at nondot.org Tue Jul 7 17:47:46 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 22:47:46 -0000 Subject: [llvm-commits] [llvm] r74961 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/2008-07-23-VSetCC.ll Message-ID: <200907072247.n67Mlka7002933@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 17:47:46 2009 New Revision: 74961 URL: http://llvm.org/viewvc/llvm-project?rev=74961&view=rev Log: implement support for spliting and scalarizing vector setcc's. This finishes off enough support for vector compares to get the icmp/fcmp version of 2008-07-23-VSetCC.ll passing. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=74961&r1=74960&r2=74961&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Tue Jul 7 17:47:46 2009 @@ -520,6 +520,7 @@ SDValue ScalarizeVecRes_UNDEF(SDNode *N); SDValue ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N); SDValue ScalarizeVecRes_VSETCC(SDNode *N); + SDValue ScalarizeVecRes_SETCC(SDNode *N); // Vector Operand Scalarization: <1 x ty> -> ty. bool ScalarizeVectorOperand(SDNode *N, unsigned OpNo); @@ -560,7 +561,7 @@ void SplitVecRes_UNDEF(SDNode *N, SDValue &Lo, SDValue &Hi); void SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N, SDValue &Lo, SDValue &Hi); - void SplitVecRes_VSETCC(SDNode *N, SDValue &Lo, SDValue &Hi); + void SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi); // Vector Operand Splitting: <128 x ty> -> 2 x <64 x ty>. bool SplitVectorOperand(SDNode *N, unsigned OpNo); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=74961&r1=74960&r2=74961&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Tue Jul 7 17:47:46 2009 @@ -56,6 +56,7 @@ case ISD::UNDEF: R = ScalarizeVecRes_UNDEF(N); break; case ISD::VECTOR_SHUFFLE: R = ScalarizeVecRes_VECTOR_SHUFFLE(N); break; case ISD::VSETCC: R = ScalarizeVecRes_VSETCC(N); break; + case ISD::SETCC: R = ScalarizeVecRes_SETCC(N); break; case ISD::CTLZ: case ISD::CTPOP: @@ -250,6 +251,14 @@ return DAG.getNode(ISD::SIGN_EXTEND, dl, NVT, Res); } } +SDValue DAGTypeLegalizer::ScalarizeVecRes_SETCC(SDNode *N) { + SDValue LHS = GetScalarizedVector(N->getOperand(0)); + SDValue RHS = GetScalarizedVector(N->getOperand(1)); + DebugLoc DL = N->getDebugLoc(); + + // Turn it into a scalar SETCC. + return DAG.getNode(ISD::SETCC, DL, MVT::i1, LHS, RHS, N->getOperand(2)); +} //===----------------------------------------------------------------------===// @@ -381,10 +390,17 @@ case ISD::FPOWI: SplitVecRes_FPOWI(N, Lo, Hi); break; case ISD::INSERT_VECTOR_ELT: SplitVecRes_INSERT_VECTOR_ELT(N, Lo, Hi); break; case ISD::SCALAR_TO_VECTOR: SplitVecRes_SCALAR_TO_VECTOR(N, Lo, Hi); break; - case ISD::LOAD: SplitVecRes_LOAD(cast(N), Lo, Hi);break; + case ISD::LOAD: + SplitVecRes_LOAD(cast(N), Lo, Hi); + break; case ISD::VECTOR_SHUFFLE: - SplitVecRes_VECTOR_SHUFFLE(cast(N), Lo, Hi); break; - case ISD::VSETCC: SplitVecRes_VSETCC(N, Lo, Hi); break; + SplitVecRes_VECTOR_SHUFFLE(cast(N), Lo, Hi); + break; + + case ISD::VSETCC: + case ISD::SETCC: + SplitVecRes_SETCC(N, Lo, Hi); + break; case ISD::CTTZ: case ISD::CTLZ: @@ -874,8 +890,7 @@ } } -void DAGTypeLegalizer::SplitVecRes_VSETCC(SDNode *N, SDValue &Lo, - SDValue &Hi) { +void DAGTypeLegalizer::SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi) { MVT LoVT, HiVT; DebugLoc dl = N->getDebugLoc(); GetSplitDestVTs(N->getValueType(0), LoVT, HiVT); @@ -884,11 +899,10 @@ GetSplitVector(N->getOperand(0), LL, LH); GetSplitVector(N->getOperand(1), RL, RH); - Lo = DAG.getNode(ISD::VSETCC, dl, LoVT, LL, RL, N->getOperand(2)); - Hi = DAG.getNode(ISD::VSETCC, dl, HiVT, LH, RH, N->getOperand(2)); + Lo = DAG.getNode(N->getOpcode(), dl, LoVT, LL, RL, N->getOperand(2)); + Hi = DAG.getNode(N->getOpcode(), dl, HiVT, LH, RH, N->getOperand(2)); } - //===----------------------------------------------------------------------===// // Operand Vector Splitting //===----------------------------------------------------------------------===// Modified: llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll?rev=74961&r1=74960&r2=74961&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll Tue Jul 7 17:47:46 2009 @@ -27,4 +27,32 @@ ret void } +define void @entry2(i32 %m_task_id, i32 %start_x, i32 %end_x) nounwind { + br i1 false, label %bb.nph, label %._crit_edge + +bb.nph: ; preds = %bb.nph, %0 + %X = icmp sgt <4 x i32> zeroinitializer, < i32 -128, i32 -128, i32 -128, i32 -128 > ; <<4 x i32>>:1 [#uses=1] + sext <4 x i1> %X to <4 x i32> + extractelement <4 x i32> %1, i32 3 ; :2 [#uses=1] + lshr i32 %2, 31 ; :3 [#uses=1] + trunc i32 %3 to i1 ; :4 [#uses=1] + select i1 %4, i32 -1, i32 0 ; :5 [#uses=1] + insertelement <4 x i32> zeroinitializer, i32 %5, i32 3 ; <<4 x i32>>:6 [#uses=1] + and <4 x i32> zeroinitializer, %6 ; <<4 x i32>>:7 [#uses=1] + bitcast <4 x i32> %7 to <4 x float> ; <<4 x float>>:8 [#uses=1] + fmul <4 x float> zeroinitializer, %8 ; <<4 x float>>:9 [#uses=1] + bitcast <4 x float> %9 to <4 x i32> ; <<4 x i32>>:10 [#uses=1] + or <4 x i32> %10, zeroinitializer ; <<4 x i32>>:11 [#uses=1] + bitcast <4 x i32> %11 to <4 x float> ; <<4 x float>>:12 [#uses=1] + fmul <4 x float> %12, < float 1.000000e+02, float 1.000000e+02, float 1.000000e+02, float 1.000000e+02 > ; <<4 x float>>:13 [#uses=1] + fsub <4 x float> %13, < float 1.000000e+02, float 1.000000e+02, float 1.000000e+02, float 1.000000e+02 > ; <<4 x float>>:14 [#uses=1] + extractelement <4 x float> %14, i32 3 ; :15 [#uses=1] + call float @fmaxf( float 0.000000e+00, float %15 ) ; :16 [#uses=0] + br label %bb.nph + +._crit_edge: ; preds = %0 + ret void +} + + declare float @fmaxf(float, float) From sabre at nondot.org Tue Jul 7 17:49:15 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 22:49:15 -0000 Subject: [llvm-commits] [llvm] r74962 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Message-ID: <200907072249.n67MnF2L002983@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 17:49:15 2009 New Revision: 74962 URL: http://llvm.org/viewvc/llvm-project?rev=74962&view=rev Log: random code cleanups. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=74962&r1=74961&r2=74962&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Tue Jul 7 17:49:15 2009 @@ -225,10 +225,10 @@ SDValue RHS = GetScalarizedVector(N->getOperand(1)); MVT NVT = N->getValueType(0).getVectorElementType(); MVT SVT = TLI.getSetCCResultType(LHS.getValueType()); - DebugLoc dl = N->getDebugLoc(); + DebugLoc DL = N->getDebugLoc(); // Turn it into a scalar SETCC. - SDValue Res = DAG.getNode(ISD::SETCC, dl, SVT, LHS, RHS, N->getOperand(2)); + SDValue Res = DAG.getNode(ISD::SETCC, DL, SVT, LHS, RHS, N->getOperand(2)); // VSETCC always returns a sign-extended value, while SETCC may not. The // SETCC result type may not match the vector element type. Correct these. @@ -237,19 +237,19 @@ // Ensure the SETCC result is sign-extended. if (TLI.getBooleanContents() != TargetLowering::ZeroOrNegativeOneBooleanContent) - Res = DAG.getNode(ISD::SIGN_EXTEND_INREG, dl, SVT, Res, + Res = DAG.getNode(ISD::SIGN_EXTEND_INREG, DL, SVT, Res, DAG.getValueType(MVT::i1)); // Truncate to the final type. - return DAG.getNode(ISD::TRUNCATE, dl, NVT, Res); - } else { - // The SETCC result type is smaller than the vector element type. - // If the SetCC result is not sign-extended, chop it down to MVT::i1. - if (TLI.getBooleanContents() != - TargetLowering::ZeroOrNegativeOneBooleanContent) - Res = DAG.getNode(ISD::TRUNCATE, dl, MVT::i1, Res); - // Sign extend to the final type. - return DAG.getNode(ISD::SIGN_EXTEND, dl, NVT, Res); + return DAG.getNode(ISD::TRUNCATE, DL, NVT, Res); } + + // The SETCC result type is smaller than the vector element type. + // If the SetCC result is not sign-extended, chop it down to MVT::i1. + if (TLI.getBooleanContents() != + TargetLowering::ZeroOrNegativeOneBooleanContent) + Res = DAG.getNode(ISD::TRUNCATE, DL, MVT::i1, Res); + // Sign extend to the final type. + return DAG.getNode(ISD::SIGN_EXTEND, DL, NVT, Res); } SDValue DAGTypeLegalizer::ScalarizeVecRes_SETCC(SDNode *N) { SDValue LHS = GetScalarizedVector(N->getOperand(0)); @@ -278,19 +278,18 @@ N->dump(&DAG); cerr << "\n"; #endif assert(0 && "Do not know how to scalarize this operator's operand!"); - abort(); - case ISD::BIT_CONVERT: - Res = ScalarizeVecOp_BIT_CONVERT(N); break; - + Res = ScalarizeVecOp_BIT_CONVERT(N); + break; case ISD::CONCAT_VECTORS: - Res = ScalarizeVecOp_CONCAT_VECTORS(N); break; - + Res = ScalarizeVecOp_CONCAT_VECTORS(N); + break; case ISD::EXTRACT_VECTOR_ELT: - Res = ScalarizeVecOp_EXTRACT_VECTOR_ELT(N); break; - + Res = ScalarizeVecOp_EXTRACT_VECTOR_ELT(N); + break; case ISD::STORE: - Res = ScalarizeVecOp_STORE(cast(N), OpNo); break; + Res = ScalarizeVecOp_STORE(cast(N), OpNo); + break; } } @@ -1036,10 +1035,9 @@ if (IdxVal < LoElts) return DAG.UpdateNodeOperands(SDValue(N, 0), Lo, Idx); - else - return DAG.UpdateNodeOperands(SDValue(N, 0), Hi, - DAG.getConstant(IdxVal - LoElts, - Idx.getValueType())); + return DAG.UpdateNodeOperands(SDValue(N, 0), Hi, + DAG.getConstant(IdxVal - LoElts, + Idx.getValueType())); } // Store the vector to the stack. @@ -1129,8 +1127,11 @@ case ISD::SELECT_CC: Res = WidenVecRes_SELECT_CC(N); break; case ISD::UNDEF: Res = WidenVecRes_UNDEF(N); break; case ISD::VECTOR_SHUFFLE: - Res = WidenVecRes_VECTOR_SHUFFLE(cast(N)); break; - case ISD::VSETCC: Res = WidenVecRes_VSETCC(N); break; + Res = WidenVecRes_VECTOR_SHUFFLE(cast(N)); + break; + case ISD::VSETCC: + Res = WidenVecRes_VSETCC(N); + break; case ISD::ADD: case ISD::AND: From sabre at nondot.org Tue Jul 7 17:51:09 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 22:51:09 -0000 Subject: [llvm-commits] [llvm] r74963 - /llvm/trunk/test/CodeGen/X86/vec_compare.ll Message-ID: <200907072251.n67Mp9am003049@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 17:51:09 2009 New Revision: 74963 URL: http://llvm.org/viewvc/llvm-project?rev=74963&view=rev Log: add a trivial test that vector compares work. Added: llvm/trunk/test/CodeGen/X86/vec_compare.ll Added: llvm/trunk/test/CodeGen/X86/vec_compare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_compare.ll?rev=74963&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_compare.ll (added) +++ llvm/trunk/test/CodeGen/X86/vec_compare.ll Tue Jul 7 17:51:09 2009 @@ -0,0 +1,7 @@ +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep pcmpgtd + +define <4 x i32> @test(<4 x i32> %A, <4 x i32> %B) nounwind { + %C = vicmp sgt <4 x i32> %A, %B + ret <4 x i32> %C +} + From sabre at nondot.org Tue Jul 7 18:03:54 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 23:03:54 -0000 Subject: [llvm-commits] [llvm] r74964 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/vec_compare.ll Message-ID: <200907072303.n67N3tpM003424@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 18:03:54 2009 New Revision: 74964 URL: http://llvm.org/viewvc/llvm-project?rev=74964&view=rev Log: add support for legalizing an icmp where the result is illegal (4xi1) but the input is legal (4 x i32) Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp llvm/trunk/test/CodeGen/X86/vec_compare.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=74964&r1=74963&r2=74964&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Tue Jul 7 18:03:54 2009 @@ -891,15 +891,38 @@ void DAGTypeLegalizer::SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi) { MVT LoVT, HiVT; - DebugLoc dl = N->getDebugLoc(); + DebugLoc DL = N->getDebugLoc(); GetSplitDestVTs(N->getValueType(0), LoVT, HiVT); - + + // Split the input. + MVT InVT = N->getOperand(0).getValueType(); SDValue LL, LH, RL, RH; - GetSplitVector(N->getOperand(0), LL, LH); - GetSplitVector(N->getOperand(1), RL, RH); - - Lo = DAG.getNode(N->getOpcode(), dl, LoVT, LL, RL, N->getOperand(2)); - Hi = DAG.getNode(N->getOpcode(), dl, HiVT, LH, RH, N->getOperand(2)); + switch (getTypeAction(InVT)) { + default: assert(0 && "Unexpected type action!"); + case WidenVector: assert(0 && "Unimp"); + case Legal: { + assert(LoVT == HiVT && "Legal non-power-of-two vector type?"); + MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(), + LoVT.getVectorNumElements()); + LL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0), + DAG.getIntPtrConstant(0)); + LH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0), + DAG.getIntPtrConstant(InNVT.getVectorNumElements())); + + RL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1), + DAG.getIntPtrConstant(0)); + RH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1), + DAG.getIntPtrConstant(InNVT.getVectorNumElements())); + break; + } + case SplitVector: + GetSplitVector(N->getOperand(0), LL, LH); + GetSplitVector(N->getOperand(1), RL, RH); + break; + } + + Lo = DAG.getNode(N->getOpcode(), DL, LoVT, LL, RL, N->getOperand(2)); + Hi = DAG.getNode(N->getOpcode(), DL, HiVT, LH, RH, N->getOperand(2)); } //===----------------------------------------------------------------------===// Modified: llvm/trunk/test/CodeGen/X86/vec_compare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_compare.ll?rev=74964&r1=74963&r2=74964&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_compare.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_compare.ll Tue Jul 7 18:03:54 2009 @@ -5,3 +5,10 @@ ret <4 x i32> %C } + +define <4 x i32> @test2(<4 x i32> %A, <4 x i32> %B) nounwind { + %C = icmp sgt <4 x i32> %A, %B + %D = sext <4 x i1> %C to <4 x i32> + ret <4 x i32> %D +} + From dalej at apple.com Tue Jul 7 18:26:37 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 07 Jul 2009 23:26:37 -0000 Subject: [llvm-commits] [llvm] r74967 - /llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Message-ID: <200907072326.n67NQdWw004088@zion.cs.uiuc.edu> Author: johannes Date: Tue Jul 7 18:26:33 2009 New Revision: 74967 URL: http://llvm.org/viewvc/llvm-project?rev=74967&view=rev Log: Operand of asm("call") (the callee function) is represented as "X" constraint and "P" modifier on x86. Make this work. (Change may not be sufficient to fix it for non-Darwin, but I'm pretty sure it won't break anything.) gcc.apple/asm-block-32.c gcc.apple/asm-block-33.c Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=74967&r1=74966&r2=74967&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Tue Jul 7 18:26:33 2009 @@ -2405,11 +2405,24 @@ // 'X' matches anything. if (OpInfo.ConstraintCode == "X" && OpInfo.CallOperandVal) { + // Look through bitcasts over functions. In the context of an asm + // argument we don't care about bitcasting function types; the parameters + // to the function, if any, will have been handled elsewhere. + Value *v = OpInfo.CallOperandVal; + ConstantExpr *CE = NULL; + while ((CE = dyn_cast(v)) && + CE->getOpcode()==Instruction::BitCast) + v = CE->getOperand(0); + if (!isa(v)) + v = OpInfo.CallOperandVal; // Labels and constants are handled elsewhere ('X' is the only thing - // that matches labels). - if (isa(OpInfo.CallOperandVal) || - isa(OpInfo.CallOperandVal)) + // that matches labels). For Functions, the type here is the type of + // the result, which is not what we want to look at; leave them alone + // (minus any bitcasts). + if (isa(v) || isa(v) || isa(v)) { + OpInfo.CallOperandVal = v; return; + } // Otherwise, try to resolve it to something we know about by looking at // the actual operand type. From dalej at apple.com Tue Jul 7 18:28:23 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 07 Jul 2009 23:28:23 -0000 Subject: [llvm-commits] [llvm] r74968 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Message-ID: <200907072328.n67NSOwY004146@zion.cs.uiuc.edu> Author: johannes Date: Tue Jul 7 18:28:22 2009 New Revision: 74968 URL: http://llvm.org/viewvc/llvm-project?rev=74968&view=rev Log: Commit the file I actually changed as part of last patch, instead of one I didn't. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=74968&r1=74967&r2=74968&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Tue Jul 7 18:28:22 2009 @@ -434,19 +434,22 @@ case MachineOperand::MO_Immediate: if (!Modifier || (strcmp(Modifier, "debug") && - strcmp(Modifier, "mem"))) + strcmp(Modifier, "mem") && + strcmp(Modifier, "asmcall"))) O << '$'; O << MO.getImm(); return; case MachineOperand::MO_JumpTableIndex: { - bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + bool isMemOp = Modifier && + (!strcmp(Modifier, "mem") || !strcmp(Modifier, "asmcall")); if (!isMemOp) O << '$'; O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' << MO.getIndex(); break; } case MachineOperand::MO_ConstantPoolIndex: { - bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + bool isMemOp = Modifier && + (!strcmp(Modifier, "mem") || !strcmp(Modifier, "asmcall")); if (!isMemOp) O << '$'; O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_' << MO.getIndex(); @@ -455,7 +458,9 @@ break; } case MachineOperand::MO_GlobalAddress: { - bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + bool isMemOp = Modifier && + (!strcmp(Modifier, "mem") || !strcmp(Modifier, "asmcall")); + bool isAsmCallOp = Modifier && !strcmp(Modifier, "asmcall"); const GlobalValue *GV = MO.getGlobal(); std::string Name = Mang->getValueName(GV); @@ -478,7 +483,15 @@ // non-lazily-resolved stubs if (GV->isDeclaration() || GV->isWeakForLinker()) { // Dynamically-resolved functions need a stub for the function. - if (GV->hasHiddenVisibility()) { + if (isa(GV) && isAsmCallOp) { + // Function stubs are no longer needed for Mac OS X 10.5 and up. + if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) { + O << Name; + } else { + FnStubs.insert(Name); + printSuffixedName(Name, "$stub"); + } + } else if (GV->hasHiddenVisibility()) { if (!GV->isDeclaration() && !GV->hasCommonLinkage()) // Definition is not definitely in the current translation unit. O << Name; @@ -496,7 +509,7 @@ O << Name; } - if (TM.getRelocationModel() == Reloc::PIC_) { + if (TM.getRelocationModel() == Reloc::PIC_ && !isAsmCallOp) { O << '-'; PrintPICBaseSymbol(); } @@ -519,7 +532,8 @@ /// are pcrel_imm's. assert(!Subtarget->is64Bit() && !Subtarget->isPICStyleRIPRel()); // These are never used as memory operands. - assert(!(Modifier && !strcmp(Modifier, "mem"))); + assert(!(Modifier && + (!strcmp(Modifier, "mem") || !strcmp(Modifier, "asmcall")))); O << '$'; O << TAI->getGlobalPrefix(); @@ -725,11 +739,11 @@ printOperand(MI, OpNo); return false; - case 'P': // Don't print @PLT, but do print as memory. - printOperand(MI, OpNo, "mem"); + case 'P': // This is the operand of a call, treat specially. + printOperand(MI, OpNo, "asmcall"); return false; - case 'n': { // Negate the immediate or print a '-' before the operand. + case 'n': { // Negate the immediate or print a '-' before the operand. // Note: this is a temporary solution. It should be handled target // independently as part of the 'MC' work. const MachineOperand &MO = MI->getOperand(OpNo); From sabre at nondot.org Tue Jul 7 18:28:46 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Jul 2009 23:28:46 -0000 Subject: [llvm-commits] [llvm] r74969 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <200907072328.n67NSk2p004167@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 18:28:46 2009 New Revision: 74969 URL: http://llvm.org/viewvc/llvm-project?rev=74969&view=rev Log: SelectionDAG::SignBitIsZero doesn't work right for vectors, for now, conservatively return false. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=74969&r1=74968&r2=74969&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Jul 7 18:28:46 2009 @@ -1516,6 +1516,10 @@ /// SignBitIsZero - Return true if the sign bit of Op is known to be zero. We /// use this predicate to simplify operations downstream. bool SelectionDAG::SignBitIsZero(SDValue Op, unsigned Depth) const { + // This predicate is not safe for vector operations. + if (Op.getValueType().isVector()) + return false; + unsigned BitWidth = Op.getValueSizeInBits(); return MaskedValueIsZero(Op, APInt::getSignBit(BitWidth), Depth); } From isanbard at gmail.com Tue Jul 7 18:37:50 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 07 Jul 2009 23:37:50 -0000 Subject: [llvm-commits] [llvm] r74970 - in /llvm/trunk/lib/Target/X86: X86RegisterInfo.cpp X86RegisterInfo.h Message-ID: <200907072337.n67Nbo6p004424@zion.cs.uiuc.edu> Author: void Date: Tue Jul 7 18:37:49 2009 New Revision: 74970 URL: http://llvm.org/viewvc/llvm-project?rev=74970&view=rev Log: --- Reverse-merging (from foreign repository) r74952 into '.': U lib/Target/X86/X86RegisterInfo.cpp U lib/Target/X86/X86RegisterInfo.h Temporarily revert. This was causing an infinite loop in the linker on Leopard. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.h Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=74970&r1=74969&r2=74970&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Tue Jul 7 18:37:49 2009 @@ -644,16 +644,15 @@ return Offset; } -void X86RegisterInfo::emitCalleeSavedFrameMoves(MachineFunction &MF, - unsigned LabelId) const { +void X86RegisterInfo::emitFrameMoves(MachineFunction &MF, + unsigned FrameLabelId, + unsigned ReadyLabelId) const { MachineFrameInfo *MFI = MF.getFrameInfo(); MachineModuleInfo *MMI = MFI->getMachineModuleInfo(); - if (!MMI) return; - - // Add callee saved registers to move list. - const std::vector &CSI = MFI->getCalleeSavedInfo(); - if (CSI.empty()) return; + if (!MMI) + return; + uint64_t StackSize = MFI->getStackSize(); std::vector &Moves = MMI->getFrameMoves(); const TargetData *TD = MF.getTarget().getTargetData(); @@ -663,30 +662,62 @@ TargetFrameInfo::StackGrowsUp ? TD->getPointerSize() : -TD->getPointerSize()); + MachineLocation FPDst(hasFP(MF) ? FramePtr : StackPtr); + MachineLocation FPSrc(MachineLocation::VirtualFP); + Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); + + if (StackSize) { + // Show update of SP. + if (hasFP(MF)) { + // Adjust SP + MachineLocation SPDst(MachineLocation::VirtualFP); + MachineLocation SPSrc(MachineLocation::VirtualFP, 2*stackGrowth); + Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); + } else { + MachineLocation SPDst(MachineLocation::VirtualFP); + MachineLocation SPSrc(MachineLocation::VirtualFP, + -StackSize+stackGrowth); + Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); + } + } else { + // FIXME: Verify & implement for FP + MachineLocation SPDst(StackPtr); + MachineLocation SPSrc(StackPtr, stackGrowth); + Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); + } + + // Add callee saved registers to move list. + const std::vector &CSI = MFI->getCalleeSavedInfo(); + // FIXME: This is dirty hack. The code itself is pretty mess right now. // It should be rewritten from scratch and generalized sometimes. // Determine maximum offset (minumum due to stack growth) int64_t MaxOffset = 0; - for (std::vector::const_iterator - I = CSI.begin(), E = CSI.end(); I != E; ++I) + for (unsigned I = 0, E = CSI.size(); I!=E; ++I) MaxOffset = std::min(MaxOffset, - MFI->getObjectOffset(I->getFrameIdx())); - - // Calculate offsets. - int64_t saveAreaOffset = (hasFP(MF) ? 3 : 2) * stackGrowth; - for (std::vector::const_iterator - I = CSI.begin(), E = CSI.end(); I != E; ++I) { - int64_t Offset = MFI->getObjectOffset(I->getFrameIdx()); - unsigned Reg = I->getReg(); - Offset = MaxOffset - Offset + saveAreaOffset; + MFI->getObjectOffset(CSI[I].getFrameIdx())); + // Calculate offsets + int64_t saveAreaOffset = (hasFP(MF) ? 3 : 2)*stackGrowth; + for (unsigned I = 0, E = CSI.size(); I!=E; ++I) { + int64_t Offset = MFI->getObjectOffset(CSI[I].getFrameIdx()); + unsigned Reg = CSI[I].getReg(); + Offset = (MaxOffset-Offset+saveAreaOffset); MachineLocation CSDst(MachineLocation::VirtualFP, Offset); MachineLocation CSSrc(Reg); - Moves.push_back(MachineMove(LabelId, CSDst, CSSrc)); + Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc)); + } + + if (hasFP(MF)) { + // Save FP + MachineLocation FPDst(MachineLocation::VirtualFP, 2*stackGrowth); + MachineLocation FPSrc(FramePtr); + Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); } } + void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB MachineFrameInfo *MFI = MF.getFrameInfo(); @@ -698,9 +729,11 @@ bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) || !Fn->doesNotThrow() || UnwindTablesMandatory; - bool HasFP = hasFP(MF); DebugLoc DL; + // Prepare for frame info. + unsigned FrameLabelId = 0; + // Get the number of bytes to allocate from the FrameInfo. uint64_t StackSize = MFI->getStackSize(); @@ -724,7 +757,7 @@ !MFI->hasCalls() && // No calls. !Subtarget->isTargetWin64()) { // Win64 has no Red Zone uint64_t MinSize = X86FI->getCalleeSavedFrameSize(); - if (HasFP) MinSize += SlotSize; + if (hasFP(MF)) MinSize += SlotSize; StackSize = std::max(MinSize, StackSize > 128 ? StackSize - 128 : 0); MFI->setStackSize(StackSize); @@ -741,16 +774,8 @@ MI->getOperand(3).setIsDead(); } - // uint64_t StackSize = MFI->getStackSize(); - std::vector &Moves = MMI->getFrameMoves(); - const TargetData *TD = MF.getTarget().getTargetData(); - int stackGrowth = - (MF.getTarget().getFrameInfo()->getStackGrowthDirection() == - TargetFrameInfo::StackGrowsUp ? - TD->getPointerSize() : -TD->getPointerSize()); - uint64_t NumBytes = 0; - if (HasFP) { + if (hasFP(MF)) { // Calculate required stack adjustment uint64_t FrameSize = StackSize - SlotSize; if (needsStackRealignment(MF)) @@ -758,38 +783,19 @@ NumBytes = FrameSize - X86FI->getCalleeSavedFrameSize(); - // Get the offset of the stack slot for the EBP register, which is + // Get the offset of the stack slot for the EBP register... which is // guaranteed to be the last slot by processFunctionBeforeFrameFinalized. // Update the frame offset adjustment. MFI->setOffsetAdjustment(-NumBytes); - // Save EBP/RBP into the appropriate stack slot... + // Save EBP into the appropriate stack slot... BuildMI(MBB, MBBI, DL, TII.get(Is64Bit ? X86::PUSH64r : X86::PUSH32r)) .addReg(FramePtr, RegState::Kill); if (needsFrameMoves) { // Mark effective beginning of when frame pointer becomes valid. - unsigned FrameLabelId = MMI->NextLabelID(); + FrameLabelId = MMI->NextLabelID(); BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(FrameLabelId); - - // Define the current CFA rule to use the provided offset. - if (StackSize) { - MachineLocation SPDst(MachineLocation::VirtualFP); - MachineLocation SPSrc(MachineLocation::VirtualFP, - HasFP ? 2 * stackGrowth : - -StackSize + stackGrowth); - Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); - } else { - // FIXME: Verify & implement for FP - MachineLocation SPDst(StackPtr); - MachineLocation SPSrc(StackPtr, stackGrowth); - Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); - } - - // Change the rule for the FramePtr to be an "offset" rule. - MachineLocation FPDst(MachineLocation::VirtualFP, 2 * stackGrowth); - MachineLocation FPSrc(FramePtr); - Moves.push_back(MachineMove(FrameLabelId, FPDst, FPSrc)); } // Update EBP with the new base value... @@ -797,16 +803,6 @@ TII.get(Is64Bit ? X86::MOV64rr : X86::MOV32rr), FramePtr) .addReg(StackPtr); - if (needsFrameMoves) { - unsigned FrameLabelId = MMI->NextLabelID(); - BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(FrameLabelId); - - // Define the current CFA to use the EBP/RBP register. - MachineLocation FPDst(FramePtr); - MachineLocation FPSrc(MachineLocation::VirtualFP); - Moves.push_back(MachineMove(FrameLabelId, FPDst, FPSrc)); - } - // Mark the FramePtr as live-in in every block except the entry. for (MachineFunction::iterator I = next(MF.begin()), E = MF.end(); I != E; ++I) @@ -826,22 +822,10 @@ } // Skip the callee-saved push instructions. - bool RegsSaved = false; while (MBBI != MBB.end() && (MBBI->getOpcode() == X86::PUSH32r || - MBBI->getOpcode() == X86::PUSH64r)) { - RegsSaved = true; + MBBI->getOpcode() == X86::PUSH64r)) ++MBBI; - } - - if (RegsSaved && needsFrameMoves) { - // Mark end of callee-saved push instructions. - unsigned LabelId = MMI->NextLabelID(); - BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(LabelId); - - // Emit DWARF info specifying the offsets of the callee-saved registers. - emitCalleeSavedFrameMoves(MF, LabelId); - } if (MBBI != MBB.end()) DL = MBBI->getDebugLoc(); @@ -898,6 +882,14 @@ if (NumBytes) emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit, TII); } + + if (needsFrameMoves) { + unsigned ReadyLabelId = 0; + // Mark effective beginning of when frame pointer is ready. + ReadyLabelId = MMI->NextLabelID(); + BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(ReadyLabelId); + emitFrameMoves(MF, FrameLabelId, ReadyLabelId); + } } void X86RegisterInfo::emitEpilogue(MachineFunction &MF, Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.h?rev=74970&r1=74969&r2=74970&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.h Tue Jul 7 18:37:49 2009 @@ -136,10 +136,12 @@ void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, RegScavenger *RS = NULL) const; - void emitCalleeSavedFrameMoves(MachineFunction &MF, unsigned LabelId) const; void emitPrologue(MachineFunction &MF) const; void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; + void emitFrameMoves(MachineFunction &MF, + unsigned FrameLabelId, unsigned ReadyLabelId) const; + // Debug information queries. unsigned getRARegister() const; unsigned getFrameRegister(MachineFunction &MF) const; From evan.cheng at apple.com Tue Jul 7 18:40:26 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Jul 2009 23:40:26 -0000 Subject: [llvm-commits] [llvm] r74972 - in /llvm/trunk/lib/Target/ARM: ARMCodeEmitter.cpp ARMInstrInfo.td Message-ID: <200907072340.n67NeQcV004599@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jul 7 18:40:25 2009 New Revision: 74972 URL: http://llvm.org/viewvc/llvm-project?rev=74972&view=rev Log: Statically encode bit 25 to indicate immediate form of data processing instructions. Patch by Sean Callanan. Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=74972&r1=74971&r2=74972&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Tue Jul 7 18:40:25 2009 @@ -528,7 +528,6 @@ Binary |= ARMRegisterInfo::getRegisterNumbering(ARM::PC) << ARMII::RegRnShift; // Encode the displacement. - // Set bit I(25) to identify this is the immediate form of . Binary |= 1 << ARMII::I_BitShift; emitJumpTableAddress(MI.getOperand(1).getIndex(), ARM::reloc_arm_jt_base); @@ -797,7 +796,6 @@ } // Encode so_imm. - // Set bit I(25) to identify this is the immediate form of . Binary |= 1 << ARMII::I_BitShift; Binary |= getMachineSoImmOpValue(MO.getImm()); Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=74972&r1=74971&r2=74972&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Jul 7 18:40:25 2009 @@ -352,15 +352,20 @@ bit Commutable = 0> { def ri : AsI1; + [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> { + let Inst{25} = 1; + } def rr : AsI1 { + let Inst{25} = 0; let isCommutable = Commutable; } def rs : AsI1; + [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> { + let Inst{25} = 0; + } } /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the @@ -370,15 +375,20 @@ bit Commutable = 0> { def ri : AI1; + [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> { + let Inst{25} = 1; + } def rr : AI1 { let isCommutable = Commutable; + let Inst{25} = 0; } def rs : AI1; + [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> { + let Inst{25} = 0; + } } } @@ -390,15 +400,20 @@ bit Commutable = 0> { def ri : AI1; + [(opnode GPR:$a, so_imm:$b)]> { + let Inst{25} = 1; + } def rr : AI1 { + let Inst{25} = 0; let isCommutable = Commutable; } def rs : AI1; + [(opnode GPR:$a, so_reg:$b)]> { + let Inst{25} = 0; + } } } @@ -441,35 +456,43 @@ def ri : AsI1, - Requires<[IsARM, CarryDefIsUnused]>; + Requires<[IsARM, CarryDefIsUnused]> { + let Inst{25} = 1; + } def rr : AsI1, Requires<[IsARM, CarryDefIsUnused]> { let isCommutable = Commutable; + let Inst{25} = 0; } def rs : AsI1, - Requires<[IsARM, CarryDefIsUnused]>; + Requires<[IsARM, CarryDefIsUnused]> { + let Inst{25} = 0; + } // Carry setting variants def Sri : AXI1, Requires<[IsARM, CarryDefIsUsed]> { - let Defs = [CPSR]; + let Defs = [CPSR]; + let Inst{25} = 1; } def Srr : AXI1, Requires<[IsARM, CarryDefIsUsed]> { - let Defs = [CPSR]; + let Defs = [CPSR]; + let Inst{25} = 0; } def Srs : AXI1, Requires<[IsARM, CarryDefIsUsed]> { - let Defs = [CPSR]; + let Defs = [CPSR]; + let Inst{25} = 0; } } } @@ -570,7 +593,9 @@ "${:private}PCRELL${:uid}+8))\n"), !strconcat("${:private}PCRELL${:uid}:\n\t", "add$p $dst, pc, #PCRELV${:uid}")), - []>; + []> { + let Inst{25} = 1; +} //===----------------------------------------------------------------------===// // Control Flow Instructions. From resistor at mac.com Tue Jul 7 18:43:39 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Jul 2009 23:43:39 -0000 Subject: [llvm-commits] [llvm] r74973 - in /llvm/trunk: include/llvm/Intrinsics.h lib/VMCore/AutoUpgrade.cpp lib/VMCore/BasicBlock.cpp lib/VMCore/Function.cpp Message-ID: <200907072343.n67Nhepu004738@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 18:43:39 2009 New Revision: 74973 URL: http://llvm.org/viewvc/llvm-project?rev=74973&view=rev Log: LLVMContext-ification. Modified: llvm/trunk/include/llvm/Intrinsics.h llvm/trunk/lib/VMCore/AutoUpgrade.cpp llvm/trunk/lib/VMCore/BasicBlock.cpp llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/include/llvm/Intrinsics.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=74973&r1=74972&r2=74973&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.h (original) +++ llvm/trunk/include/llvm/Intrinsics.h Tue Jul 7 18:43:39 2009 @@ -23,6 +23,7 @@ class Type; class FunctionType; class Function; +class LLVMContext; class Module; class AttrListPtr; @@ -47,7 +48,8 @@ /// Intrinsic::getType(ID) - Return the function type for an intrinsic. /// - const FunctionType *getType(ID id, const Type **Tys = 0, unsigned numTys = 0); + const FunctionType *getType(LLVMContext &Context, ID id, + const Type **Tys = 0, unsigned numTys = 0); /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be /// overloaded. Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=74973&r1=74972&r2=74973&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Tue Jul 7 18:43:39 2009 @@ -14,6 +14,7 @@ #include "llvm/AutoUpgrade.h" #include "llvm/Constants.h" #include "llvm/Function.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" @@ -25,6 +26,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { assert(F && "Illegal to upgrade a non-existent Function."); + LLVMContext* Context = F->getContext(); + // Get the Function's name. const std::string& Name = F->getName(); @@ -162,7 +165,8 @@ Name.compare(13,4,"psra", 4) == 0 || Name.compare(13,4,"psrl", 4) == 0) && Name[17] != 'i') { - const llvm::Type *VT = VectorType::get(IntegerType::get(64), 1); + const llvm::Type *VT = + Context->getVectorType(Context->getIntegerType(64), 1); // We don't have to do anything if the parameter already has // the correct type. @@ -227,6 +231,8 @@ // order to seamlessly integrate with existing context. void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Function *F = CI->getCalledFunction(); + LLVMContext* Context = F->getContext(); + assert(F && "CallInst has no function associated with it."); if (!NewFn) { @@ -259,59 +265,60 @@ Value *Op0 = CI->getOperand(1); ShuffleVectorInst *SI = NULL; if (isLoadH || isLoadL) { - Value *Op1 = UndefValue::get(Op0->getType()); + Value *Op1 = Context->getUndef(Op0->getType()); Value *Addr = new BitCastInst(CI->getOperand(2), - PointerType::getUnqual(Type::DoubleTy), + Context->getPointerTypeUnqual(Type::DoubleTy), "upgraded.", CI); Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI); - Value *Idx = ConstantInt::get(Type::Int32Ty, 0); + Value *Idx = Context->getConstantInt(Type::Int32Ty, 0); Op1 = InsertElementInst::Create(Op1, Load, Idx, "upgraded.", CI); if (isLoadH) { - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 0)); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 0)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); } else { - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2)); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 1)); } - Value *Mask = ConstantVector::get(Idxs); + Value *Mask = Context->getConstantVector(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } else if (isMovL) { - Constant *Zero = ConstantInt::get(Type::Int32Ty, 0); + Constant *Zero = Context->getConstantInt(Type::Int32Ty, 0); Idxs.push_back(Zero); Idxs.push_back(Zero); Idxs.push_back(Zero); Idxs.push_back(Zero); - Value *ZeroV = ConstantVector::get(Idxs); + Value *ZeroV = Context->getConstantVector(Idxs); Idxs.clear(); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 4)); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 5)); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2)); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3)); - Value *Mask = ConstantVector::get(Idxs); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 4)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 5)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 3)); + Value *Mask = Context->getConstantVector(Idxs); SI = new ShuffleVectorInst(ZeroV, Op0, Mask, "upgraded.", CI); } else if (isMovSD || isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) { Value *Op1 = CI->getOperand(2); if (isMovSD) { - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2)); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 1)); } else if (isUnpckhPD || isPunpckhQPD) { - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1)); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 1)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 3)); } else { - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 0)); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 0)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); } - Value *Mask = ConstantVector::get(Idxs); + Value *Mask = Context->getConstantVector(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } else if (isShufPD) { Value *Op1 = CI->getOperand(2); unsigned MaskVal = cast(CI->getOperand(3))->getZExtValue(); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, MaskVal & 1)); - Idxs.push_back(ConstantInt::get(Type::Int32Ty, ((MaskVal >> 1) & 1)+2)); - Value *Mask = ConstantVector::get(Idxs); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, MaskVal & 1)); + Idxs.push_back(Context->getConstantInt(Type::Int32Ty, + ((MaskVal >> 1) & 1)+2)); + Value *Mask = Context->getConstantVector(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } Modified: llvm/trunk/lib/VMCore/BasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/BasicBlock.cpp?rev=74973&r1=74972&r2=74973&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/BasicBlock.cpp (original) +++ llvm/trunk/lib/VMCore/BasicBlock.cpp Tue Jul 7 18:43:39 2009 @@ -14,6 +14,7 @@ #include "llvm/BasicBlock.h" #include "llvm/Constants.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/Type.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/CFG.h" @@ -202,7 +203,7 @@ PN->replaceAllUsesWith(PN->getOperand(0)); else // We are left with an infinite loop with no entries: kill the PHI. - PN->replaceAllUsesWith(UndefValue::get(PN->getType())); + PN->replaceAllUsesWith(getContext()->getUndef(PN->getType())); getInstList().pop_front(); // Remove the PHI node } Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=74973&r1=74972&r2=74973&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Tue Jul 7 18:43:39 2009 @@ -14,6 +14,7 @@ #include "llvm/Module.h" #include "llvm/DerivedTypes.h" #include "llvm/IntrinsicInst.h" +#include "llvm/LLVMContext.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" @@ -336,7 +337,8 @@ return Result; } -const FunctionType *Intrinsic::getType(ID id, const Type **Tys, +const FunctionType *Intrinsic::getType(LLVMContext &Context, + ID id, const Type **Tys, unsigned numTys) { const Type *ResultTy = NULL; std::vector ArgTys; @@ -346,7 +348,7 @@ #include "llvm/Intrinsics.gen" #undef GET_INTRINSIC_GENERATOR - return FunctionType::get(ResultTy, ArgTys, IsVarArg); + return Context.getFunctionType(ResultTy, ArgTys, IsVarArg); } bool Intrinsic::isOverloaded(ID id) { @@ -370,7 +372,8 @@ // because intrinsics must be a specific type. return cast(M->getOrInsertFunction(getName(id, Tys, numTys), - getType(id, Tys, numTys))); + getType(M->getContext(), + id, Tys, numTys))); } // This defines the "Intrinsic::getIntrinsicForGCCBuiltin()" method. From evan.cheng at apple.com Tue Jul 7 18:45:11 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Jul 2009 23:45:11 -0000 Subject: [llvm-commits] [llvm] r74974 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <200907072345.n67NjBcU004789@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jul 7 18:45:10 2009 New Revision: 74974 URL: http://llvm.org/viewvc/llvm-project?rev=74974&view=rev Log: Also statically set bit 25 for BR_JT instructions. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=74974&r1=74973&r2=74974&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Jul 7 18:45:10 2009 @@ -697,7 +697,7 @@ [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> { let Inst{20} = 0; // S Bit let Inst{24-21} = 0b1101; - let Inst{27-26} = {0,0}; + let Inst{27-25} = 0b000; } def BR_JTm : JTI<(outs), (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id), @@ -708,7 +708,7 @@ let Inst{21} = 0; // W bit let Inst{22} = 0; // B bit let Inst{24} = 1; // P bit - let Inst{27-26} = {0,1}; + let Inst{27-25} = 0b011; } def BR_JTadd : JTI<(outs), (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id), @@ -717,7 +717,7 @@ imm:$id)]> { let Inst{20} = 0; // S bit let Inst{24-21} = 0b0100; - let Inst{27-26} = {0,0}; + let Inst{27-25} = 0b000; } } // isNotDuplicable = 1, isIndirectBranch = 1 } // isBarrier = 1 From howard0su at gmail.com Tue Jul 7 18:46:23 2009 From: howard0su at gmail.com (Howard Su) Date: Wed, 8 Jul 2009 07:46:23 +0800 Subject: [llvm-commits] [llvm] r74927 - in /llvm/trunk: include/llvm/System/DynamicLibrary.h lib/System/DynamicLibrary.cpp In-Reply-To: <200907071817.n67IHbJ8024168@zion.cs.uiuc.edu> References: <200907071817.n67IHbJ8024168@zion.cs.uiuc.edu> Message-ID: can you also keep Windows version of DynamicLibrary.inc compilable? On Wed, Jul 8, 2009 at 2:17 AM, Chris Lattner wrote: > Author: lattner > Date: Tue Jul 7 13:17:07 2009 > New Revision: 74927 > > URL: http://llvm.org/viewvc/llvm-project?rev=74927&view=rev > Log: > Eliminate the static constructors and locks from DynamicLibrary.cpp. > This fixes PR4512 and eliminating static ctors is always good. Losing > thread safety is unfortunate, but the code is just incredibly poorly > designed. > > If someone is interested, the "right" solution is to split > DynamicLibrary.cpp into two separate pieces: a stateless piece in > libsystem, and a simple support file in libsupport that has the > "state" (e.g. AddSymbol) in managed static objects. > > Doing this would both fix memory leaks we already have, as well as make > the code thread safe again. it would also make sense to move all the > unix specific code in System/DynamicLibrary.cpp into > System/Unix/DynamicLibrary.inc. > > > Modified: > llvm/trunk/include/llvm/System/DynamicLibrary.h > llvm/trunk/lib/System/DynamicLibrary.cpp > > Modified: llvm/trunk/include/llvm/System/DynamicLibrary.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/DynamicLibrary.h?rev=74927&r1=74926&r2=74927&view=diff > > > ============================================================================== > --- llvm/trunk/include/llvm/System/DynamicLibrary.h (original) > +++ llvm/trunk/include/llvm/System/DynamicLibrary.h Tue Jul 7 13:17:07 > 2009 > @@ -36,6 +36,9 @@ > /// and will only be unloaded when the program terminates. This > returns > /// false on success or returns true and fills in *ErrMsg on failure. > /// @brief Open a dynamic library permanently. > + /// > + /// NOTE: This function is not thread safe. > + /// > static bool LoadLibraryPermanently(const char *filename, > std::string *ErrMsg = 0); > > @@ -46,9 +49,15 @@ > /// as ephemerally loaded libraries (constructors). > /// @throws std::string on error. > /// @brief Search through libraries for address of a symbol > + /// > + /// NOTE: This function is not thread safe. > + /// > static void *SearchForAddressOfSymbol(const char *symbolName); > > /// @brief Convenience function for C++ophiles. > + /// > + /// NOTE: This function is not thread safe. > + /// > static void *SearchForAddressOfSymbol(const std::string &symbolName) { > return SearchForAddressOfSymbol(symbolName.c_str()); > } > @@ -57,9 +66,15 @@ > /// value \p symbolValue. These symbols are searched before any > /// libraries. > /// @brief Add searchable symbol/value pair. > + /// > + /// NOTE: This function is not thread safe. > + /// > static void AddSymbol(const char *symbolName, void *symbolValue); > > /// @brief Convenience function for C++ophiles. > + /// > + /// NOTE: This function is not thread safe. > + /// > static void AddSymbol(const std::string &symbolName, void *symbolValue) > { > AddSymbol(symbolName.c_str(), symbolValue); > } > > Modified: llvm/trunk/lib/System/DynamicLibrary.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/DynamicLibrary.cpp?rev=74927&r1=74926&r2=74927&view=diff > > > ============================================================================== > --- llvm/trunk/lib/System/DynamicLibrary.cpp (original) > +++ llvm/trunk/lib/System/DynamicLibrary.cpp Tue Jul 7 13:17:07 2009 > @@ -9,11 +9,13 @@ > // > // This header file implements the operating system DynamicLibrary > concept. > // > +// FIXME: This file leaks the ExplicitSymbols and OpenedHandles vector, > and is > +// not thread safe! > +// > > //===----------------------------------------------------------------------===// > > #include "llvm/System/DynamicLibrary.h" > #include "llvm/Support/ManagedStatic.h" > -#include "llvm/System/RWMutex.h" > #include "llvm/Config/config.h" > #include > #include > @@ -21,13 +23,13 @@ > #include > > // Collection of symbol name/value pairs to be searched prior to any > libraries. > -static std::map symbols; > -static llvm::sys::SmartRWMutex SymbolsLock; > +static std::map *ExplicitSymbols = 0; > > void llvm::sys::DynamicLibrary::AddSymbol(const char* symbolName, > void *symbolValue) { > - llvm::sys::SmartScopedWriter Writer(&SymbolsLock); > - symbols[symbolName] = symbolValue; > + if (ExplicitSymbols == 0) > + ExplicitSymbols = new std::map(); > + (*ExplicitSymbols)[symbolName] = symbolValue; > } > > #ifdef LLVM_ON_WIN32 > @@ -37,7 +39,6 @@ > #else > > #include > -#include > using namespace llvm; > using namespace llvm::sys; > > @@ -46,44 +47,44 @@ > //=== independent code. > > //===----------------------------------------------------------------------===// > > -static std::vector OpenedHandles; > +static std::vector *OpenedHandles = 0; > > > bool DynamicLibrary::LoadLibraryPermanently(const char *Filename, > std::string *ErrMsg) { > - SmartScopedWriter Writer(&SymbolsLock); > void *H = dlopen(Filename, RTLD_LAZY|RTLD_GLOBAL); > if (H == 0) { > - if (ErrMsg) > - *ErrMsg = dlerror(); > + if (ErrMsg) *ErrMsg = dlerror(); > return true; > } > - OpenedHandles.push_back(H); > + if (OpenedHandles == 0) > + OpenedHandles = new std::vector(); > + OpenedHandles->push_back(H); > return false; > } > > void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { > // First check symbols added via AddSymbol(). > - SymbolsLock.reader_acquire(); > - std::map::iterator I = symbols.find(symbolName); > - std::map::iterator E = symbols.end(); > - SymbolsLock.reader_release(); > + if (ExplicitSymbols) { > + std::map::iterator I = > + ExplicitSymbols->find(symbolName); > + std::map::iterator E = ExplicitSymbols->end(); > > - if (I != E) > - return I->second; > + if (I != E) > + return I->second; > + } > > - SymbolsLock.writer_acquire(); > // Now search the libraries. > - for (std::vector::iterator I = OpenedHandles.begin(), > - E = OpenedHandles.end(); I != E; ++I) { > - //lt_ptr ptr = lt_dlsym(*I, symbolName); > - void *ptr = dlsym(*I, symbolName); > - if (ptr) { > - SymbolsLock.writer_release(); > - return ptr; > + if (OpenedHandles) { > + for (std::vector::iterator I = OpenedHandles->begin(), > + E = OpenedHandles->end(); I != E; ++I) { > + //lt_ptr ptr = lt_dlsym(*I, symbolName); > + void *ptr = dlsym(*I, symbolName); > + if (ptr) { > + return ptr; > + } > } > } > - SymbolsLock.writer_release(); > > #define EXPLICIT_SYMBOL(SYM) \ > extern void *SYM; if (!strcmp(symbolName, #SYM)) return &SYM > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- -Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090708/dd442054/attachment.html From evan.cheng at apple.com Tue Jul 7 19:05:05 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 08 Jul 2009 00:05:05 -0000 Subject: [llvm-commits] [llvm] r74976 - in /llvm/trunk/lib/Target/ARM: ARMCodeEmitter.cpp README-Thumb2.txt Message-ID: <200907080005.n68055AQ005601@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jul 7 19:05:05 2009 New Revision: 74976 URL: http://llvm.org/viewvc/llvm-project?rev=74976&view=rev Log: Add a todo. Added: llvm/trunk/lib/Target/ARM/README-Thumb2.txt Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=74976&r1=74975&r2=74976&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Tue Jul 7 19:05:05 2009 @@ -1165,7 +1165,8 @@ emitDataProcessingInstruction(MI, ARM::PC); // Then emit the inline jump table. - unsigned JTIndex = (TID.Opcode == ARM::BR_JTr || TID.Opcode == ARM::t2BR_JTr) + unsigned JTIndex = + (TID.Opcode == ARM::BR_JTr || TID.Opcode == ARM::t2BR_JTr) ? MI.getOperand(1).getIndex() : MI.getOperand(2).getIndex(); emitInlineJumpTable(JTIndex); return; Added: llvm/trunk/lib/Target/ARM/README-Thumb2.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README-Thumb2.txt?rev=74976&view=auto ============================================================================== --- llvm/trunk/lib/Target/ARM/README-Thumb2.txt (added) +++ llvm/trunk/lib/Target/ARM/README-Thumb2.txt Tue Jul 7 19:05:05 2009 @@ -0,0 +1,7 @@ +//===---------------------------------------------------------------------===// +// Random ideas for the ARM backend (Thumb2 specific). +//===---------------------------------------------------------------------===// + +* We should model IT instructions explicitly. We should introduce them (even if + if-converter is not run, the function could still contain movcc's) before + PEI since passes starting from PEI may require exact code size. From clattner at apple.com Tue Jul 7 19:05:17 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 17:05:17 -0700 Subject: [llvm-commits] [llvm] r74927 - in /llvm/trunk: include/llvm/System/DynamicLibrary.h lib/System/DynamicLibrary.cpp In-Reply-To: References: <200907071817.n67IHbJ8024168@zion.cs.uiuc.edu> Message-ID: <25333B6A-E9F4-4346-A577-75412D3CD802@apple.com> On Jul 7, 2009, at 4:46 PM, Howard Su wrote: > can you also keep Windows version of DynamicLibrary.inc compilable? Is it not? What problem do you see? I don't have a windows box. -Chris > > On Wed, Jul 8, 2009 at 2:17 AM, Chris Lattner > wrote: > Author: lattner > Date: Tue Jul 7 13:17:07 2009 > New Revision: 74927 > > URL: http://llvm.org/viewvc/llvm-project?rev=74927&view=rev > Log: > Eliminate the static constructors and locks from DynamicLibrary.cpp. > This fixes PR4512 and eliminating static ctors is always good. Losing > thread safety is unfortunate, but the code is just incredibly poorly > designed. > > If someone is interested, the "right" solution is to split > DynamicLibrary.cpp into two separate pieces: a stateless piece in > libsystem, and a simple support file in libsupport that has the > "state" (e.g. AddSymbol) in managed static objects. > > Doing this would both fix memory leaks we already have, as well as > make > the code thread safe again. it would also make sense to move all the > unix specific code in System/DynamicLibrary.cpp into > System/Unix/DynamicLibrary.inc. > > > Modified: > llvm/trunk/include/llvm/System/DynamicLibrary.h > llvm/trunk/lib/System/DynamicLibrary.cpp > > Modified: llvm/trunk/include/llvm/System/DynamicLibrary.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/DynamicLibrary.h?rev=74927&r1=74926&r2=74927&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/System/DynamicLibrary.h (original) > +++ llvm/trunk/include/llvm/System/DynamicLibrary.h Tue Jul 7 > 13:17:07 2009 > @@ -36,6 +36,9 @@ > /// and will only be unloaded when the program terminates. This > returns > /// false on success or returns true and fills in *ErrMsg on > failure. > /// @brief Open a dynamic library permanently. > + /// > + /// NOTE: This function is not thread safe. > + /// > static bool LoadLibraryPermanently(const char *filename, > std::string *ErrMsg = 0); > > @@ -46,9 +49,15 @@ > /// as ephemerally loaded libraries (constructors). > /// @throws std::string on error. > /// @brief Search through libraries for address of a symbol > + /// > + /// NOTE: This function is not thread safe. > + /// > static void *SearchForAddressOfSymbol(const char *symbolName); > > /// @brief Convenience function for C++ophiles. > + /// > + /// NOTE: This function is not thread safe. > + /// > static void *SearchForAddressOfSymbol(const std::string > &symbolName) { > return SearchForAddressOfSymbol(symbolName.c_str()); > } > @@ -57,9 +66,15 @@ > /// value \p symbolValue. These symbols are searched before any > /// libraries. > /// @brief Add searchable symbol/value pair. > + /// > + /// NOTE: This function is not thread safe. > + /// > static void AddSymbol(const char *symbolName, void *symbolValue); > > /// @brief Convenience function for C++ophiles. > + /// > + /// NOTE: This function is not thread safe. > + /// > static void AddSymbol(const std::string &symbolName, void > *symbolValue) { > AddSymbol(symbolName.c_str(), symbolValue); > } > > Modified: llvm/trunk/lib/System/DynamicLibrary.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/DynamicLibrary.cpp?rev=74927&r1=74926&r2=74927&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/System/DynamicLibrary.cpp (original) > +++ llvm/trunk/lib/System/DynamicLibrary.cpp Tue Jul 7 13:17:07 2009 > @@ -9,11 +9,13 @@ > // > // This header file implements the operating system DynamicLibrary > concept. > // > +// FIXME: This file leaks the ExplicitSymbols and OpenedHandles > vector, and is > +// not thread safe! > +// > // > = > = > = > ----------------------------------------------------------------------= > ==// > > #include "llvm/System/DynamicLibrary.h" > #include "llvm/Support/ManagedStatic.h" > -#include "llvm/System/RWMutex.h" > #include "llvm/Config/config.h" > #include > #include > @@ -21,13 +23,13 @@ > #include > > // Collection of symbol name/value pairs to be searched prior to > any libraries. > -static std::map symbols; > -static llvm::sys::SmartRWMutex SymbolsLock; > +static std::map *ExplicitSymbols = 0; > > void llvm::sys::DynamicLibrary::AddSymbol(const char* symbolName, > void *symbolValue) { > - llvm::sys::SmartScopedWriter Writer(&SymbolsLock); > - symbols[symbolName] = symbolValue; > + if (ExplicitSymbols == 0) > + ExplicitSymbols = new std::map(); > + (*ExplicitSymbols)[symbolName] = symbolValue; > } > > #ifdef LLVM_ON_WIN32 > @@ -37,7 +39,6 @@ > #else > > #include > -#include > using namespace llvm; > using namespace llvm::sys; > > @@ -46,44 +47,44 @@ > //=== independent code. > // > = > = > = > ----------------------------------------------------------------------= > ==// > > -static std::vector OpenedHandles; > +static std::vector *OpenedHandles = 0; > > > bool DynamicLibrary::LoadLibraryPermanently(const char *Filename, > std::string *ErrMsg) { > - SmartScopedWriter Writer(&SymbolsLock); > void *H = dlopen(Filename, RTLD_LAZY|RTLD_GLOBAL); > if (H == 0) { > - if (ErrMsg) > - *ErrMsg = dlerror(); > + if (ErrMsg) *ErrMsg = dlerror(); > return true; > } > - OpenedHandles.push_back(H); > + if (OpenedHandles == 0) > + OpenedHandles = new std::vector(); > + OpenedHandles->push_back(H); > return false; > } > > void* DynamicLibrary::SearchForAddressOfSymbol(const char* > symbolName) { > // First check symbols added via AddSymbol(). > - SymbolsLock.reader_acquire(); > - std::map::iterator I = > symbols.find(symbolName); > - std::map::iterator E = symbols.end(); > - SymbolsLock.reader_release(); > + if (ExplicitSymbols) { > + std::map::iterator I = > + ExplicitSymbols->find(symbolName); > + std::map::iterator E = ExplicitSymbols- > >end(); > > - if (I != E) > - return I->second; > + if (I != E) > + return I->second; > + } > > - SymbolsLock.writer_acquire(); > // Now search the libraries. > - for (std::vector::iterator I = OpenedHandles.begin(), > - E = OpenedHandles.end(); I != E; ++I) { > - //lt_ptr ptr = lt_dlsym(*I, symbolName); > - void *ptr = dlsym(*I, symbolName); > - if (ptr) { > - SymbolsLock.writer_release(); > - return ptr; > + if (OpenedHandles) { > + for (std::vector::iterator I = OpenedHandles->begin(), > + E = OpenedHandles->end(); I != E; ++I) { > + //lt_ptr ptr = lt_dlsym(*I, symbolName); > + void *ptr = dlsym(*I, symbolName); > + if (ptr) { > + return ptr; > + } > } > } > - SymbolsLock.writer_release(); > > #define EXPLICIT_SYMBOL(SYM) \ > extern void *SYM; if (!strcmp(symbolName, #SYM)) return &SYM > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > > -- > -Howard > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090707/d5b973d3/attachment.html From howard0su at gmail.com Tue Jul 7 19:10:28 2009 From: howard0su at gmail.com (Howard Su) Date: Wed, 8 Jul 2009 08:10:28 +0800 Subject: [llvm-commits] [llvm] r74927 - in /llvm/trunk: include/llvm/System/DynamicLibrary.h lib/System/DynamicLibrary.cpp In-Reply-To: <25333B6A-E9F4-4346-A577-75412D3CD802@apple.com> References: <200907071817.n67IHbJ8024168@zion.cs.uiuc.edu> <25333B6A-E9F4-4346-A577-75412D3CD802@apple.com> Message-ID: [ 0%] Building CXX object lib/System/CMakeFiles/LLVMSystem.dir/DynamicLibrary.c pp.obj DynamicLibrary.cpp c:\llvm\lib\system\Win32/DynamicLibrary.inc(70) : error C2039: 'SmartScopedWrite r' : is not a member of 'llvm::sys' c:\llvm\lib\system\Win32/DynamicLibrary.inc(70) : error C2065: 'SmartScopedWrite r' : undeclared identifier c:\llvm\lib\system\Win32/DynamicLibrary.inc(70) : warning C4804: '<' : unsafe us e of type 'bool' in operation c:\llvm\lib\system\Win32/DynamicLibrary.inc(70) : error C2065: 'SymbolsLock' : u ndeclared identifier c:\llvm\lib\system\Win32/DynamicLibrary.inc(70) : error C3861: 'Writer': identif ier not found c:\llvm\lib\system\Win32/DynamicLibrary.inc(92) : error C2614: 'llvm::sys::Dynam icLibrary' : illegal member initialization: 'handle' is not a base or member c:\llvm\lib\system\Win32/DynamicLibrary.inc(93) : warning C4804: '<' : unsafe us e of type 'bool' in operation c:\llvm\lib\system\Win32/DynamicLibrary.inc(93) : error C3861: 'Writer': identif ier not found c:\llvm\lib\system\Win32/DynamicLibrary.inc(94) : error C2065: 'handle' : undecl ared identifier c:\llvm\lib\system\Win32/DynamicLibrary.inc(98) : error C2600: 'llvm::sys::Dynam icLibrary::~DynamicLibrary' : cannot define a compiler-generated special member function (must be declared in the class first) c:\llvm\lib\system\Win32/DynamicLibrary.inc(99) : error C2039: 'SmartScopedWrite r' : is not a member of 'llvm::sys' This diagnostic occurred in the compiler generated function 'llvm::sys:: DynamicLibrary::~DynamicLibrary(void)' c:\llvm\lib\system\Win32/DynamicLibrary.inc(99) : warning C4804: '<' : unsafe us e of type 'bool' in operation This diagnostic occurred in the compiler generated function 'llvm::sys:: DynamicLibrary::~DynamicLibrary(void)' c:\llvm\lib\system\Win32/DynamicLibrary.inc(99) : error C3861: 'Writer': identif ier not found This diagnostic occurred in the compiler generated function 'llvm::sys:: DynamicLibrary::~DynamicLibrary(void)' c:\llvm\lib\system\Win32/DynamicLibrary.inc(121) : error C2039: 'SmartScopedWrit er' : is not a member of 'llvm::sys' c:\llvm\lib\system\Win32/DynamicLibrary.inc(121) : warning C4804: '<' : unsafe u se of type 'bool' in operation c:\llvm\lib\system\Win32/DynamicLibrary.inc(121) : error C3861: 'Writer': identi fier not found c:\llvm\lib\system\Win32/DynamicLibrary.inc(173) : error C2228: left of '.reader _acquire' must have class/struct/union type is ''unknown-type'' c:\llvm\lib\system\Win32/DynamicLibrary.inc(174) : error C2065: 'symbols' : unde clared identifier c:\llvm\lib\system\Win32/DynamicLibrary.inc(174) : error C2228: left of '.find' must have class/struct/union type is ''unknown-type'' c:\llvm\lib\system\Win32/DynamicLibrary.inc(175) : error C2228: left of '.end' m ust have class/struct/union type is ''unknown-type'' c:\llvm\lib\system\Win32/DynamicLibrary.inc(176) : error C2228: left of '.reader _release' must have class/struct/union type is ''unknown-type'' c:\llvm\lib\system\Win32/DynamicLibrary.inc(181) : error C2228: left of '.writer _acquire' must have class/struct/union type is ''unknown-type'' c:\llvm\lib\system\Win32/DynamicLibrary.inc(186) : error C2228: left of '.writer _release' must have class/struct/union type is ''unknown-type'' c:\llvm\lib\system\Win32/DynamicLibrary.inc(190) : error C2228: left of '.writer _release' must have class/struct/union type is ''unknown-type'' NMAKE : fatal error U1077: 'C:\VC\bin\cl.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: 'c:\vc\bin\nmake.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: 'c:\vc\bin\nmake.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: 'c:\vc\bin\nmake.exe' : return code '0x2' Stop. On Wed, Jul 8, 2009 at 8:05 AM, Chris Lattner wrote: > > On Jul 7, 2009, at 4:46 PM, Howard Su wrote: > > can you also keep Windows version of DynamicLibrary.inc compilable? > > > Is it not? What problem do you see? I don't have a windows box. > > -Chris > > > On Wed, Jul 8, 2009 at 2:17 AM, Chris Lattner wrote: > >> Author: lattner >> Date: Tue Jul 7 13:17:07 2009 >> New Revision: 74927 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=74927&view=rev >> Log: >> Eliminate the static constructors and locks from DynamicLibrary.cpp. >> This fixes PR4512 and eliminating static ctors is always good. Losing >> thread safety is unfortunate, but the code is just incredibly poorly >> designed. >> >> If someone is interested, the "right" solution is to split >> DynamicLibrary.cpp into two separate pieces: a stateless piece in >> libsystem, and a simple support file in libsupport that has the >> "state" (e.g. AddSymbol) in managed static objects. >> >> Doing this would both fix memory leaks we already have, as well as make >> the code thread safe again. it would also make sense to move all the >> unix specific code in System/DynamicLibrary.cpp into >> System/Unix/DynamicLibrary.inc. >> >> >> Modified: >> llvm/trunk/include/llvm/System/DynamicLibrary.h >> llvm/trunk/lib/System/DynamicLibrary.cpp >> >> Modified: llvm/trunk/include/llvm/System/DynamicLibrary.h >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/DynamicLibrary.h?rev=74927&r1=74926&r2=74927&view=diff >> >> >> ============================================================================== >> --- llvm/trunk/include/llvm/System/DynamicLibrary.h (original) >> +++ llvm/trunk/include/llvm/System/DynamicLibrary.h Tue Jul 7 13:17:07 >> 2009 >> @@ -36,6 +36,9 @@ >> /// and will only be unloaded when the program terminates. This >> returns >> /// false on success or returns true and fills in *ErrMsg on failure. >> /// @brief Open a dynamic library permanently. >> + /// >> + /// NOTE: This function is not thread safe. >> + /// >> static bool LoadLibraryPermanently(const char *filename, >> std::string *ErrMsg = 0); >> >> @@ -46,9 +49,15 @@ >> /// as ephemerally loaded libraries (constructors). >> /// @throws std::string on error. >> /// @brief Search through libraries for address of a symbol >> + /// >> + /// NOTE: This function is not thread safe. >> + /// >> static void *SearchForAddressOfSymbol(const char *symbolName); >> >> /// @brief Convenience function for C++ophiles. >> + /// >> + /// NOTE: This function is not thread safe. >> + /// >> static void *SearchForAddressOfSymbol(const std::string &symbolName) { >> return SearchForAddressOfSymbol(symbolName.c_str()); >> } >> @@ -57,9 +66,15 @@ >> /// value \p symbolValue. These symbols are searched before any >> /// libraries. >> /// @brief Add searchable symbol/value pair. >> + /// >> + /// NOTE: This function is not thread safe. >> + /// >> static void AddSymbol(const char *symbolName, void *symbolValue); >> >> /// @brief Convenience function for C++ophiles. >> + /// >> + /// NOTE: This function is not thread safe. >> + /// >> static void AddSymbol(const std::string &symbolName, void >> *symbolValue) { >> AddSymbol(symbolName.c_str(), symbolValue); >> } >> >> Modified: llvm/trunk/lib/System/DynamicLibrary.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/DynamicLibrary.cpp?rev=74927&r1=74926&r2=74927&view=diff >> >> >> ============================================================================== >> --- llvm/trunk/lib/System/DynamicLibrary.cpp (original) >> +++ llvm/trunk/lib/System/DynamicLibrary.cpp Tue Jul 7 13:17:07 2009 >> @@ -9,11 +9,13 @@ >> // >> // This header file implements the operating system DynamicLibrary >> concept. >> // >> +// FIXME: This file leaks the ExplicitSymbols and OpenedHandles vector, >> and is >> +// not thread safe! >> +// >> >> //===----------------------------------------------------------------------===// >> >> #include "llvm/System/DynamicLibrary.h" >> #include "llvm/Support/ManagedStatic.h" >> -#include "llvm/System/RWMutex.h" >> #include "llvm/Config/config.h" >> #include >> #include >> @@ -21,13 +23,13 @@ >> #include >> >> // Collection of symbol name/value pairs to be searched prior to any >> libraries. >> -static std::map symbols; >> -static llvm::sys::SmartRWMutex SymbolsLock; >> +static std::map *ExplicitSymbols = 0; >> >> void llvm::sys::DynamicLibrary::AddSymbol(const char* symbolName, >> void *symbolValue) { >> - llvm::sys::SmartScopedWriter Writer(&SymbolsLock); >> - symbols[symbolName] = symbolValue; >> + if (ExplicitSymbols == 0) >> + ExplicitSymbols = new std::map(); >> + (*ExplicitSymbols)[symbolName] = symbolValue; >> } >> >> #ifdef LLVM_ON_WIN32 >> @@ -37,7 +39,6 @@ >> #else >> >> #include >> -#include >> using namespace llvm; >> using namespace llvm::sys; >> >> @@ -46,44 +47,44 @@ >> //=== independent code. >> >> //===----------------------------------------------------------------------===// >> >> -static std::vector OpenedHandles; >> +static std::vector *OpenedHandles = 0; >> >> >> bool DynamicLibrary::LoadLibraryPermanently(const char *Filename, >> std::string *ErrMsg) { >> - SmartScopedWriter Writer(&SymbolsLock); >> void *H = dlopen(Filename, RTLD_LAZY|RTLD_GLOBAL); >> if (H == 0) { >> - if (ErrMsg) >> - *ErrMsg = dlerror(); >> + if (ErrMsg) *ErrMsg = dlerror(); >> return true; >> } >> - OpenedHandles.push_back(H); >> + if (OpenedHandles == 0) >> + OpenedHandles = new std::vector(); >> + OpenedHandles->push_back(H); >> return false; >> } >> >> void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { >> // First check symbols added via AddSymbol(). >> - SymbolsLock.reader_acquire(); >> - std::map::iterator I = symbols.find(symbolName); >> - std::map::iterator E = symbols.end(); >> - SymbolsLock.reader_release(); >> + if (ExplicitSymbols) { >> + std::map::iterator I = >> + ExplicitSymbols->find(symbolName); >> + std::map::iterator E = ExplicitSymbols->end(); >> >> - if (I != E) >> - return I->second; >> + if (I != E) >> + return I->second; >> + } >> >> - SymbolsLock.writer_acquire(); >> // Now search the libraries. >> - for (std::vector::iterator I = OpenedHandles.begin(), >> - E = OpenedHandles.end(); I != E; ++I) { >> - //lt_ptr ptr = lt_dlsym(*I, symbolName); >> - void *ptr = dlsym(*I, symbolName); >> - if (ptr) { >> - SymbolsLock.writer_release(); >> - return ptr; >> + if (OpenedHandles) { >> + for (std::vector::iterator I = OpenedHandles->begin(), >> + E = OpenedHandles->end(); I != E; ++I) { >> + //lt_ptr ptr = lt_dlsym(*I, symbolName); >> + void *ptr = dlsym(*I, symbolName); >> + if (ptr) { >> + return ptr; >> + } >> } >> } >> - SymbolsLock.writer_release(); >> >> #define EXPLICIT_SYMBOL(SYM) \ >> extern void *SYM; if (!strcmp(symbolName, #SYM)) return &SYM >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > > > -- > -Howard > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > -- -Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090708/bbb2e6d1/attachment.html From sabre at nondot.org Tue Jul 7 19:29:33 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 00:29:33 -0000 Subject: [llvm-commits] [llvm] r74977 - /llvm/trunk/lib/System/Win32/DynamicLibrary.inc Message-ID: <200907080029.n680TXpP006299@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 19:29:32 2009 New Revision: 74977 URL: http://llvm.org/viewvc/llvm-project?rev=74977&view=rev Log: hopefully fix the build on windows. Modified: llvm/trunk/lib/System/Win32/DynamicLibrary.inc Modified: llvm/trunk/lib/System/Win32/DynamicLibrary.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/DynamicLibrary.inc?rev=74977&r1=74976&r2=74977&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/DynamicLibrary.inc (original) +++ llvm/trunk/lib/System/Win32/DynamicLibrary.inc Tue Jul 7 19:29:32 2009 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "Win32.h" +#include "llvm/System/RWMutex.h" #ifdef __MINGW32__ #include From clattner at apple.com Tue Jul 7 19:29:51 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 17:29:51 -0700 Subject: [llvm-commits] [llvm] r74927 - in /llvm/trunk: include/llvm/System/DynamicLibrary.h lib/System/DynamicLibrary.cpp In-Reply-To: References: <200907071817.n67IHbJ8024168@zion.cs.uiuc.edu> <25333B6A-E9F4-4346-A577-75412D3CD802@apple.com> Message-ID: <9F9FFBB6-D779-4B88-A0D6-46FE56964836@apple.com> On Jul 7, 2009, at 5:10 PM, Howard Su wrote: > [ 0%] Building CXX object lib/System/CMakeFiles/LLVMSystem.dir/ > DynamicLibrary.c > pp.obj Ok, does r74977 help? If not, please let me know what the new errors are. -Chris From sabre at nondot.org Tue Jul 7 19:31:34 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 00:31:34 -0000 Subject: [llvm-commits] [llvm] r74978 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/vec_compare.ll Message-ID: <200907080031.n680VYgM006362@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 19:31:33 2009 New Revision: 74978 URL: http://llvm.org/viewvc/llvm-project?rev=74978&view=rev Log: dag combine sext(setcc) -> vsetcc before legalize. To make this safe, VSETCC must define all bits, which is different than it was documented to before. Since all targets that implement VSETCC already have this behavior, and we don't optimize based on this, just change the documentation. We now get nice code for vec_compare.ll Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/trunk/test/CodeGen/X86/vec_compare.ll Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=74978&r1=74977&r2=74978&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Tue Jul 7 19:31:33 2009 @@ -363,12 +363,11 @@ // them with (op #2) as a CondCodeSDNode. SETCC, - // Vector SetCC operator - This evaluates to a vector of integer elements - // with the high bit in each element set to true if the comparison is true - // and false if the comparison is false. All other bits in each element - // are undefined. The operands to this are the left and right operands - // to compare (ops #0, and #1) and the condition code to compare them with - // (op #2) as a CondCodeSDNode. + // RESULT = VSETCC(LHS, RHS, COND) operator - This evaluates to a vector of + // integer elements with all bits of the result elements set to true if the + // comparison is true or all cleared if the comparison is false. The + // operands to this are the left and right operands to compare (LHS/RHS) and + // the condition code to compare them with (COND) as a CondCodeSDNode. VSETCC, // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=74978&r1=74977&r2=74978&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Jul 7 19:31:33 2009 @@ -3071,14 +3071,32 @@ } } - // sext(setcc x, y, cc) -> (select_cc x, y, -1, 0, cc) if (N0.getOpcode() == ISD::SETCC) { + // sext(setcc) -> sext_in_reg(vsetcc) for vectors. + if (VT.isVector() && + // We know that the # elements of the results is the same as the + // # elements of the compare (and the # elements of the compare result + // for that matter). Check to see that they are the same size. If so, + // we know that the element size of the sext'd result matches the + // element size of the compare operands. + VT.getSizeInBits() == N0.getOperand(0).getValueType().getSizeInBits() && + + // Only do this before legalize for now. + !LegalOperations) { + return DAG.getVSetCC(N->getDebugLoc(), VT, N0.getOperand(0), + N0.getOperand(1), + cast(N0.getOperand(2))->get()); + } + + // sext(setcc x, y, cc) -> (select_cc x, y, -1, 0, cc) SDValue SCC = SimplifySelectCC(N->getDebugLoc(), N0.getOperand(0), N0.getOperand(1), DAG.getConstant(~0ULL, VT), DAG.getConstant(0, VT), cast(N0.getOperand(2))->get(), true); if (SCC.getNode()) return SCC; } + + // fold (sext x) -> (zext x) if the sign bit is known zero. if ((!LegalOperations || TLI.isOperationLegal(ISD::ZERO_EXTEND, VT)) && Modified: llvm/trunk/test/CodeGen/X86/vec_compare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_compare.ll?rev=74978&r1=74977&r2=74978&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_compare.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_compare.ll Tue Jul 7 19:31:33 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep pcmpgtd +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep pcmpgtd | count 2 define <4 x i32> @test(<4 x i32> %A, <4 x i32> %B) nounwind { %C = vicmp sgt <4 x i32> %A, %B From sabre at nondot.org Tue Jul 7 19:46:57 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 00:46:57 -0000 Subject: [llvm-commits] [llvm] r74979 - in /llvm/trunk/test/CodeGen/ARM: vceq.ll vcge.ll vcgt.ll vfcmp.ll vicmp.ll vtst.ll Message-ID: <200907080046.n680kwN0006769@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 19:46:57 2009 New Revision: 74979 URL: http://llvm.org/viewvc/llvm-project?rev=74979&view=rev Log: Change these tests to use [fi]cmp+sext instead of v[fi]cmp. No functionality change. Modified: llvm/trunk/test/CodeGen/ARM/vceq.ll llvm/trunk/test/CodeGen/ARM/vcge.ll llvm/trunk/test/CodeGen/ARM/vcgt.ll llvm/trunk/test/CodeGen/ARM/vfcmp.ll llvm/trunk/test/CodeGen/ARM/vicmp.ll llvm/trunk/test/CodeGen/ARM/vtst.ll Modified: llvm/trunk/test/CodeGen/ARM/vceq.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vceq.ll?rev=74979&r1=74978&r2=74979&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vceq.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vceq.ll Tue Jul 7 19:46:57 2009 @@ -7,55 +7,63 @@ define <8 x i8> @vceqi8(<8 x i8>* %A, <8 x i8>* %B) nounwind { %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B - %tmp3 = vicmp eq <8 x i8> %tmp1, %tmp2 - ret <8 x i8> %tmp3 + %tmp3 = icmp eq <8 x i8> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i8> + ret <8 x i8> %tmp4 } define <4 x i16> @vceqi16(<4 x i16>* %A, <4 x i16>* %B) nounwind { %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B - %tmp3 = vicmp eq <4 x i16> %tmp1, %tmp2 - ret <4 x i16> %tmp3 + %tmp3 = icmp eq <4 x i16> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i16> + ret <4 x i16> %tmp4 } define <2 x i32> @vceqi32(<2 x i32>* %A, <2 x i32>* %B) nounwind { %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B - %tmp3 = vicmp eq <2 x i32> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = icmp eq <2 x i32> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } define <2 x i32> @vceqf32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp oeq <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp oeq <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } define <16 x i8> @vceqQi8(<16 x i8>* %A, <16 x i8>* %B) nounwind { %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B - %tmp3 = vicmp eq <16 x i8> %tmp1, %tmp2 - ret <16 x i8> %tmp3 + %tmp3 = icmp eq <16 x i8> %tmp1, %tmp2 + %tmp4 = sext <16 x i1> %tmp3 to <16 x i8> + ret <16 x i8> %tmp4 } define <8 x i16> @vceqQi16(<8 x i16>* %A, <8 x i16>* %B) nounwind { %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B - %tmp3 = vicmp eq <8 x i16> %tmp1, %tmp2 - ret <8 x i16> %tmp3 + %tmp3 = icmp eq <8 x i16> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i16> + ret <8 x i16> %tmp4 } define <4 x i32> @vceqQi32(<4 x i32>* %A, <4 x i32>* %B) nounwind { %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B - %tmp3 = vicmp eq <4 x i32> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = icmp eq <4 x i32> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } define <4 x i32> @vceqQf32(<4 x float>* %A, <4 x float>* %B) nounwind { %tmp1 = load <4 x float>* %A %tmp2 = load <4 x float>* %B - %tmp3 = vfcmp oeq <4 x float> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = fcmp oeq <4 x float> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } Modified: llvm/trunk/test/CodeGen/ARM/vcge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vcge.ll?rev=74979&r1=74978&r2=74979&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vcge.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vcge.ll Tue Jul 7 19:46:57 2009 @@ -10,97 +10,111 @@ define <8 x i8> @vcges8(<8 x i8>* %A, <8 x i8>* %B) nounwind { %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B - %tmp3 = vicmp sge <8 x i8> %tmp1, %tmp2 - ret <8 x i8> %tmp3 + %tmp3 = icmp sge <8 x i8> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i8> + ret <8 x i8> %tmp4 } define <4 x i16> @vcges16(<4 x i16>* %A, <4 x i16>* %B) nounwind { %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B - %tmp3 = vicmp sge <4 x i16> %tmp1, %tmp2 - ret <4 x i16> %tmp3 + %tmp3 = icmp sge <4 x i16> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i16> + ret <4 x i16> %tmp4 } define <2 x i32> @vcges32(<2 x i32>* %A, <2 x i32>* %B) nounwind { %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B - %tmp3 = vicmp sge <2 x i32> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = icmp sge <2 x i32> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } define <8 x i8> @vcgeu8(<8 x i8>* %A, <8 x i8>* %B) nounwind { %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B - %tmp3 = vicmp uge <8 x i8> %tmp1, %tmp2 - ret <8 x i8> %tmp3 + %tmp3 = icmp uge <8 x i8> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i8> + ret <8 x i8> %tmp4 } define <4 x i16> @vcgeu16(<4 x i16>* %A, <4 x i16>* %B) nounwind { %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B - %tmp3 = vicmp uge <4 x i16> %tmp1, %tmp2 - ret <4 x i16> %tmp3 + %tmp3 = icmp uge <4 x i16> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i16> + ret <4 x i16> %tmp4 } define <2 x i32> @vcgeu32(<2 x i32>* %A, <2 x i32>* %B) nounwind { %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B - %tmp3 = vicmp uge <2 x i32> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = icmp uge <2 x i32> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } define <2 x i32> @vcgef32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp oge <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp oge <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } define <16 x i8> @vcgeQs8(<16 x i8>* %A, <16 x i8>* %B) nounwind { %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B - %tmp3 = vicmp sge <16 x i8> %tmp1, %tmp2 - ret <16 x i8> %tmp3 + %tmp3 = icmp sge <16 x i8> %tmp1, %tmp2 + %tmp4 = sext <16 x i1> %tmp3 to <16 x i8> + ret <16 x i8> %tmp4 } define <8 x i16> @vcgeQs16(<8 x i16>* %A, <8 x i16>* %B) nounwind { %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B - %tmp3 = vicmp sge <8 x i16> %tmp1, %tmp2 - ret <8 x i16> %tmp3 + %tmp3 = icmp sge <8 x i16> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i16> + ret <8 x i16> %tmp4 } define <4 x i32> @vcgeQs32(<4 x i32>* %A, <4 x i32>* %B) nounwind { %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B - %tmp3 = vicmp sge <4 x i32> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = icmp sge <4 x i32> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } define <16 x i8> @vcgeQu8(<16 x i8>* %A, <16 x i8>* %B) nounwind { %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B - %tmp3 = vicmp uge <16 x i8> %tmp1, %tmp2 - ret <16 x i8> %tmp3 + %tmp3 = icmp uge <16 x i8> %tmp1, %tmp2 + %tmp4 = sext <16 x i1> %tmp3 to <16 x i8> + ret <16 x i8> %tmp4 } define <8 x i16> @vcgeQu16(<8 x i16>* %A, <8 x i16>* %B) nounwind { %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B - %tmp3 = vicmp uge <8 x i16> %tmp1, %tmp2 - ret <8 x i16> %tmp3 + %tmp3 = icmp uge <8 x i16> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i16> + ret <8 x i16> %tmp4 } define <4 x i32> @vcgeQu32(<4 x i32>* %A, <4 x i32>* %B) nounwind { %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B - %tmp3 = vicmp uge <4 x i32> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = icmp uge <4 x i32> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } define <4 x i32> @vcgeQf32(<4 x float>* %A, <4 x float>* %B) nounwind { %tmp1 = load <4 x float>* %A %tmp2 = load <4 x float>* %B - %tmp3 = vfcmp oge <4 x float> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = fcmp oge <4 x float> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } Modified: llvm/trunk/test/CodeGen/ARM/vcgt.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vcgt.ll?rev=74979&r1=74978&r2=74979&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vcgt.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vcgt.ll Tue Jul 7 19:46:57 2009 @@ -10,97 +10,111 @@ define <8 x i8> @vcgts8(<8 x i8>* %A, <8 x i8>* %B) nounwind { %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B - %tmp3 = vicmp sgt <8 x i8> %tmp1, %tmp2 - ret <8 x i8> %tmp3 + %tmp3 = icmp sgt <8 x i8> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i8> + ret <8 x i8> %tmp4 } define <4 x i16> @vcgts16(<4 x i16>* %A, <4 x i16>* %B) nounwind { %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B - %tmp3 = vicmp sgt <4 x i16> %tmp1, %tmp2 - ret <4 x i16> %tmp3 + %tmp3 = icmp sgt <4 x i16> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i16> + ret <4 x i16> %tmp4 } define <2 x i32> @vcgts32(<2 x i32>* %A, <2 x i32>* %B) nounwind { %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B - %tmp3 = vicmp sgt <2 x i32> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = icmp sgt <2 x i32> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } define <8 x i8> @vcgtu8(<8 x i8>* %A, <8 x i8>* %B) nounwind { %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B - %tmp3 = vicmp ugt <8 x i8> %tmp1, %tmp2 - ret <8 x i8> %tmp3 + %tmp3 = icmp ugt <8 x i8> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i8> + ret <8 x i8> %tmp4 } define <4 x i16> @vcgtu16(<4 x i16>* %A, <4 x i16>* %B) nounwind { %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B - %tmp3 = vicmp ugt <4 x i16> %tmp1, %tmp2 - ret <4 x i16> %tmp3 + %tmp3 = icmp ugt <4 x i16> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i16> + ret <4 x i16> %tmp4 } define <2 x i32> @vcgtu32(<2 x i32>* %A, <2 x i32>* %B) nounwind { %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B - %tmp3 = vicmp ugt <2 x i32> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = icmp ugt <2 x i32> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } define <2 x i32> @vcgtf32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp ogt <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp ogt <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } define <16 x i8> @vcgtQs8(<16 x i8>* %A, <16 x i8>* %B) nounwind { %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B - %tmp3 = vicmp sgt <16 x i8> %tmp1, %tmp2 - ret <16 x i8> %tmp3 + %tmp3 = icmp sgt <16 x i8> %tmp1, %tmp2 + %tmp4 = sext <16 x i1> %tmp3 to <16 x i8> + ret <16 x i8> %tmp4 } define <8 x i16> @vcgtQs16(<8 x i16>* %A, <8 x i16>* %B) nounwind { %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B - %tmp3 = vicmp sgt <8 x i16> %tmp1, %tmp2 - ret <8 x i16> %tmp3 + %tmp3 = icmp sgt <8 x i16> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i16> + ret <8 x i16> %tmp4 } define <4 x i32> @vcgtQs32(<4 x i32>* %A, <4 x i32>* %B) nounwind { %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B - %tmp3 = vicmp sgt <4 x i32> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = icmp sgt <4 x i32> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } define <16 x i8> @vcgtQu8(<16 x i8>* %A, <16 x i8>* %B) nounwind { %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B - %tmp3 = vicmp ugt <16 x i8> %tmp1, %tmp2 - ret <16 x i8> %tmp3 + %tmp3 = icmp ugt <16 x i8> %tmp1, %tmp2 + %tmp4 = sext <16 x i1> %tmp3 to <16 x i8> + ret <16 x i8> %tmp4 } define <8 x i16> @vcgtQu16(<8 x i16>* %A, <8 x i16>* %B) nounwind { %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B - %tmp3 = vicmp ugt <8 x i16> %tmp1, %tmp2 - ret <8 x i16> %tmp3 + %tmp3 = icmp ugt <8 x i16> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i16> + ret <8 x i16> %tmp4 } define <4 x i32> @vcgtQu32(<4 x i32>* %A, <4 x i32>* %B) nounwind { %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B - %tmp3 = vicmp ugt <4 x i32> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = icmp ugt <4 x i32> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } define <4 x i32> @vcgtQf32(<4 x float>* %A, <4 x float>* %B) nounwind { %tmp1 = load <4 x float>* %A %tmp2 = load <4 x float>* %B - %tmp3 = vfcmp ogt <4 x float> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = fcmp ogt <4 x float> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } Modified: llvm/trunk/test/CodeGen/ARM/vfcmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vfcmp.ll?rev=74979&r1=74978&r2=74979&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vfcmp.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vfcmp.ll Tue Jul 7 19:46:57 2009 @@ -5,92 +5,103 @@ ; RUN: grep vorr %t | count 4 ; RUN: grep vmvn %t | count 7 -; This tests vfcmp operations that do not map directly to NEON instructions. +; This tests fcmp operations that do not map directly to NEON instructions. ; une is implemented with VCEQ/VMVN define <2 x i32> @vcunef32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp une <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp une <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; olt is implemented with VCGT define <2 x i32> @vcoltf32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp olt <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp olt <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; ole is implemented with VCGE define <2 x i32> @vcolef32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp ole <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp ole <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; uge is implemented with VCGT/VMVN define <2 x i32> @vcugef32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp uge <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp uge <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; ule is implemented with VCGT/VMVN define <2 x i32> @vculef32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp ule <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp ule <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; ugt is implemented with VCGE/VMVN define <2 x i32> @vcugtf32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp ugt <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp ugt <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; ult is implemented with VCGE/VMVN define <2 x i32> @vcultf32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp ult <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp ult <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; ueq is implemented with VCGT/VCGT/VORR/VMVN define <2 x i32> @vcueqf32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp ueq <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp ueq <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; one is implemented with VCGT/VCGT/VORR define <2 x i32> @vconef32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp one <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp one <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; uno is implemented with VCGT/VCGE/VORR/VMVN define <2 x i32> @vcunof32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp uno <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp uno <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } ; ord is implemented with VCGT/VCGE/VORR define <2 x i32> @vcordf32(<2 x float>* %A, <2 x float>* %B) nounwind { %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B - %tmp3 = vfcmp ord <2 x float> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = fcmp ord <2 x float> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } Modified: llvm/trunk/test/CodeGen/ARM/vicmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vicmp.ll?rev=74979&r1=74978&r2=74979&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vicmp.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vicmp.ll Tue Jul 7 19:46:57 2009 @@ -8,7 +8,7 @@ ; RUN: grep {vcgt\\.u16} %t | count 1 ; RUN: grep {vcge\\.u32} %t | count 1 -; This tests vicmp operations that do not map directly to NEON instructions. +; This tests icmp operations that do not map directly to NEON instructions. ; Not-equal (ne) operations are implemented by VCEQ/VMVN. Less-than (lt/ult) ; and less-than-or-equal (le/ule) are implemented by swapping the arguments ; to VCGT and VCGE. Test all the operand types for not-equal but only sample @@ -17,69 +17,79 @@ define <8 x i8> @vcnei8(<8 x i8>* %A, <8 x i8>* %B) nounwind { %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B - %tmp3 = vicmp ne <8 x i8> %tmp1, %tmp2 - ret <8 x i8> %tmp3 + %tmp3 = icmp ne <8 x i8> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i8> + ret <8 x i8> %tmp4 } define <4 x i16> @vcnei16(<4 x i16>* %A, <4 x i16>* %B) nounwind { %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B - %tmp3 = vicmp ne <4 x i16> %tmp1, %tmp2 - ret <4 x i16> %tmp3 + %tmp3 = icmp ne <4 x i16> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i16> + ret <4 x i16> %tmp4 } define <2 x i32> @vcnei32(<2 x i32>* %A, <2 x i32>* %B) nounwind { %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B - %tmp3 = vicmp ne <2 x i32> %tmp1, %tmp2 - ret <2 x i32> %tmp3 + %tmp3 = icmp ne <2 x i32> %tmp1, %tmp2 + %tmp4 = sext <2 x i1> %tmp3 to <2 x i32> + ret <2 x i32> %tmp4 } define <16 x i8> @vcneQi8(<16 x i8>* %A, <16 x i8>* %B) nounwind { %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B - %tmp3 = vicmp ne <16 x i8> %tmp1, %tmp2 - ret <16 x i8> %tmp3 + %tmp3 = icmp ne <16 x i8> %tmp1, %tmp2 + %tmp4 = sext <16 x i1> %tmp3 to <16 x i8> + ret <16 x i8> %tmp4 } define <8 x i16> @vcneQi16(<8 x i16>* %A, <8 x i16>* %B) nounwind { %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B - %tmp3 = vicmp ne <8 x i16> %tmp1, %tmp2 - ret <8 x i16> %tmp3 + %tmp3 = icmp ne <8 x i16> %tmp1, %tmp2 + %tmp4 = sext <8 x i1> %tmp3 to <8 x i16> + ret <8 x i16> %tmp4 } define <4 x i32> @vcneQi32(<4 x i32>* %A, <4 x i32>* %B) nounwind { %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B - %tmp3 = vicmp ne <4 x i32> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = icmp ne <4 x i32> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } define <16 x i8> @vcltQs8(<16 x i8>* %A, <16 x i8>* %B) nounwind { %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B - %tmp3 = vicmp slt <16 x i8> %tmp1, %tmp2 - ret <16 x i8> %tmp3 + %tmp3 = icmp slt <16 x i8> %tmp1, %tmp2 + %tmp4 = sext <16 x i1> %tmp3 to <16 x i8> + ret <16 x i8> %tmp4 } define <4 x i16> @vcles16(<4 x i16>* %A, <4 x i16>* %B) nounwind { %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B - %tmp3 = vicmp sle <4 x i16> %tmp1, %tmp2 - ret <4 x i16> %tmp3 + %tmp3 = icmp sle <4 x i16> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i16> + ret <4 x i16> %tmp4 } define <4 x i16> @vcltu16(<4 x i16>* %A, <4 x i16>* %B) nounwind { %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B - %tmp3 = vicmp ult <4 x i16> %tmp1, %tmp2 - ret <4 x i16> %tmp3 + %tmp3 = icmp ult <4 x i16> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i16> + ret <4 x i16> %tmp4 } define <4 x i32> @vcleQu32(<4 x i32>* %A, <4 x i32>* %B) nounwind { %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B - %tmp3 = vicmp ule <4 x i32> %tmp1, %tmp2 - ret <4 x i32> %tmp3 + %tmp3 = icmp ule <4 x i32> %tmp1, %tmp2 + %tmp4 = sext <4 x i1> %tmp3 to <4 x i32> + ret <4 x i32> %tmp4 } Modified: llvm/trunk/test/CodeGen/ARM/vtst.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vtst.ll?rev=74979&r1=74978&r2=74979&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vtst.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vtst.ll Tue Jul 7 19:46:57 2009 @@ -7,46 +7,52 @@ %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B %tmp3 = and <8 x i8> %tmp1, %tmp2 - %tmp4 = vicmp ne <8 x i8> %tmp3, zeroinitializer - ret <8 x i8> %tmp4 + %tmp4 = icmp ne <8 x i8> %tmp3, zeroinitializer + %tmp5 = sext <8 x i1> %tmp4 to <8 x i8> + ret <8 x i8> %tmp5 } define <4 x i16> @vtsti16(<4 x i16>* %A, <4 x i16>* %B) nounwind { %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B %tmp3 = and <4 x i16> %tmp1, %tmp2 - %tmp4 = vicmp ne <4 x i16> %tmp3, zeroinitializer - ret <4 x i16> %tmp4 + %tmp4 = icmp ne <4 x i16> %tmp3, zeroinitializer + %tmp5 = sext <4 x i1> %tmp4 to <4 x i16> + ret <4 x i16> %tmp5 } define <2 x i32> @vtsti32(<2 x i32>* %A, <2 x i32>* %B) nounwind { %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B %tmp3 = and <2 x i32> %tmp1, %tmp2 - %tmp4 = vicmp ne <2 x i32> %tmp3, zeroinitializer - ret <2 x i32> %tmp4 + %tmp4 = icmp ne <2 x i32> %tmp3, zeroinitializer + %tmp5 = sext <2 x i1> %tmp4 to <2 x i32> + ret <2 x i32> %tmp5 } define <16 x i8> @vtstQi8(<16 x i8>* %A, <16 x i8>* %B) nounwind { %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B %tmp3 = and <16 x i8> %tmp1, %tmp2 - %tmp4 = vicmp ne <16 x i8> %tmp3, zeroinitializer - ret <16 x i8> %tmp4 + %tmp4 = icmp ne <16 x i8> %tmp3, zeroinitializer + %tmp5 = sext <16 x i1> %tmp4 to <16 x i8> + ret <16 x i8> %tmp5 } define <8 x i16> @vtstQi16(<8 x i16>* %A, <8 x i16>* %B) nounwind { %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B %tmp3 = and <8 x i16> %tmp1, %tmp2 - %tmp4 = vicmp ne <8 x i16> %tmp3, zeroinitializer - ret <8 x i16> %tmp4 + %tmp4 = icmp ne <8 x i16> %tmp3, zeroinitializer + %tmp5 = sext <8 x i1> %tmp4 to <8 x i16> + ret <8 x i16> %tmp5 } define <4 x i32> @vtstQi32(<4 x i32>* %A, <4 x i32>* %B) nounwind { %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B %tmp3 = and <4 x i32> %tmp1, %tmp2 - %tmp4 = vicmp ne <4 x i32> %tmp3, zeroinitializer - ret <4 x i32> %tmp4 + %tmp4 = icmp ne <4 x i32> %tmp3, zeroinitializer + %tmp5 = sext <4 x i1> %tmp4 to <4 x i32> + ret <4 x i32> %tmp5 } From sabre at nondot.org Tue Jul 7 19:49:35 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 00:49:35 -0000 Subject: [llvm-commits] [llvm] r74980 - in /llvm/trunk/test/CodeGen/X86: 2008-07-23-VSetCC.ll vec_compare.ll vfcmp.ll Message-ID: <200907080049.n680nZgF006850@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 19:49:35 2009 New Revision: 74980 URL: http://llvm.org/viewvc/llvm-project?rev=74980&view=rev Log: eliminate the v[if]cmp versions of these tests, now that [if]cmp+sext works. Modified: llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll llvm/trunk/test/CodeGen/X86/vec_compare.ll llvm/trunk/test/CodeGen/X86/vfcmp.ll Modified: llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll?rev=74980&r1=74979&r2=74980&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-07-23-VSetCC.ll Tue Jul 7 19:49:35 2009 @@ -5,32 +5,6 @@ br i1 false, label %bb.nph, label %._crit_edge bb.nph: ; preds = %bb.nph, %0 - vicmp sgt <4 x i32> zeroinitializer, < i32 -128, i32 -128, i32 -128, i32 -128 > ; <<4 x i32>>:1 [#uses=1] - extractelement <4 x i32> %1, i32 3 ; :2 [#uses=1] - lshr i32 %2, 31 ; :3 [#uses=1] - trunc i32 %3 to i1 ; :4 [#uses=1] - select i1 %4, i32 -1, i32 0 ; :5 [#uses=1] - insertelement <4 x i32> zeroinitializer, i32 %5, i32 3 ; <<4 x i32>>:6 [#uses=1] - and <4 x i32> zeroinitializer, %6 ; <<4 x i32>>:7 [#uses=1] - bitcast <4 x i32> %7 to <4 x float> ; <<4 x float>>:8 [#uses=1] - fmul <4 x float> zeroinitializer, %8 ; <<4 x float>>:9 [#uses=1] - bitcast <4 x float> %9 to <4 x i32> ; <<4 x i32>>:10 [#uses=1] - or <4 x i32> %10, zeroinitializer ; <<4 x i32>>:11 [#uses=1] - bitcast <4 x i32> %11 to <4 x float> ; <<4 x float>>:12 [#uses=1] - fmul <4 x float> %12, < float 1.000000e+02, float 1.000000e+02, float 1.000000e+02, float 1.000000e+02 > ; <<4 x float>>:13 [#uses=1] - fsub <4 x float> %13, < float 1.000000e+02, float 1.000000e+02, float 1.000000e+02, float 1.000000e+02 > ; <<4 x float>>:14 [#uses=1] - extractelement <4 x float> %14, i32 3 ; :15 [#uses=1] - call float @fmaxf( float 0.000000e+00, float %15 ) ; :16 [#uses=0] - br label %bb.nph - -._crit_edge: ; preds = %0 - ret void -} - -define void @entry2(i32 %m_task_id, i32 %start_x, i32 %end_x) nounwind { - br i1 false, label %bb.nph, label %._crit_edge - -bb.nph: ; preds = %bb.nph, %0 %X = icmp sgt <4 x i32> zeroinitializer, < i32 -128, i32 -128, i32 -128, i32 -128 > ; <<4 x i32>>:1 [#uses=1] sext <4 x i1> %X to <4 x i32> extractelement <4 x i32> %1, i32 3 ; :2 [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/vec_compare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_compare.ll?rev=74980&r1=74979&r2=74980&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_compare.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_compare.ll Tue Jul 7 19:49:35 2009 @@ -1,9 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep pcmpgtd | count 2 - -define <4 x i32> @test(<4 x i32> %A, <4 x i32> %B) nounwind { - %C = vicmp sgt <4 x i32> %A, %B - ret <4 x i32> %C -} +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep pcmpgtd define <4 x i32> @test2(<4 x i32> %A, <4 x i32> %B) nounwind { Modified: llvm/trunk/test/CodeGen/X86/vfcmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vfcmp.ll?rev=74980&r1=74979&r2=74980&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vfcmp.ll (original) +++ llvm/trunk/test/CodeGen/X86/vfcmp.ll Tue Jul 7 19:49:35 2009 @@ -1,16 +1,6 @@ ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 ; PR2620 -define void @t(i32 %m_task_id, i32 %start_x, i32 %end_x) nounwind { - vfcmp olt <2 x double> zeroinitializer, zeroinitializer ; <<2 x i64>>:1 [#uses=1] - extractelement <2 x i64> %1, i32 1 ; :2 [#uses=1] - lshr i64 %2, 63 ; :3 [#uses=1] - trunc i64 %3 to i1 ; :4 [#uses=1] - zext i1 %4 to i8 ; :5 [#uses=1] - insertelement <2 x i8> zeroinitializer, i8 %5, i32 1 ; <<2 x i8>>:6 [#uses=1] - store <2 x i8> %6, <2 x i8>* null - ret void -} define void @t2(i32 %m_task_id, i32 %start_x, i32 %end_x) nounwind { %A = fcmp olt <2 x double> zeroinitializer, zeroinitializer ; <<2 x i64>>:1 [#uses=1] From sabre at nondot.org Tue Jul 7 19:52:12 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 00:52:12 -0000 Subject: [llvm-commits] [llvm] r74981 - /llvm/trunk/lib/System/Win32/DynamicLibrary.inc Message-ID: <200907080052.n680qCvn006940@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 19:52:12 2009 New Revision: 74981 URL: http://llvm.org/viewvc/llvm-project?rev=74981&view=rev Log: more getting windows to build. Modified: llvm/trunk/lib/System/Win32/DynamicLibrary.inc Modified: llvm/trunk/lib/System/Win32/DynamicLibrary.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/DynamicLibrary.inc?rev=74981&r1=74980&r2=74981&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/DynamicLibrary.inc (original) +++ llvm/trunk/lib/System/Win32/DynamicLibrary.inc Tue Jul 7 19:52:12 2009 @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "Win32.h" -#include "llvm/System/RWMutex.h" #ifdef __MINGW32__ #include @@ -68,7 +67,6 @@ PVOID UserContext) #endif { - llvm::sys::SmartScopedWriter Writer(&SymbolsLock); // Ignore VC++ runtimes prior to 7.1. Somehow some of them get loaded // into the process. if (stricmp(ModuleName, "msvci70") != 0 && @@ -91,13 +89,11 @@ } DynamicLibrary::DynamicLibrary() : handle(0) { - SmartScopedWriter Writer(&SymbolsLock); handle = GetModuleHandle(NULL); OpenedHandles.push_back((HMODULE)handle); } DynamicLibrary::~DynamicLibrary() { - llvm::sys::SmartScopedWriter Writer(&SymbolsLock); if (handle == 0) return; @@ -119,7 +115,6 @@ bool DynamicLibrary::LoadLibraryPermanently(const char *filename, std::string *ErrMsg) { if (filename) { - llvm::sys::SmartScopedWriter Writer(&SymbolsLock); HMODULE a_handle = LoadLibrary(filename); if (a_handle == 0) @@ -171,24 +166,22 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { // First check symbols added via AddSymbol(). - SymbolsLock.reader_acquire(); - std::map::iterator I = symbols.find(symbolName); - std::map::iterator E = symbols.end(); - SymbolsLock.reader_release(); - if (I != E) - return I->second; + if (ExplicitSymbols) { + std::map::iterator I = + ExplicitSymbols->find(symbolName); + std::map::iterator E = ExplicitSymbols->end(); + if (I != E) + return I->second; + } // Now search the libraries. - SymbolsLock.writer_acquire(); for (std::vector::iterator I = OpenedHandles.begin(), E = OpenedHandles.end(); I != E; ++I) { FARPROC ptr = GetProcAddress((HMODULE)*I, symbolName); if (ptr) { - SymbolsLock.writer_release(); return (void *) ptr; } } - SymbolsLock.writer_release(); #if defined(__MINGW32__) { From sabre at nondot.org Tue Jul 7 20:07:43 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 01:07:43 -0000 Subject: [llvm-commits] [llvm] r74982 - /llvm/trunk/lib/System/Win32/DynamicLibrary.inc Message-ID: <200907080107.n6817hZ2007386@zion.cs.uiuc.edu> Author: lattner Date: Tue Jul 7 20:07:39 2009 New Revision: 74982 URL: http://llvm.org/viewvc/llvm-project?rev=74982&view=rev Log: remove two methods that no longer exist. Modified: llvm/trunk/lib/System/Win32/DynamicLibrary.inc Modified: llvm/trunk/lib/System/Win32/DynamicLibrary.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/DynamicLibrary.inc?rev=74982&r1=74981&r2=74982&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/DynamicLibrary.inc (original) +++ llvm/trunk/lib/System/Win32/DynamicLibrary.inc Tue Jul 7 20:07:39 2009 @@ -88,30 +88,6 @@ } } -DynamicLibrary::DynamicLibrary() : handle(0) { - handle = GetModuleHandle(NULL); - OpenedHandles.push_back((HMODULE)handle); -} - -DynamicLibrary::~DynamicLibrary() { - if (handle == 0) - return; - - // GetModuleHandle() does not increment the ref count, so we must not free - // the handle to the executable. - if (handle != GetModuleHandle(NULL)) - FreeLibrary((HMODULE)handle); - handle = 0; - - for (std::vector::iterator I = OpenedHandles.begin(), - E = OpenedHandles.end(); I != E; ++I) { - if (*I == handle) { - // Note: don't use the swap/pop_back trick here. Order is important. - OpenedHandles.erase(I); - } - } -} - bool DynamicLibrary::LoadLibraryPermanently(const char *filename, std::string *ErrMsg) { if (filename) { From resistor at mac.com Tue Jul 7 20:26:07 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 08 Jul 2009 01:26:07 -0000 Subject: [llvm-commits] [llvm] r74985 - in /llvm/trunk: examples/BrainF/ include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Linker/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ Message-ID: <200907080126.n681Q7XL007942@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 20:26:06 2009 New Revision: 74985 URL: http://llvm.org/viewvc/llvm-project?rev=74985&view=rev Log: Push LLVMContext through GlobalVariables and IRBuilder. Modified: llvm/trunk/examples/BrainF/BrainF.cpp llvm/trunk/include/llvm/GlobalVariable.h llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/CodeGen/ShadowStackGC.cpp llvm/trunk/lib/Linker/LinkModules.cpp llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/CloneModule.cpp llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Globals.cpp llvm/trunk/lib/VMCore/Module.cpp llvm/trunk/tools/bugpoint/ExtractFunction.cpp llvm/trunk/tools/bugpoint/Miscompilation.cpp Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Tue Jul 7 20:26:06 2009 @@ -128,6 +128,7 @@ get("Error: The head has left the tape.", true); GlobalVariable *aberrormsg = new GlobalVariable( + module->getContext(), msg_0->getType(), true, GlobalValue::InternalLinkage, Modified: llvm/trunk/include/llvm/GlobalVariable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalVariable.h?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/include/llvm/GlobalVariable.h (original) +++ llvm/trunk/include/llvm/GlobalVariable.h Tue Jul 7 20:26:06 2009 @@ -26,6 +26,7 @@ namespace llvm { +class LLVMContext; class Module; class Constant; template @@ -49,13 +50,15 @@ } /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. - GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage, + GlobalVariable(LLVMContext &Context, const Type *Ty, + bool isConstant, LinkageTypes Linkage, Constant *Initializer = 0, const std::string &Name = "", Module *Parent = 0, bool ThreadLocal = false, unsigned AddressSpace = 0); /// GlobalVariable ctor - This creates a global and inserts it before the /// specified other global. - GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage, + GlobalVariable(LLVMContext &Context, const Type *Ty, + bool isConstant, LinkageTypes Linkage, Constant *Initializer, const std::string &Name, GlobalVariable *InsertBefore, bool ThreadLocal = false, unsigned AddressSpace = 0); Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Tue Jul 7 20:26:06 2009 @@ -20,6 +20,7 @@ #include "llvm/GlobalAlias.h" #include "llvm/GlobalVariable.h" #include "llvm/Function.h" +#include "llvm/LLVMContext.h" #include "llvm/Support/ConstantFolder.h" namespace llvm { @@ -42,12 +43,16 @@ BasicBlock *BB; BasicBlock::iterator InsertPt; T Folder; + LLVMContext& Context; public: - IRBuilder(const T& F = T()) : Folder(F) { ClearInsertionPoint(); } - explicit IRBuilder(BasicBlock *TheBB, const T& F = T()) - : Folder(F) { SetInsertPoint(TheBB); } - IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F = T()) - : Folder(F) { SetInsertPoint(TheBB, IP); } + IRBuilder(const T& F = T(), LLVMContext &C = getGlobalContext()) : + Folder(F), Context(C) { ClearInsertionPoint(); } + explicit IRBuilder(BasicBlock *TheBB, const T& F = T(), + LLVMContext &C = getGlobalContext()) : + Folder(F), Context(C) { SetInsertPoint(TheBB); } + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F = T(), + LLVMContext &C = getGlobalContext()) + : Folder(F), Context(C) { SetInsertPoint(TheBB, IP); } /// getFolder - Get the constant folder being used. const T& getFolder() { return Folder; } @@ -125,7 +130,7 @@ /// ReturnInst *CreateAggregateRet(Value * const* retVals, unsigned N) { const Type *RetType = BB->getParent()->getReturnType(); - Value *V = UndefValue::get(RetType); + Value *V = Context.getUndef(RetType); for (unsigned i = 0; i != N; ++i) V = CreateInsertValue(V, retVals[i], i, "mrv"); return Insert(ReturnInst::Create(V)); @@ -349,7 +354,7 @@ return Insert(GetElementPtrInst::Create(Ptr, Idx), Name); } Value *CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const char *Name = "") { - Value *Idx = ConstantInt::get(Type::Int32Ty, Idx0); + Value *Idx = Context.getConstantInt(Type::Int32Ty, Idx0); if (Constant *PC = dyn_cast(Ptr)) return Folder.CreateGetElementPtr(PC, &Idx, 1); @@ -359,8 +364,8 @@ Value *CreateConstGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1, const char *Name = "") { Value *Idxs[] = { - ConstantInt::get(Type::Int32Ty, Idx0), - ConstantInt::get(Type::Int32Ty, Idx1) + Context.getConstantInt(Type::Int32Ty, Idx0), + Context.getConstantInt(Type::Int32Ty, Idx1) }; if (Constant *PC = dyn_cast(Ptr)) @@ -369,7 +374,7 @@ return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name); } Value *CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const char *Name = "") { - Value *Idx = ConstantInt::get(Type::Int64Ty, Idx0); + Value *Idx = Context.getConstantInt(Type::Int64Ty, Idx0); if (Constant *PC = dyn_cast(Ptr)) return Folder.CreateGetElementPtr(PC, &Idx, 1); @@ -379,8 +384,8 @@ Value *CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const char *Name = "") { Value *Idxs[] = { - ConstantInt::get(Type::Int64Ty, Idx0), - ConstantInt::get(Type::Int64Ty, Idx1) + Context.getConstantInt(Type::Int64Ty, Idx0), + Context.getConstantInt(Type::Int64Ty, Idx1) }; if (Constant *PC = dyn_cast(Ptr)) @@ -392,8 +397,9 @@ return CreateConstGEP2_32(Ptr, 0, Idx, Name); } Value *CreateGlobalString(const char *Str = "", const char *Name = "") { - Constant *StrConstant = ConstantArray::get(Str, true); - GlobalVariable *gv = new GlobalVariable(StrConstant->getType(), + Constant *StrConstant = Context.getConstantArray(Str, true); + GlobalVariable *gv = new GlobalVariable(Context, + StrConstant->getType(), true, GlobalValue::InternalLinkage, StrConstant, @@ -405,7 +411,7 @@ } Value *CreateGlobalStringPtr(const char *Str = "", const char *Name = "") { Value *gv = CreateGlobalString(Str, Name); - Value *zero = ConstantInt::get(Type::Int32Ty, 0); + Value *zero = Context.getConstantInt(Type::Int32Ty, 0); Value *Args[] = { zero, zero }; return CreateGEP(gv, Args, Args+2, Name); } @@ -697,13 +703,13 @@ /// CreateIsNull - Return an i1 value testing if \arg Arg is null. Value *CreateIsNull(Value *Arg, const char *Name = "") { - return CreateICmpEQ(Arg, Constant::getNullValue(Arg->getType()), + return CreateICmpEQ(Arg, Context.getNullValue(Arg->getType()), Name); } /// CreateIsNotNull - Return an i1 value testing if \arg Arg is not null. Value *CreateIsNotNull(Value *Arg, const char *Name = "") { - return CreateICmpNE(Arg, Constant::getNullValue(Arg->getType()), + return CreateICmpNE(Arg, Context.getNullValue(Arg->getType()), Name); } @@ -718,7 +724,7 @@ Value *RHS_int = CreatePtrToInt(RHS, Type::Int64Ty); Value *Difference = CreateSub(LHS_int, RHS_int); return CreateSDiv(Difference, - ConstantExpr::getSizeOf(ArgType->getElementType()), + Context.getConstantExprSizeOf(ArgType->getElementType()), Name); } }; Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Jul 7 20:26:06 2009 @@ -490,7 +490,7 @@ Constant *ConstStr = VMContext.getConstantArray(String); // Otherwise create and return a new string global. - GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true, + GlobalVariable *StrGV = new GlobalVariable(VMContext,ConstStr->getType(), true, GlobalVariable::InternalLinkage, ConstStr, ".str", &M); StrGV->setSection("llvm.metadata"); @@ -516,7 +516,7 @@ DIDescriptor &Entry = SimpleConstantCache[Init]; if (!Entry.isNull()) return DIArray(Entry.getGV()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::InternalLinkage, Init, "llvm.dbg.array", &M); GV->setSection("llvm.metadata"); @@ -542,7 +542,7 @@ M.addTypeName("llvm.dbg.subrange.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::InternalLinkage, Init, "llvm.dbg.subrange", &M); GV->setSection("llvm.metadata"); @@ -579,7 +579,7 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.compile_unit.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::LinkOnceAnyLinkage, Init, "llvm.dbg.compile_unit", &M); GV->setSection("llvm.metadata"); @@ -598,7 +598,7 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.enumerator.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::InternalLinkage, Init, "llvm.dbg.enumerator", &M); GV->setSection("llvm.metadata"); @@ -632,7 +632,7 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.basictype.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::InternalLinkage, Init, "llvm.dbg.basictype", &M); GV->setSection("llvm.metadata"); @@ -668,7 +668,7 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.derivedtype.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::InternalLinkage, Init, "llvm.dbg.derivedtype", &M); GV->setSection("llvm.metadata"); @@ -708,7 +708,7 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.composite.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::InternalLinkage, Init, "llvm.dbg.composite", &M); GV->setSection("llvm.metadata"); @@ -746,7 +746,7 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.subprogram.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::LinkOnceAnyLinkage, Init, "llvm.dbg.subprogram", &M); GV->setSection("llvm.metadata"); @@ -780,7 +780,7 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.global_variable.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::LinkOnceAnyLinkage, Init, "llvm.dbg.global_variable", &M); GV->setSection("llvm.metadata"); @@ -806,7 +806,7 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.variable.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::InternalLinkage, Init, "llvm.dbg.variable", &M); GV->setSection("llvm.metadata"); @@ -826,7 +826,7 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.block.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, GlobalValue::InternalLinkage, Init, "llvm.dbg.block", &M); GV->setSection("llvm.metadata"); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Jul 7 20:26:06 2009 @@ -516,7 +516,8 @@ } if (GV == 0) { - GV = new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage, 0, Name, + GV = new GlobalVariable(Context, Ty, false, + GlobalValue::ExternalLinkage, 0, Name, M, false, AddrSpace); } else { if (GV->getType()->getElementType() != Ty) @@ -607,7 +608,7 @@ FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M); } else { - FwdVal = new GlobalVariable(PTy->getElementType(), false, + FwdVal = new GlobalVariable(Context, PTy->getElementType(), false, GlobalValue::ExternalWeakLinkage, 0, Name, M); } @@ -651,7 +652,7 @@ } FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M); } else { - FwdVal = new GlobalVariable(PTy->getElementType(), false, + FwdVal = new GlobalVariable(Context, PTy->getElementType(), false, GlobalValue::ExternalWeakLinkage, 0, "", M); } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jul 7 20:26:06 2009 @@ -1258,7 +1258,7 @@ isThreadLocal = Record[7]; GlobalVariable *NewGV = - new GlobalVariable(Ty, isConstant, Linkage, 0, "", TheModule, + new GlobalVariable(Context, Ty, isConstant, Linkage, 0, "", TheModule, isThreadLocal, AddressSpace); NewGV->setAlignment(Alignment); if (!Section.empty()) Modified: llvm/trunk/lib/CodeGen/ShadowStackGC.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShadowStackGC.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ShadowStackGC.cpp (original) +++ llvm/trunk/lib/CodeGen/ShadowStackGC.cpp Tue Jul 7 20:26:06 2009 @@ -229,7 +229,7 @@ // to be a ModulePass (which means it cannot be in the 'llc' pipeline // (which uses a FunctionPassManager (which segfaults (not asserts) if // provided a ModulePass))). - Constant *GV = new GlobalVariable(FrameMap->getType(), true, + Constant *GV = new GlobalVariable(*F.getContext(), FrameMap->getType(), true, GlobalVariable::InternalLinkage, FrameMap, "__gc_" + F.getName(), F.getParent()); @@ -292,7 +292,7 @@ if (!Head) { // If the root chain does not exist, insert a new one with linkonce // linkage! - Head = new GlobalVariable(StackEntryPtrTy, false, + Head = new GlobalVariable(M.getContext(), StackEntryPtrTy, false, GlobalValue::LinkOnceAnyLinkage, Constant::getNullValue(StackEntryPtrTy), "llvm_gc_root_chain", &M); Modified: llvm/trunk/lib/Linker/LinkModules.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkModules.cpp (original) +++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Jul 7 20:26:06 2009 @@ -573,7 +573,7 @@ // symbol over in the dest module... the initializer will be filled in // later by LinkGlobalInits. GlobalVariable *NewDGV = - new GlobalVariable(SGV->getType()->getElementType(), + new GlobalVariable(Context, SGV->getType()->getElementType(), SGV->isConstant(), SGV->getLinkage(), /*init*/0, SGV->getName(), Dest, false, SGV->getType()->getAddressSpace()); @@ -606,7 +606,7 @@ // AppendingVars map. The name is cleared out so that no linkage is // performed. GlobalVariable *NewDGV = - new GlobalVariable(SGV->getType()->getElementType(), + new GlobalVariable(Context, SGV->getType()->getElementType(), SGV->isConstant(), SGV->getLinkage(), /*init*/0, "", Dest, false, SGV->getType()->getAddressSpace()); @@ -634,8 +634,9 @@ // we are replacing may be a function (if a prototype, weak, etc) or a // global variable. GlobalVariable *NewDGV = - new GlobalVariable(SGV->getType()->getElementType(), SGV->isConstant(), - NewLinkage, /*init*/0, DGV->getName(), Dest, false, + new GlobalVariable(Context, SGV->getType()->getElementType(), + SGV->isConstant(), NewLinkage, /*init*/0, + DGV->getName(), Dest, false, SGV->getType()->getAddressSpace()); // Propagate alignment, section, and visibility info. @@ -1156,7 +1157,7 @@ // Create the new global variable... GlobalVariable *NG = - new GlobalVariable(NewType, G1->isConstant(), G1->getLinkage(), + new GlobalVariable(Context, NewType, G1->isConstant(), G1->getLinkage(), /*init*/0, First->first, M, G1->isThreadLocal(), G1->getType()->getAddressSpace()); Modified: llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp Tue Jul 7 20:26:06 2009 @@ -108,7 +108,7 @@ } ArrayType *AT = Context->getArrayType(SBP, AUGs.size()); Constant *Init = Context->getConstantArray(AT, AUGs); - GlobalValue *gv = new GlobalVariable(AT, false, + GlobalValue *gv = new GlobalVariable(M.getContext(), AT, false, GlobalValue::AppendingLinkage, Init, "llvm.used", &M); gv->setSection("llvm.metadata"); Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Jul 7 20:26:06 2009 @@ -490,12 +490,13 @@ Context->getConstantInt(Type::Int32Ty, i), Context); assert(In && "Couldn't get element of initializer?"); - GlobalVariable *NGV = new GlobalVariable(STy->getElementType(i), false, + GlobalVariable *NGV = new GlobalVariable(*Context, STy->getElementType(i), + false, GlobalVariable::InternalLinkage, In, GV->getName()+"."+utostr(i), (Module *)NULL, GV->isThreadLocal(), - GV->getType()->getAddressSpace()); + GV->getType()->getAddressSpace()); Globals.insert(GV, NGV); NewGlobals.push_back(NGV); @@ -526,7 +527,8 @@ Context); assert(In && "Couldn't get element of initializer?"); - GlobalVariable *NGV = new GlobalVariable(STy->getElementType(), false, + GlobalVariable *NGV = new GlobalVariable(*Context, STy->getElementType(), + false, GlobalVariable::InternalLinkage, In, GV->getName()+"."+utostr(i), (Module *)NULL, @@ -841,7 +843,8 @@ // Create the new global variable. The contents of the malloc'd memory is // undefined, so initialize with an undef value. Constant *Init = Context->getUndef(MI->getAllocatedType()); - GlobalVariable *NewGV = new GlobalVariable(MI->getAllocatedType(), false, + GlobalVariable *NewGV = new GlobalVariable(*Context, MI->getAllocatedType(), + false, GlobalValue::InternalLinkage, Init, GV->getName()+".body", (Module *)NULL, @@ -862,7 +865,8 @@ // If there is a comparison against null, we will insert a global bool to // keep track of whether the global was initialized yet or not. GlobalVariable *InitBool = - new GlobalVariable(Type::Int1Ty, false, GlobalValue::InternalLinkage, + new GlobalVariable(*Context, Type::Int1Ty, false, + GlobalValue::InternalLinkage, Context->getConstantIntFalse(), GV->getName()+".init", (Module *)NULL, GV->isThreadLocal()); bool InitBoolUsed = false; @@ -1282,7 +1286,8 @@ const Type *PFieldTy = Context->getPointerTypeUnqual(FieldTy); GlobalVariable *NGV = - new GlobalVariable(PFieldTy, false, GlobalValue::InternalLinkage, + new GlobalVariable(*Context, PFieldTy, false, + GlobalValue::InternalLinkage, Context->getNullValue(PFieldTy), GV->getName() + ".f" + utostr(FieldNo), GV, GV->isThreadLocal()); @@ -1579,7 +1584,7 @@ DOUT << " *** SHRINKING TO BOOL: " << *GV; // Create the new global, initializing it to false. - GlobalVariable *NewGV = new GlobalVariable(Type::Int1Ty, false, + GlobalVariable *NewGV = new GlobalVariable(*Context, Type::Int1Ty, false, GlobalValue::InternalLinkage, Context->getConstantIntFalse(), GV->getName()+".b", (Module *)NULL, @@ -1974,7 +1979,8 @@ } // Create the new global and insert it next to the existing list. - GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(), + GlobalVariable *NGV = new GlobalVariable(*Context, CA->getType(), + GCL->isConstant(), GCL->getLinkage(), CA, "", (Module *)NULL, GCL->isThreadLocal()); @@ -2222,7 +2228,7 @@ } else if (AllocaInst *AI = dyn_cast(CurInst)) { if (AI->isArrayAllocation()) return false; // Cannot handle array allocs. const Type *Ty = AI->getType()->getElementType(); - AllocaTmps.push_back(new GlobalVariable(Ty, false, + AllocaTmps.push_back(new GlobalVariable(*Context, Ty, false, GlobalValue::InternalLinkage, Context->getUndef(Ty), AI->getName())); Modified: llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp Tue Jul 7 20:26:06 2009 @@ -65,7 +65,7 @@ const Type *ATy = Context->getArrayType(Type::Int32Ty, NumFunctions); GlobalVariable *Counters = - new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, + new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage, Context->getNullValue(ATy), "FuncProfCounters", &M); // Instrument all of the functions... @@ -110,7 +110,7 @@ const Type *ATy = Context->getArrayType(Type::Int32Ty, NumBlocks); GlobalVariable *Counters = - new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, + new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage, Context->getNullValue(ATy), "BlockProfCounters", &M); // Instrument all of the blocks... Modified: llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp Tue Jul 7 20:26:06 2009 @@ -66,7 +66,7 @@ const Type *ATy = Context->getArrayType(Type::Int32Ty, NumEdges); GlobalVariable *Counters = - new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, + new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage, Context->getNullValue(ATy), "EdgeProfCounters", &M); // Instrument all of the edges... Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Tue Jul 7 20:26:06 2009 @@ -198,7 +198,8 @@ uint64_t resetval) : T(t) { ConstantInt* Init = M.getContext().getConstantInt(T, resetval); ResetValue = Init; - Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, + Counter = new GlobalVariable(M.getContext(), T, false, + GlobalValue::InternalLinkage, Init, "RandomSteeringCounter", &M); } @@ -237,7 +238,8 @@ : AI(0), T(t) { ConstantInt* Init = M.getContext().getConstantInt(T, resetval); ResetValue = Init; - Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, + Counter = new GlobalVariable(M.getContext(), T, false, + GlobalValue::InternalLinkage, Init, "RandomSteeringCounter", &M); } Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Tue Jul 7 20:26:06 2009 @@ -1290,7 +1290,8 @@ // pass to be run after this pass, to merge duplicate strings. FormatStr.erase(FormatStr.end()-1); Constant *C = Context->getConstantArray(FormatStr, true); - C = new GlobalVariable(C->getType(), true,GlobalVariable::InternalLinkage, + C = new GlobalVariable(*Context, C->getType(), + true, GlobalVariable::InternalLinkage, C, "str", Callee->getParent()); EmitPutS(C, B); return CI->use_empty() ? (Value*)CI : Modified: llvm/trunk/lib/Transforms/Utils/CloneModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneModule.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Tue Jul 7 20:26:06 2009 @@ -56,7 +56,8 @@ // for (Module::const_global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) { - GlobalVariable *GV = new GlobalVariable(I->getType()->getElementType(), + GlobalVariable *GV = new GlobalVariable(M->getContext(), + I->getType()->getElementType(), false, GlobalValue::ExternalLinkage, 0, I->getName(), New); Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Tue Jul 7 20:26:06 2009 @@ -139,7 +139,8 @@ // Now that we've done that, insert the jmpbuf list head global, unless it // already exists. if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))) { - JBListHead = new GlobalVariable(PtrJBList, false, + JBListHead = new GlobalVariable(M.getContext(), + PtrJBList, false, GlobalValue::LinkOnceAnyLinkage, Context->getNullValue(PtrJBList), "llvm.sjljeh.jblist", &M); @@ -182,7 +183,8 @@ Context->getConstantArray("ERROR: Exception thrown, but not caught!\n"); AbortMessageLength = Msg->getNumOperands()-1; // don't include \0 - GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true, + GlobalVariable *MsgGV = new GlobalVariable(M->getContext(), + Msg->getType(), true, GlobalValue::InternalLinkage, Msg, "abortmsg", M); std::vector GEPIdx(2, Context->getNullValue(Type::Int32Ty)); @@ -195,7 +197,8 @@ "Recompile program with -enable-correct-eh-support.\n"); AbortMessageLength = Msg->getNumOperands()-1; // don't include \0 - GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true, + GlobalVariable *MsgGV = new GlobalVariable(M->getContext(), + Msg->getType(), true, GlobalValue::InternalLinkage, Msg, "abortmsg", M); std::vector GEPIdx(2, Context->getNullValue(Type::Int32Ty)); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Tue Jul 7 20:26:06 2009 @@ -700,7 +700,8 @@ /*--.. Operations on global variables ......................................--*/ LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name) { - return wrap(new GlobalVariable(unwrap(Ty), false, + LLVMContext &Context = unwrap(M)->getContext(); + return wrap(new GlobalVariable(Context, unwrap(Ty), false, GlobalValue::ExternalLinkage, 0, Name, unwrap(M))); } Modified: llvm/trunk/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Globals.cpp (original) +++ llvm/trunk/lib/VMCore/Globals.cpp Tue Jul 7 20:26:06 2009 @@ -16,6 +16,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/GlobalAlias.h" #include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/LeakDetector.h" @@ -93,11 +94,13 @@ // GlobalVariable Implementation //===----------------------------------------------------------------------===// -GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link, +GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty, + bool constant, LinkageTypes Link, Constant *InitVal, const std::string &Name, Module *ParentModule, bool ThreadLocal, unsigned AddressSpace) - : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, + : GlobalValue(Context.getPointerType(Ty, AddressSpace), + Value::GlobalVariableVal, OperandTraits::op_begin(this), InitVal != 0, Link, Name), isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) { @@ -113,11 +116,13 @@ ParentModule->getGlobalList().push_back(this); } -GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link, +GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty, + bool constant, LinkageTypes Link, Constant *InitVal, const std::string &Name, GlobalVariable *Before, bool ThreadLocal, unsigned AddressSpace) - : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, + : GlobalValue(Context.getPointerType(Ty, AddressSpace), + Value::GlobalVariableVal, OperandTraits::op_begin(this), InitVal != 0, Link, Name), isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) { Modified: llvm/trunk/lib/VMCore/Module.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Module.cpp (original) +++ llvm/trunk/lib/VMCore/Module.cpp Tue Jul 7 20:26:06 2009 @@ -28,17 +28,20 @@ //===----------------------------------------------------------------------===// // Methods to implement the globals and functions lists. +// NOTE: It is ok to allocate the globals used for these methods from the +// global context, because all we ever do is use them to compare for equality. // GlobalVariable *ilist_traits::createSentinel() { - GlobalVariable *Ret = new GlobalVariable(Type::Int32Ty, false, + GlobalVariable *Ret = new GlobalVariable(getGlobalContext(), + Type::Int32Ty, false, GlobalValue::ExternalLinkage); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); return Ret; } GlobalAlias *ilist_traits::createSentinel() { - GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty, + GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty, GlobalValue::ExternalLinkage); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); @@ -270,7 +273,8 @@ if (GV == 0) { // Nope, add it GlobalVariable *New = - new GlobalVariable(Ty, false, GlobalVariable::ExternalLinkage, 0, Name); + new GlobalVariable(getContext(), Ty, false, + GlobalVariable::ExternalLinkage, 0, Name); GlobalList.push_back(New); return New; // Return the new declaration. } Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original) +++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Tue Jul 7 20:26:06 2009 @@ -236,7 +236,8 @@ GV->eraseFromParent(); if (!M1Tors.empty()) { Constant *M1Init = GetTorInit(M1Tors); - new GlobalVariable(M1Init->getType(), false, GlobalValue::AppendingLinkage, + new GlobalVariable(M1->getContext(), M1Init->getType(), false, + GlobalValue::AppendingLinkage, M1Init, GlobalName, M1); } @@ -247,7 +248,8 @@ GV->eraseFromParent(); if (!M2Tors.empty()) { Constant *M2Init = GetTorInit(M2Tors); - new GlobalVariable(M2Init->getType(), false, GlobalValue::AppendingLinkage, + new GlobalVariable(M2->getContext(), M2Init->getType(), false, + GlobalValue::AppendingLinkage, M2Init, GlobalName, M2); } } Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=74985&r1=74984&r2=74985&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original) +++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Tue Jul 7 20:26:06 2009 @@ -703,7 +703,8 @@ // 1. Add a string constant with its name to the global file Constant *InitArray = ConstantArray::get(F->getName()); GlobalVariable *funcName = - new GlobalVariable(InitArray->getType(), true /*isConstant*/, + new GlobalVariable(Safe->getContext(), + InitArray->getType(), true /*isConstant*/, GlobalValue::InternalLinkage, InitArray, F->getName() + "_name", Safe); @@ -722,7 +723,8 @@ // Create a new global to hold the cached function pointer. Constant *NullPtr = ConstantPointerNull::get(F->getType()); GlobalVariable *Cache = - new GlobalVariable(F->getType(), false,GlobalValue::InternalLinkage, + new GlobalVariable(F->getParent()->getContext(), + F->getType(), false,GlobalValue::InternalLinkage, NullPtr,F->getName()+".fpcache", F->getParent()); // Construct a new stub function that will re-route calls to F From resistor at mac.com Tue Jul 7 20:29:46 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 08 Jul 2009 01:29:46 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r74987 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-convert.cpp llvm-types.cpp Message-ID: <200907080129.n681TkqB008108@zion.cs.uiuc.edu> Author: resistor Date: Tue Jul 7 20:29:46 2009 New Revision: 74987 URL: http://llvm.org/viewvc/llvm-project?rev=74987&view=rev Log: Update for LLVM API change. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=74987&r1=74986&r2=74987&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue Jul 7 20:29:46 2009 @@ -286,7 +286,7 @@ Constant *LLVMValuesTable = ConstantStruct::get(ValuesForPCH, false); // Create variable to hold this string table. - new GlobalVariable(LLVMValuesTable->getType(), true, + new GlobalVariable(TheModule->getContext(), LLVMValuesTable->getType(), true, GlobalValue::ExternalLinkage, LLVMValuesTable, "llvm.pch.values", TheModule); @@ -804,7 +804,8 @@ Constant *Array = ConstantArray::get(ArrayType::get(InitList[0]->getType(), InitList.size()), InitList); - new GlobalVariable(Array->getType(), false, GlobalValue::AppendingLinkage, + new GlobalVariable(TheModule->getContext(), Array->getType(), false, + GlobalValue::AppendingLinkage, Array, Name, TheModule); } @@ -838,7 +839,7 @@ ArrayType *AT = ArrayType::get(SBP, AUGs.size()); Constant *Init = ConstantArray::get(AT, AUGs); - GlobalValue *gv = new GlobalVariable(AT, false, + GlobalValue *gv = new GlobalVariable(TheModule->getContext(), AT, false, GlobalValue::AppendingLinkage, Init, "llvm.used", TheModule); gv->setSection("llvm.metadata"); @@ -851,7 +852,8 @@ ConstantArray::get(ArrayType::get(AttributeAnnotateGlobals[0]->getType(), AttributeAnnotateGlobals.size()), AttributeAnnotateGlobals); - GlobalValue *gv = new GlobalVariable(Array->getType(), false, + GlobalValue *gv = new GlobalVariable(TheModule->getContext(), + Array->getType(), false, GlobalValue::AppendingLinkage, Array, "llvm.global.annotations", TheModule); gv->setSection("llvm.metadata"); @@ -1013,7 +1015,8 @@ if (!Aliasee) { if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))) { if (GlobalVariable *GV = dyn_cast(V)) - Aliasee = new GlobalVariable(GV->getType(), GV->isConstant(), + Aliasee = new GlobalVariable(TheModule->getContext(), + GV->getType(), GV->isConstant(), GlobalVariable::ExternalWeakLinkage, NULL, AliaseeName, TheModule); else if (Function *F = dyn_cast(V)) @@ -1084,7 +1087,8 @@ if (Slot) return Slot; // Create a new string global. - GlobalVariable *GV = new GlobalVariable(Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(TheModule->getContext(), + Init->getType(), true, GlobalVariable::InternalLinkage, Init, ".str", TheModule); GV->setSection("llvm.metadata"); @@ -1193,7 +1197,8 @@ // different from the union element used for the type. if (GV->getType()->getElementType() != Init->getType()) { GV->removeFromParent(); - GlobalVariable *NGV = new GlobalVariable(Init->getType(), GV->isConstant(), + GlobalVariable *NGV = new GlobalVariable(TheModule->getContext(), + Init->getType(), GV->isConstant(), GV->getLinkage(), 0, GV->getName(), TheModule); NGV->setVisibility(GV->getVisibility()); @@ -1269,7 +1274,8 @@ // different from the union element used for the type. if (GV->getType()->getElementType() != Init->getType()) { GV->removeFromParent(); - GlobalVariable *NGV = new GlobalVariable(Init->getType(), GV->isConstant(), + GlobalVariable *NGV = new GlobalVariable(TheModule->getContext(), + Init->getType(), GV->isConstant(), GlobalValue::ExternalLinkage, 0, GV->getName(), TheModule); GV->replaceAllUsesWith(TheFolder->CreateBitCast(NGV, GV->getType())); @@ -1562,7 +1568,8 @@ if (Ty == Type::VoidTy) Ty = StructType::get(NULL, NULL); if (Name[0] == 0) { // Global has no name. - GV = new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage, 0, + GV = new GlobalVariable(TheModule->getContext(), + Ty, false, GlobalValue::ExternalLinkage, 0, "", TheModule); // Check for external weak linkage. @@ -1580,7 +1587,8 @@ GlobalVariable *GVE = TheModule->getGlobalVariable(Name, true); if (GVE == 0) { - GV = new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage,0, + GV = new GlobalVariable(TheModule->getContext(), + Ty, false, GlobalValue::ExternalLinkage,0, Name, TheModule); // Check for external weak linkage. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=74987&r1=74986&r2=74987&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Jul 7 20:29:46 2009 @@ -7779,7 +7779,7 @@ if (Slot) return Slot; // Create a new complex global. - Slot = new GlobalVariable(Init->getType(), true, + Slot = new GlobalVariable(TheModule->getContext(), Init->getType(), true, GlobalVariable::InternalLinkage, Init, ".cpx", TheModule); return Slot; @@ -7804,7 +7804,8 @@ // Create a new string global. const TargetAsmInfo *TAI = TheTarget->getTargetAsmInfo(); - GlobalVariable *GV = new GlobalVariable(Init->getType(), StringIsConstant, + GlobalVariable *GV = new GlobalVariable(TheModule->getContext(), + Init->getType(), StringIsConstant, GlobalVariable::InternalLinkage, Init, TAI ? TAI->getStringConstantPrefix() : Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=74987&r1=74986&r2=74987&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Tue Jul 7 20:29:46 2009 @@ -192,7 +192,8 @@ Constant *LTypesNameTable = ConstantStruct::get(LTypesNames, false); // Create variable to hold this string table. - GlobalVariable *GV = new GlobalVariable(LTypesNameTable->getType(), true, + GlobalVariable *GV = new GlobalVariable(TheModule->getContext(), + LTypesNameTable->getType(), true, GlobalValue::ExternalLinkage, LTypesNameTable, "llvm.pch.types", TheModule); From gohman at apple.com Tue Jul 7 20:29:53 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 7 Jul 2009 18:29:53 -0700 Subject: [llvm-commits] [llvm] r74964 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/vec_compare.ll In-Reply-To: <200907072303.n67N3tpM003424@zion.cs.uiuc.edu> References: <200907072303.n67N3tpM003424@zion.cs.uiuc.edu> Message-ID: On Jul 7, 2009, at 4:03 PM, Chris Lattner wrote: > Author: lattner > Date: Tue Jul 7 18:03:54 2009 > New Revision: 74964 > > URL: http://llvm.org/viewvc/llvm-project?rev=74964&view=rev > Log: > add support for legalizing an icmp where the result is illegal > (4xi1) but > the input is legal (4 x i32) > > Modified: > llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp > llvm/trunk/test/CodeGen/X86/vec_compare.ll > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=74964&r1=74963&r2=74964&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp > (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Tue > Jul 7 18:03:54 2009 > @@ -891,15 +891,38 @@ > > void DAGTypeLegalizer::SplitVecRes_SETCC(SDNode *N, SDValue &Lo, > SDValue &Hi) { > MVT LoVT, HiVT; > - DebugLoc dl = N->getDebugLoc(); > + DebugLoc DL = N->getDebugLoc(); > GetSplitDestVTs(N->getValueType(0), LoVT, HiVT); > - > + > + // Split the input. > + MVT InVT = N->getOperand(0).getValueType(); > SDValue LL, LH, RL, RH; > - GetSplitVector(N->getOperand(0), LL, LH); > - GetSplitVector(N->getOperand(1), RL, RH); > - > - Lo = DAG.getNode(N->getOpcode(), dl, LoVT, LL, RL, N->getOperand > (2)); > - Hi = DAG.getNode(N->getOpcode(), dl, HiVT, LH, RH, N->getOperand > (2)); > + switch (getTypeAction(InVT)) { > + default: assert(0 && "Unexpected type action!"); > + case WidenVector: assert(0 && "Unimp"); > + case Legal: { > + assert(LoVT == HiVT && "Legal non-power-of-two vector type?"); > + MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(), > + LoVT.getVectorNumElements()); > + LL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N- > >getOperand(0), > + DAG.getIntPtrConstant(0)); > + LH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N- > >getOperand(0), > + DAG.getIntPtrConstant > (InNVT.getVectorNumElements())); > + > + RL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N- > >getOperand(1), > + DAG.getIntPtrConstant(0)); > + RH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N- > >getOperand(1), > + DAG.getIntPtrConstant > (InNVT.getVectorNumElements())); > + break; > + } Hi Chris, EXTRACT_SUBVECTOR is normally used to extract a legal value from an illegal one. The code above does the opposite, extracting a potentially illegal value from a legal one. Right now, this code only happens to work on x86 by coincidence: because of MMX, types <2 x i32> and <2 x float> are legal. But if you compile the included testcase with -disable-mmx, these types are not legal, and CodeGen aborts. Dan From evan.cheng at apple.com Tue Jul 7 20:46:36 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 08 Jul 2009 01:46:36 -0000 Subject: [llvm-commits] [llvm] r74988 - in /llvm/trunk/lib/Target/ARM: ARM.td ARMInstrFormats.td ARMInstrInfo.h Message-ID: <200907080146.n681kaKa008569@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jul 7 20:46:35 2009 New Revision: 74988 URL: http://llvm.org/viewvc/llvm-project?rev=74988&view=rev Log: Add a Thumb2 instruction flag to that indicates whether the instruction can be transformed to 16-bit variant. Modified: llvm/trunk/lib/Target/ARM/ARM.td llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=74988&r1=74987&r2=74988&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Tue Jul 7 20:46:35 2009 @@ -131,13 +131,13 @@ let TSFlagsFields = ["AddrModeBits", "SizeFlag", "IndexModeBits", - "isUnaryDataProc", - "Form"]; + "Form", + "isUnaryDataProc"]; let TSFlagsShifts = [0, 4, 7, 9, - 10]; + 15]; } //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=74988&r1=74987&r2=74988&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Tue Jul 7 20:46:35 2009 @@ -54,9 +54,16 @@ def NEONSetLnFrm : Format<26>; def NEONDupFrm : Format<27>; -// Misc flag for data processing instructions that indicates whether +// Misc flags. + // the instruction has a Rn register operand. -class UnaryDP { bit isUnaryDataProc = 1; } +// UnaryDP - Indicates this is a unary data processing instruction, i.e. +// it doesn't have a Rn operand. +class UnaryDP { bit isUnaryDataProc = 1; } + +// Xform16Bit - Indicates this Thumb2 instruction may be transformed into +// a 16-bit Thumb instruction if certain conditions are met. +class Xform16Bit { bit canXformTo16Bit = 1; } //===----------------------------------------------------------------------===// // ARM Instruction flags. These need to match ARMInstrInfo.h. @@ -130,6 +137,7 @@ // Attributes specific to ARM instructions... // bit isUnaryDataProc = 0; + bit canXformTo16Bit = 0; let Constraints = cstr; } Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.h?rev=74988&r1=74987&r2=74988&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Tue Jul 7 20:46:35 2009 @@ -66,17 +66,10 @@ IndexModePost = 2, //===------------------------------------------------------------------===// - // Misc flags. - - // UnaryDP - Indicates this is a unary data processing instruction, i.e. - // it doesn't have a Rn operand. - UnaryDP = 1 << 9, - - //===------------------------------------------------------------------===// // Instruction encoding formats. // - FormShift = 10, - FormMask = 0x1f << FormShift, + FormShift = 9, + FormMask = 0x3f << FormShift, // Pseudo instructions Pseudo = 0 << FormShift, @@ -127,6 +120,17 @@ NEONDupFrm = 27 << FormShift, //===------------------------------------------------------------------===// + // Misc flags. + + // UnaryDP - Indicates this is a unary data processing instruction, i.e. + // it doesn't have a Rn operand. + UnaryDP = 1 << 15, + + // Xform16Bit - Indicates this Thumb2 instruction may be transformed into + // a 16-bit Thumb instruction if certain conditions are met. + Xform16Bit = 1 << 16, + + //===------------------------------------------------------------------===// // Field shifts - such shifts are used to set field while generating // machine instructions. M_BitShift = 5, From eli.friedman at gmail.com Tue Jul 7 21:16:36 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 7 Jul 2009 19:16:36 -0700 Subject: [llvm-commits] [llvm] r74964 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/vec_compare.ll In-Reply-To: References: <200907072303.n67N3tpM003424@zion.cs.uiuc.edu> Message-ID: On Tue, Jul 7, 2009 at 6:29 PM, Dan Gohman wrote: > EXTRACT_SUBVECTOR is normally used to extract a legal value from > an illegal one. The code above does the opposite, extracting a > potentially illegal value from a legal one. As far as I can tell, we support both cases properly in type legalization; what specific case breaks? -Eli From eli.friedman at gmail.com Tue Jul 7 21:38:03 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 7 Jul 2009 19:38:03 -0700 Subject: [llvm-commits] [llvm] r74964 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/vec_compare.ll In-Reply-To: References: <200907072303.n67N3tpM003424@zion.cs.uiuc.edu> Message-ID: On Tue, Jul 7, 2009 at 7:16 PM, Eli Friedman wrote: > On Tue, Jul 7, 2009 at 6:29 PM, Dan Gohman wrote: >> EXTRACT_SUBVECTOR is normally used to extract a legal value from >> an illegal one. The code above does the opposite, extracting a >> potentially illegal value from a legal one. > > As far as I can tell, we support both cases properly in type > legalization; what specific case breaks? Mmm, nevermind, you're talking about something like the following? define void @test2(<2 x i32> %A, <2 x i32> %B, <2 x i32>* %C) nounwind { %D = icmp sgt <2 x i32> %A, %B %E = zext <2 x i1> %D to <2 x i32> store <2 x i32> %E, <2 x i32>* %C ret void } It's really just falling apart because we don't support various related cases correctly; first, it hits the "Unimp" assert in this patch, and if you just comment it out (which seems like the right thing to do), we hit an assertion because we don't support extracting an i1 from a <2 x i1> in PromoteIntRes_EXTRACT_VECTOR_ELT . Still nothing going wrong with EXTRACT_SUBVECTOR. -Eli From rnk at mit.edu Tue Jul 7 12:24:48 2009 From: rnk at mit.edu (Reid Kleckner) Date: Tue, 7 Jul 2009 10:24:48 -0700 Subject: [llvm-commits] [patch] JITCodeEmitter speedup patch In-Reply-To: <9719867c0907070827r60eb90c2q52c6a3fa52b933d7@mail.gmail.com> References: <9719867c0907070827r60eb90c2q52c6a3fa52b933d7@mail.gmail.com> Message-ID: <9a9942200907071024l5186d982m86afbaff2326dc03@mail.gmail.com> On Tue, Jul 7, 2009 at 8:27 AM, Aaron Gray wrote: > It also has a extend() method for extending the buffer and continuing if th > buffer overfolws. And a reserveBytes that can be used in conjunction with > the raw*emit methods to allow a whole instruction to be output without any > buffer checking. Are you planning to change the JITEmitter to JITMemoryManager API with this extend method? From what I can tell this just moves the FIXME around. There are two ways I can see the JITEmitter working: 1) The current API where the target-specific CodeEmitters wrap emission in a do { startFunction(F); ... } while (finishFunction(F)); loop. When finishFunction fails and returns true, the memory manager needs to try again with more memory next time. This is what I've been working on. I've fixed up the emitter so that it will request more memory, and the memory manager so that it will actually allocate more blocks of memory when it runs out. 2) A nicer API where we emit code into a buffer, say a raw_ostream or vector, figure out how big it is, allocate exactly that much memory, and then run the relocations over it *after* it has been emitted. The trick here is that you don't actually know the function start address until after you've emitted the code, and I don't know how much that complicates code generation. If we can take care of that with relocations, then I see no reason to use the more complex API #1. However, there could be other reasons why people chose API #1 back in the day that I'm not aware of. I'm just wondering what the plan is. Reid From nicholas at mxc.ca Tue Jul 7 22:04:43 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 08 Jul 2009 03:04:43 -0000 Subject: [llvm-commits] [llvm] r74991 - in /llvm/trunk: docs/ include/llvm-c/ include/llvm/ include/llvm/Bitcode/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Transforms/Scalar/ lib/VMCore/ test/Assembler/ test/Transforms/ConstProp/ utils/ Message-ID: <200907080304.n6834jBx010818@zion.cs.uiuc.edu> Author: nicholas Date: Tue Jul 7 22:04:38 2009 New Revision: 74991 URL: http://llvm.org/viewvc/llvm-project?rev=74991&view=rev Log: Remove the vicmp and vfcmp instructions. Because we never had a release with these instructions, no autoupgrade or backwards compatibility support is provided. Modified: llvm/trunk/docs/LangRef.html llvm/trunk/include/llvm-c/Core.h llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h llvm/trunk/include/llvm/Constants.h llvm/trunk/include/llvm/InstrTypes.h llvm/trunk/include/llvm/Instruction.def llvm/trunk/include/llvm/Instructions.h llvm/trunk/include/llvm/LLVMContext.h llvm/trunk/include/llvm/Support/ConstantFolder.h llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/include/llvm/Support/InstVisitor.h llvm/trunk/include/llvm/Support/NoFolder.h llvm/trunk/include/llvm/Support/TargetFolder.h llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Instruction.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/lib/VMCore/LLVMContext.cpp llvm/trunk/test/Assembler/vector-cmp.ll llvm/trunk/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll llvm/trunk/utils/llvm.grm Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Jul 7 22:04:38 2009 @@ -155,8 +155,6 @@
    1. 'icmp' Instruction
    2. 'fcmp' Instruction
    3. -
    4. 'vicmp' Instruction
    5. -
    6. 'vfcmp' Instruction
    7. 'phi' Instruction
    8. 'select' Instruction
    9. 'call' Instruction
    10. @@ -2042,12 +2040,6 @@
      fcmp COND ( VAL1, VAL2 )
      Performs the fcmp operation on constants.
      -
      vicmp COND ( VAL1, VAL2 )
      -
      Performs the vicmp operation on constants.
      - -
      vfcmp COND ( VAL1, VAL2 )
      -
      Performs the vfcmp operation on constants.
      -
      extractelement ( VAL, IDX )
      Perform the extractelement @@ -4506,109 +4498,6 @@ -
      -
      Syntax:
      -
        <result> = vicmp <cond> <ty> <op1>, <op2>   ; yields {ty}:result
      -
      -
      Overview:
      -

      The 'vicmp' instruction returns an integer vector value based on -element-wise comparison of its two integer vector operands.

      -
      Arguments:
      -

      The 'vicmp' instruction takes three operands. The first operand is -the condition code indicating the kind of comparison to perform. It is not -a value, just a keyword. The possible condition code are:

      -
        -
      1. eq: equal
      2. -
      3. ne: not equal
      4. -
      5. ugt: unsigned greater than
      6. -
      7. uge: unsigned greater or equal
      8. -
      9. ult: unsigned less than
      10. -
      11. ule: unsigned less or equal
      12. -
      13. sgt: signed greater than
      14. -
      15. sge: signed greater or equal
      16. -
      17. slt: signed less than
      18. -
      19. sle: signed less or equal
      20. -
      -

      The remaining two arguments must be vector or -integer typed. They must also be identical types.

      -
      Semantics:
      -

      The 'vicmp' instruction compares op1 and op2 -according to the condition code given as cond. The comparison yields a -vector of integer result, of -identical type as the values being compared. The most significant bit in each -element is 1 if the element-wise comparison evaluates to true, and is 0 -otherwise. All other bits of the result are undefined. The condition codes -are evaluated identically to the 'icmp' -instruction.

      - -
      Example:
      -
      -  <result> = vicmp eq <2 x i32> < i32 4, i32 0>, < i32 5, i32 0>   ; yields: result=<2 x i32> < i32 0, i32 -1 >
      -  <result> = vicmp ult <2 x i8 > < i8 1, i8 2>, < i8 2, i8 2 >        ; yields: result=<2 x i8> < i8 -1, i8 0 >
      -
      -
      - - - -
      -
      Syntax:
      -
        <result> = vfcmp <cond> <ty> <op1>, <op2>
      -
      Overview:
      -

      The 'vfcmp' instruction returns an integer vector value based on -element-wise comparison of its two floating point vector operands. The output -elements have the same width as the input elements.

      -
      Arguments:
      -

      The 'vfcmp' instruction takes three operands. The first operand is -the condition code indicating the kind of comparison to perform. It is not -a value, just a keyword. The possible condition code are:

      -
        -
      1. false: no comparison, always returns false
      2. -
      3. oeq: ordered and equal
      4. -
      5. ogt: ordered and greater than
      6. -
      7. oge: ordered and greater than or equal
      8. -
      9. olt: ordered and less than
      10. -
      11. ole: ordered and less than or equal
      12. -
      13. one: ordered and not equal
      14. -
      15. ord: ordered (no nans)
      16. -
      17. ueq: unordered or equal
      18. -
      19. ugt: unordered or greater than
      20. -
      21. uge: unordered or greater than or equal
      22. -
      23. ult: unordered or less than
      24. -
      25. ule: unordered or less than or equal
      26. -
      27. une: unordered or not equal
      28. -
      29. uno: unordered (either nans)
      30. -
      31. true: no comparison, always returns true
      32. -
      -

      The remaining two arguments must be vector of -floating point typed. They must also be identical -types.

      -
      Semantics:
      -

      The 'vfcmp' instruction compares op1 and op2 -according to the condition code given as cond. The comparison yields a -vector of integer result, with -an identical number of elements as the values being compared, and each element -having identical with to the width of the floating point elements. The most -significant bit in each element is 1 if the element-wise comparison evaluates to -true, and is 0 otherwise. All other bits of the result are undefined. The -condition codes are evaluated identically to the -'fcmp' instruction.

      - -
      Example:
      -
      -  ; yields: result=<2 x i32> < i32 0, i32 -1 >
      -  <result> = vfcmp oeq <2 x float> < float 4, float 0 >, < float 5, float 0 >
      -  
      -  ; yields: result=<2 x i64> < i64 -1, i64 0 >
      -  <result> = vfcmp ult <2 x double> < double 1, double 2 >, < double 2, double 2>
      -
      -
      - - - Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Tue Jul 7 22:04:38 2009 @@ -341,8 +341,6 @@ macro(CmpInst) \ macro(FCmpInst) \ macro(ICmpInst) \ - macro(VFCmpInst) \ - macro(VICmpInst) \ macro(ExtractElementInst) \ macro(GetElementPtrInst) \ macro(InsertElementInst) \ Modified: llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h (original) +++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h Tue Jul 7 22:04:38 2009 @@ -210,7 +210,8 @@ FUNC_CODE_INST_GETRESULT = 25, // GETRESULT: [ty, opval, n] FUNC_CODE_INST_EXTRACTVAL = 26, // EXTRACTVAL: [n x operands] FUNC_CODE_INST_INSERTVAL = 27, // INSERTVAL: [n x operands] - // fcmp/icmp returning Int1TY or vector of Int1Ty, NOT for vicmp/vfcmp + // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, exists to + // support legacy vicmp/vfcmp instructions. FUNC_CODE_INST_CMP2 = 28, // CMP2: [opty, opval, opval, pred] // new select on i1 or [N x i1] FUNC_CODE_INST_VSELECT = 29 // VSELECT: [ty,opval,opval,predty,pred] Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Tue Jul 7 22:04:38 2009 @@ -710,8 +710,7 @@ /// static Constant *get(unsigned Opcode, Constant *C1, Constant *C2); - /// @brief Return an ICmp, FCmp, VICmp, or VFCmp comparison operator constant - /// expression. + /// @brief Return an ICmp or FCmp comparison operator constant expression. static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2); /// ConstantExpr::get* - Return some common constants without having to @@ -737,8 +736,6 @@ static Constant *getXor(Constant *C1, Constant *C2); static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS); - static Constant *getVICmp(unsigned short pred, Constant *LHS, Constant *RHS); - static Constant *getVFCmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getShl(Constant *C1, Constant *C2); static Constant *getLShr(Constant *C1, Constant *C2); static Constant *getAShr(Constant *C1, Constant *C2); Modified: llvm/trunk/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/InstrTypes.h (original) +++ llvm/trunk/include/llvm/InstrTypes.h Tue Jul 7 22:04:38 2009 @@ -655,14 +655,12 @@ static inline bool classof(const CmpInst *) { return true; } static inline bool classof(const Instruction *I) { return I->getOpcode() == Instruction::ICmp || - I->getOpcode() == Instruction::FCmp || - I->getOpcode() == Instruction::VICmp || - I->getOpcode() == Instruction::VFCmp; + I->getOpcode() == Instruction::FCmp; } static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } - /// @brief Create a result type for fcmp/icmp (but not vicmp/vfcmp) + /// @brief Create a result type for fcmp/icmp static const Type* makeCmpResultType(const Type* opnd_type) { if (const VectorType* vt = dyn_cast(opnd_type)) { return VectorType::get(Type::Int1Ty, vt->getNumElements()); Modified: llvm/trunk/include/llvm/Instruction.def URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.def?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instruction.def (original) +++ llvm/trunk/include/llvm/Instruction.def Tue Jul 7 22:04:38 2009 @@ -169,10 +169,8 @@ HANDLE_OTHER_INST(53, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. HANDLE_OTHER_INST(54, ExtractValue, ExtractValueInst)// extract from aggregate HANDLE_OTHER_INST(55, InsertValue, InsertValueInst) // insert into aggregate -HANDLE_OTHER_INST(56, VICmp , VICmpInst ) // Vec Int comparison instruction. -HANDLE_OTHER_INST(57, VFCmp , VFCmpInst ) // Vec FP point comparison instr. - LAST_OTHER_INST(57) + LAST_OTHER_INST(55) #undef FIRST_TERM_INST #undef HANDLE_TERM_INST Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Tue Jul 7 22:04:38 2009 @@ -862,118 +862,6 @@ }; //===----------------------------------------------------------------------===// -// VICmpInst Class -//===----------------------------------------------------------------------===// - -/// This instruction compares its operands according to the predicate given -/// to the constructor. It only operates on vectors of integers. -/// The operands must be identical types. -/// @brief Represents a vector integer comparison operator. -class VICmpInst: public CmpInst { -public: - /// @brief Constructor with insert-before-instruction semantics. - VICmpInst( - Predicate pred, ///< The predicate to use for the comparison - Value *LHS, ///< The left-hand-side of the expression - Value *RHS, ///< The right-hand-side of the expression - const std::string &NameStr = "", ///< Name of the instruction - Instruction *InsertBefore = 0 ///< Where to insert - ) : CmpInst(LHS->getType(), Instruction::VICmp, pred, LHS, RHS, NameStr, - InsertBefore) { - assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && - pred <= CmpInst::LAST_ICMP_PREDICATE && - "Invalid VICmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to VICmp instruction are not of the same type!"); - } - - /// @brief Constructor with insert-at-block-end semantics. - VICmpInst( - Predicate pred, ///< The predicate to use for the comparison - Value *LHS, ///< The left-hand-side of the expression - Value *RHS, ///< The right-hand-side of the expression - const std::string &NameStr, ///< Name of the instruction - BasicBlock *InsertAtEnd ///< Block to insert into. - ) : CmpInst(LHS->getType(), Instruction::VICmp, pred, LHS, RHS, NameStr, - InsertAtEnd) { - assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && - pred <= CmpInst::LAST_ICMP_PREDICATE && - "Invalid VICmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to VICmp instruction are not of the same type!"); - } - - /// @brief Return the predicate for this instruction. - Predicate getPredicate() const { return Predicate(SubclassData); } - - virtual VICmpInst *clone() const; - - // Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const VICmpInst *) { return true; } - static inline bool classof(const Instruction *I) { - return I->getOpcode() == Instruction::VICmp; - } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } -}; - -//===----------------------------------------------------------------------===// -// VFCmpInst Class -//===----------------------------------------------------------------------===// - -/// This instruction compares its operands according to the predicate given -/// to the constructor. It only operates on vectors of floating point values. -/// The operands must be identical types. -/// @brief Represents a vector floating point comparison operator. -class VFCmpInst: public CmpInst { -public: - /// @brief Constructor with insert-before-instruction semantics. - VFCmpInst( - Predicate pred, ///< The predicate to use for the comparison - Value *LHS, ///< The left-hand-side of the expression - Value *RHS, ///< The right-hand-side of the expression - const std::string &NameStr = "", ///< Name of the instruction - Instruction *InsertBefore = 0 ///< Where to insert - ) : CmpInst(VectorType::getInteger(cast(LHS->getType())), - Instruction::VFCmp, pred, LHS, RHS, NameStr, InsertBefore) { - assert(pred <= CmpInst::LAST_FCMP_PREDICATE && - "Invalid VFCmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to VFCmp instruction are not of the same type!"); - } - - /// @brief Constructor with insert-at-block-end semantics. - VFCmpInst( - Predicate pred, ///< The predicate to use for the comparison - Value *LHS, ///< The left-hand-side of the expression - Value *RHS, ///< The right-hand-side of the expression - const std::string &NameStr, ///< Name of the instruction - BasicBlock *InsertAtEnd ///< Block to insert into. - ) : CmpInst(VectorType::getInteger(cast(LHS->getType())), - Instruction::VFCmp, pred, LHS, RHS, NameStr, InsertAtEnd) { - assert(pred <= CmpInst::LAST_FCMP_PREDICATE && - "Invalid VFCmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to VFCmp instruction are not of the same type!"); - } - - /// @brief Return the predicate for this instruction. - Predicate getPredicate() const { return Predicate(SubclassData); } - - virtual VFCmpInst *clone() const; - - /// @brief Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const VFCmpInst *) { return true; } - static inline bool classof(const Instruction *I) { - return I->getOpcode() == Instruction::VFCmp; - } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } -}; - -//===----------------------------------------------------------------------===// // CallInst Class //===----------------------------------------------------------------------===// /// CallInst - This class represents a function call, abstracting a target Modified: llvm/trunk/include/llvm/LLVMContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/LLVMContext.h (original) +++ llvm/trunk/include/llvm/LLVMContext.h Tue Jul 7 22:04:38 2009 @@ -145,10 +145,6 @@ Constant* RHS); Constant* getConstantExprFCmp(unsigned short pred, Constant* LHS, Constant* RHS); - Constant* getConstantExprVICmp(unsigned short pred, Constant* LHS, - Constant* RHS); - Constant* getConstantExprVFCmp(unsigned short pred, Constant* LHS, - Constant* RHS); Constant* getConstantExprShl(Constant* C1, Constant* C2); Constant* getConstantExprLShr(Constant* C1, Constant* C2); Constant* getConstantExprAShr(Constant* C1, Constant* C2); Modified: llvm/trunk/include/llvm/Support/ConstantFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantFolder.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ConstantFolder.h (original) +++ llvm/trunk/include/llvm/Support/ConstantFolder.h Tue Jul 7 22:04:38 2009 @@ -154,14 +154,6 @@ Constant *RHS) const { return ConstantExpr::getCompare(P, LHS, RHS); } - Constant *CreateVICmp(CmpInst::Predicate P, Constant *LHS, - Constant *RHS) const { - return ConstantExpr::getCompare(P, LHS, RHS); - } - Constant *CreateVFCmp(CmpInst::Predicate P, Constant *LHS, - Constant *RHS) const { - return ConstantExpr::getCompare(P, LHS, RHS); - } //===--------------------------------------------------------------------===// // Other Instructions Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Tue Jul 7 22:04:38 2009 @@ -570,21 +570,6 @@ return Insert(new FCmpInst(P, LHS, RHS), Name); } - Value *CreateVICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, - const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return Folder.CreateVICmp(P, LC, RC); - return Insert(new VICmpInst(P, LHS, RHS), Name); - } - Value *CreateVFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, - const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return Folder.CreateVFCmp(P, LC, RC); - return Insert(new VFCmpInst(P, LHS, RHS), Name); - } - //===--------------------------------------------------------------------===// // Instruction creation methods: Other Instructions //===--------------------------------------------------------------------===// Modified: llvm/trunk/include/llvm/Support/InstVisitor.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/InstVisitor.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/InstVisitor.h (original) +++ llvm/trunk/include/llvm/Support/InstVisitor.h Tue Jul 7 22:04:38 2009 @@ -165,8 +165,6 @@ RetTy visitUnreachableInst(UnreachableInst &I) { DELEGATE(TerminatorInst);} RetTy visitICmpInst(ICmpInst &I) { DELEGATE(CmpInst);} RetTy visitFCmpInst(FCmpInst &I) { DELEGATE(CmpInst);} - RetTy visitVICmpInst(VICmpInst &I) { DELEGATE(CmpInst);} - RetTy visitVFCmpInst(VFCmpInst &I) { DELEGATE(CmpInst);} RetTy visitMallocInst(MallocInst &I) { DELEGATE(AllocationInst);} RetTy visitAllocaInst(AllocaInst &I) { DELEGATE(AllocationInst);} RetTy visitFreeInst(FreeInst &I) { DELEGATE(Instruction); } Modified: llvm/trunk/include/llvm/Support/NoFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/NoFolder.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/NoFolder.h (original) +++ llvm/trunk/include/llvm/Support/NoFolder.h Tue Jul 7 22:04:38 2009 @@ -143,12 +143,6 @@ Value *CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const { return new FCmpInst(P, LHS, RHS); } - Value *CreateVICmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const { - return new VICmpInst(P, LHS, RHS); - } - Value *CreateVFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const { - return new VFCmpInst(P, LHS, RHS); - } //===--------------------------------------------------------------------===// // Other Instructions Modified: llvm/trunk/include/llvm/Support/TargetFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetFolder.h (original) +++ llvm/trunk/include/llvm/Support/TargetFolder.h Tue Jul 7 22:04:38 2009 @@ -179,14 +179,6 @@ Constant *RHS) const { return Fold(ConstantExpr::getCompare(P, LHS, RHS)); } - Constant *CreateVICmp(CmpInst::Predicate P, Constant *LHS, - Constant *RHS) const { - return Fold(ConstantExpr::getCompare(P, LHS, RHS)); - } - Constant *CreateVFCmp(CmpInst::Predicate P, Constant *LHS, - Constant *RHS) const { - return Fold(ConstantExpr::getCompare(P, LHS, RHS)); - } //===--------------------------------------------------------------------===// // Other Instructions Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Tue Jul 7 22:04:38 2009 @@ -365,8 +365,6 @@ return 0; case Instruction::ICmp: case Instruction::FCmp: - case Instruction::VICmp: - case Instruction::VFCmp: assert(0 &&"This function is invalid for compares: no predicate specified"); case Instruction::PtrToInt: // If the input is a inttoptr, eliminate the pair. This requires knowing Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Tue Jul 7 22:04:38 2009 @@ -591,7 +591,6 @@ INSTKEYWORD(shl, Shl); INSTKEYWORD(lshr, LShr); INSTKEYWORD(ashr, AShr); INSTKEYWORD(and, And); INSTKEYWORD(or, Or); INSTKEYWORD(xor, Xor); INSTKEYWORD(icmp, ICmp); INSTKEYWORD(fcmp, FCmp); - INSTKEYWORD(vicmp, VICmp); INSTKEYWORD(vfcmp, VFCmp); INSTKEYWORD(phi, PHI); INSTKEYWORD(call, Call); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Jul 7 22:04:38 2009 @@ -1847,9 +1847,7 @@ return false; } case lltok::kw_icmp: - case lltok::kw_fcmp: - case lltok::kw_vicmp: - case lltok::kw_vfcmp: { + case lltok::kw_fcmp: { unsigned PredVal, Opc = Lex.getUIntVal(); Constant *Val0, *Val1; Lex.Lex(); @@ -1870,23 +1868,12 @@ if (!Val0->getType()->isFPOrFPVector()) return Error(ID.Loc, "fcmp requires floating point operands"); ID.ConstantVal = Context.getConstantExprFCmp(Pred, Val0, Val1); - } else if (Opc == Instruction::ICmp) { + } else { + assert(Opc == Instruction::ICmp && "Unexpected opcode for CmpInst!"); if (!Val0->getType()->isIntOrIntVector() && !isa(Val0->getType())) return Error(ID.Loc, "icmp requires pointer or integer operands"); ID.ConstantVal = Context.getConstantExprICmp(Pred, Val0, Val1); - } else if (Opc == Instruction::VFCmp) { - // FIXME: REMOVE VFCMP Support - if (!Val0->getType()->isFPOrFPVector() || - !isa(Val0->getType())) - return Error(ID.Loc, "vfcmp requires vector floating point operands"); - ID.ConstantVal = Context.getConstantExprVFCmp(Pred, Val0, Val1); - } else if (Opc == Instruction::VICmp) { - // FIXME: REMOVE VICMP Support - if (!Val0->getType()->isIntOrIntVector() || - !isa(Val0->getType())) - return Error(ID.Loc, "vicmp requires vector floating point operands"); - ID.ConstantVal = Context.getConstantExprVICmp(Pred, Val0, Val1); } ID.Kind = ValID::t_Constant; return false; @@ -2485,9 +2472,7 @@ case lltok::kw_or: case lltok::kw_xor: return ParseLogical(Inst, PFS, KeywordVal); case lltok::kw_icmp: - case lltok::kw_fcmp: - case lltok::kw_vicmp: - case lltok::kw_vfcmp: return ParseCompare(Inst, PFS, KeywordVal); + case lltok::kw_fcmp: return ParseCompare(Inst, PFS, KeywordVal); // Casts. case lltok::kw_trunc: case lltok::kw_zext: @@ -2532,8 +2517,7 @@ /// ParseCmpPredicate - Parse an integer or fp predicate, based on Kind. bool LLParser::ParseCmpPredicate(unsigned &P, unsigned Opc) { - // FIXME: REMOVE vicmp/vfcmp! - if (Opc == Instruction::FCmp || Opc == Instruction::VFCmp) { + if (Opc == Instruction::FCmp) { switch (Lex.getKind()) { default: TokError("expected fcmp predicate (e.g. 'oeq')"); case lltok::kw_oeq: P = CmpInst::FCMP_OEQ; break; @@ -2862,8 +2846,6 @@ /// ParseCompare /// ::= 'icmp' IPredicates TypeAndValue ',' Value /// ::= 'fcmp' FPredicates TypeAndValue ',' Value -/// ::= 'vicmp' IPredicates TypeAndValue ',' Value -/// ::= 'vfcmp' FPredicates TypeAndValue ',' Value bool LLParser::ParseCompare(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc) { // Parse the integer/fp comparison predicate. @@ -2880,19 +2862,12 @@ if (!LHS->getType()->isFPOrFPVector()) return Error(Loc, "fcmp requires floating point operands"); Inst = new FCmpInst(CmpInst::Predicate(Pred), LHS, RHS); - } else if (Opc == Instruction::ICmp) { + } else { + assert(Opc == Instruction::ICmp && "Unknown opcode for CmpInst!"); if (!LHS->getType()->isIntOrIntVector() && !isa(LHS->getType())) return Error(Loc, "icmp requires integer operands"); Inst = new ICmpInst(CmpInst::Predicate(Pred), LHS, RHS); - } else if (Opc == Instruction::VFCmp) { - if (!LHS->getType()->isFPOrFPVector() || !isa(LHS->getType())) - return Error(Loc, "vfcmp requires vector floating point operands"); - Inst = new VFCmpInst(CmpInst::Predicate(Pred), LHS, RHS); - } else if (Opc == Instruction::VICmp) { - if (!LHS->getType()->isIntOrIntVector() || !isa(LHS->getType())) - return Error(Loc, "vicmp requires vector floating point operands"); - Inst = new VICmpInst(CmpInst::Predicate(Pred), LHS, RHS); } return false; } Modified: llvm/trunk/lib/AsmParser/LLToken.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLToken.h (original) +++ llvm/trunk/lib/AsmParser/LLToken.h Tue Jul 7 22:04:38 2009 @@ -96,7 +96,7 @@ kw_add, kw_fadd, kw_sub, kw_fsub, kw_mul, kw_fmul, kw_udiv, kw_sdiv, kw_fdiv, kw_urem, kw_srem, kw_frem, kw_shl, kw_lshr, kw_ashr, - kw_and, kw_or, kw_xor, kw_icmp, kw_fcmp, kw_vicmp, kw_vfcmp, + kw_and, kw_or, kw_xor, kw_icmp, kw_fcmp, kw_phi, kw_call, kw_trunc, kw_zext, kw_sext, kw_fptrunc, kw_fpext, kw_uitofp, kw_sitofp, Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jul 7 22:04:38 2009 @@ -987,12 +987,8 @@ if (OpTy->isFloatingPoint()) V = Context.getConstantExprFCmp(Record[3], Op0, Op1); - else if (!isa(OpTy)) - V = Context.getConstantExprICmp(Record[3], Op0, Op1); - else if (OpTy->isFPOrFPVector()) - V = Context.getConstantExprVFCmp(Record[3], Op0, Op1); else - V = Context.getConstantExprVICmp(Record[3], Op0, Op1); + V = Context.getConstantExprICmp(Record[3], Op0, Op1); break; } case bitc::CST_CODE_INLINEASM: { @@ -1632,41 +1628,27 @@ break; } - case bitc::FUNC_CODE_INST_CMP: { // CMP: [opty, opval, opval, pred] - // VFCmp/VICmp - // or old form of ICmp/FCmp returning bool - unsigned OpNum = 0; - Value *LHS, *RHS; - if (getValueTypePair(Record, OpNum, NextValueNo, LHS) || - getValue(Record, OpNum, LHS->getType(), RHS) || - OpNum+1 != Record.size()) - return Error("Invalid CMP record"); - - if (LHS->getType()->isFloatingPoint()) - I = new FCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS); - else if (!isa(LHS->getType())) - I = new ICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS); - else if (LHS->getType()->isFPOrFPVector()) - I = new VFCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS); - else - I = new VICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS); - break; - } + case bitc::FUNC_CODE_INST_CMP: // CMP: [opty, opval, opval, pred] + // Old form of ICmp/FCmp returning bool + // Existed to differentiate between icmp/fcmp and vicmp/vfcmp which were + // both legal on vectors but had different behaviour. case bitc::FUNC_CODE_INST_CMP2: { // CMP2: [opty, opval, opval, pred] - // Fcmp/ICmp returning bool or vector of bool + // FCmp/ICmp returning bool or vector of bool + unsigned OpNum = 0; Value *LHS, *RHS; if (getValueTypePair(Record, OpNum, NextValueNo, LHS) || getValue(Record, OpNum, LHS->getType(), RHS) || OpNum+1 != Record.size()) - return Error("Invalid CMP2 record"); + return Error("Invalid CMP record"); if (LHS->getType()->isFPOrFPVector()) I = new FCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS); - else + else I = new ICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS); break; } + case bitc::FUNC_CODE_INST_GETRESULT: { // GETRESULT: [ty, val, n] if (Record.size() != 2) return Error("Invalid GETRESULT record"); Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Jul 7 22:04:38 2009 @@ -683,16 +683,7 @@ break; case Instruction::ICmp: case Instruction::FCmp: - case Instruction::VICmp: - case Instruction::VFCmp: - if (isa(C->getOperand(0)->getType()) - && (CE->getOpcode() == Instruction::ICmp - || CE->getOpcode() == Instruction::FCmp)) { - // compare returning vector of Int1Ty - assert(0 && "Unsupported constant!"); - } else { - Code = bitc::CST_CODE_CE_CMP; - } + Code = bitc::CST_CODE_CE_CMP; Record.push_back(VE.getTypeID(C->getOperand(0)->getType())); Record.push_back(VE.getValueID(C->getOperand(0))); Record.push_back(VE.getValueID(C->getOperand(1))); @@ -835,15 +826,8 @@ break; case Instruction::ICmp: case Instruction::FCmp: - case Instruction::VICmp: - case Instruction::VFCmp: - if (I.getOpcode() == Instruction::ICmp - || I.getOpcode() == Instruction::FCmp) { - // compare returning Int1Ty or vector of Int1Ty - Code = bitc::FUNC_CODE_INST_CMP2; - } else { - Code = bitc::FUNC_CODE_INST_CMP; - } + // compare returning Int1Ty or vector of Int1Ty + Code = bitc::FUNC_CODE_INST_CMP2; PushValueAndType(I.getOperand(0), InstID, Vals, VE); Vals.push_back(VE.getValueID(I.getOperand(1))); Vals.push_back(cast(I).getPredicate()); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Tue Jul 7 22:04:38 2009 @@ -2227,33 +2227,6 @@ setValue(&I, DAG.getSetCC(getCurDebugLoc(), DestVT, Op1, Op2, Condition)); } -void SelectionDAGLowering::visitVICmp(User &I) { - ICmpInst::Predicate predicate = ICmpInst::BAD_ICMP_PREDICATE; - if (VICmpInst *IC = dyn_cast(&I)) - predicate = IC->getPredicate(); - else if (ConstantExpr *IC = dyn_cast(&I)) - predicate = ICmpInst::Predicate(IC->getPredicate()); - SDValue Op1 = getValue(I.getOperand(0)); - SDValue Op2 = getValue(I.getOperand(1)); - ISD::CondCode Opcode = getICmpCondCode(predicate); - setValue(&I, DAG.getVSetCC(getCurDebugLoc(), Op1.getValueType(), - Op1, Op2, Opcode)); -} - -void SelectionDAGLowering::visitVFCmp(User &I) { - FCmpInst::Predicate predicate = FCmpInst::BAD_FCMP_PREDICATE; - if (VFCmpInst *FC = dyn_cast(&I)) - predicate = FC->getPredicate(); - else if (ConstantExpr *FC = dyn_cast(&I)) - predicate = FCmpInst::Predicate(FC->getPredicate()); - SDValue Op1 = getValue(I.getOperand(0)); - SDValue Op2 = getValue(I.getOperand(1)); - ISD::CondCode Condition = getFCmpCondCode(predicate); - MVT DestVT = TLI.getValueType(I.getType()); - - setValue(&I, DAG.getVSetCC(getCurDebugLoc(), DestVT, Op1, Op2, Condition)); -} - void SelectionDAGLowering::visitSelect(User &I) { SmallVector ValueVTs; ComputeValueVTs(TLI, I.getType(), ValueVTs); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h Tue Jul 7 22:04:38 2009 @@ -75,8 +75,6 @@ class UIToFPInst; class UnreachableInst; class UnwindInst; -class VICmpInst; -class VFCmpInst; class VAArgInst; class ZExtInst; @@ -489,8 +487,6 @@ void visitAShr(User &I) { visitShift(I, ISD::SRA); } void visitICmp(User &I); void visitFCmp(User &I); - void visitVICmp(User &I); - void visitVFCmp(User &I); // Visit the conversion instructions void visitTrunc(User &I); void visitZExt(User &I); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Jul 7 22:04:38 2009 @@ -2056,7 +2056,7 @@ case ISD::SETUGE: Opc = ARMISD::VCGEU; break; } - // Detect VTST (Vector Test Bits) = vicmp ne (and (op0, op1), zero). + // Detect VTST (Vector Test Bits) = icmp ne (and (op0, op1), zero). if (Opc == ARMISD::VCEQ) { SDValue AndOp; Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Jul 7 22:04:38 2009 @@ -224,7 +224,7 @@ } Expression::ExpressionOpcode ValueTable::getOpcode(CmpInst* C) { - if (isa(C) || isa(C)) { + if (isa(C)) { switch (C->getPredicate()) { default: // THIS SHOULD NEVER HAPPEN assert(0 && "Comparison with unknown predicate?"); @@ -239,25 +239,25 @@ case ICmpInst::ICMP_SLT: return Expression::ICMPSLT; case ICmpInst::ICMP_SLE: return Expression::ICMPSLE; } - } - assert((isa(C) || isa(C)) && "Unknown compare"); - switch (C->getPredicate()) { - default: // THIS SHOULD NEVER HAPPEN - assert(0 && "Comparison with unknown predicate?"); - case FCmpInst::FCMP_OEQ: return Expression::FCMPOEQ; - case FCmpInst::FCMP_OGT: return Expression::FCMPOGT; - case FCmpInst::FCMP_OGE: return Expression::FCMPOGE; - case FCmpInst::FCMP_OLT: return Expression::FCMPOLT; - case FCmpInst::FCMP_OLE: return Expression::FCMPOLE; - case FCmpInst::FCMP_ONE: return Expression::FCMPONE; - case FCmpInst::FCMP_ORD: return Expression::FCMPORD; - case FCmpInst::FCMP_UNO: return Expression::FCMPUNO; - case FCmpInst::FCMP_UEQ: return Expression::FCMPUEQ; - case FCmpInst::FCMP_UGT: return Expression::FCMPUGT; - case FCmpInst::FCMP_UGE: return Expression::FCMPUGE; - case FCmpInst::FCMP_ULT: return Expression::FCMPULT; - case FCmpInst::FCMP_ULE: return Expression::FCMPULE; - case FCmpInst::FCMP_UNE: return Expression::FCMPUNE; + } else { + switch (C->getPredicate()) { + default: // THIS SHOULD NEVER HAPPEN + assert(0 && "Comparison with unknown predicate?"); + case FCmpInst::FCMP_OEQ: return Expression::FCMPOEQ; + case FCmpInst::FCMP_OGT: return Expression::FCMPOGT; + case FCmpInst::FCMP_OGE: return Expression::FCMPOGE; + case FCmpInst::FCMP_OLT: return Expression::FCMPOLT; + case FCmpInst::FCMP_OLE: return Expression::FCMPOLE; + case FCmpInst::FCMP_ONE: return Expression::FCMPONE; + case FCmpInst::FCMP_ORD: return Expression::FCMPORD; + case FCmpInst::FCMP_UNO: return Expression::FCMPUNO; + case FCmpInst::FCMP_UEQ: return Expression::FCMPUEQ; + case FCmpInst::FCMP_UGT: return Expression::FCMPUGT; + case FCmpInst::FCMP_UGE: return Expression::FCMPUGE; + case FCmpInst::FCMP_ULT: return Expression::FCMPULT; + case FCmpInst::FCMP_ULE: return Expression::FCMPULE; + case FCmpInst::FCMP_UNE: return Expression::FCMPUNE; + } } } Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Jul 7 22:04:38 2009 @@ -1058,7 +1058,7 @@ R = dyn_cast(ConstantExpr::getICmp(pred, C1, C2)); if (R && !R->isZero()) return pred; - pred = isSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT; + pred = isSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT; R = dyn_cast(ConstantExpr::getICmp(pred, C1, C2)); if (R && !R->isZero()) return pred; @@ -1257,30 +1257,22 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, const Constant *C1, const Constant *C2) { + const Type *ResultTy; + if (const VectorType *VT = dyn_cast(C1->getType())) + ResultTy = VectorType::get(Type::Int1Ty, VT->getNumElements()); + else + ResultTy = Type::Int1Ty; + // Fold FCMP_FALSE/FCMP_TRUE unconditionally. - if (pred == FCmpInst::FCMP_FALSE) { - if (const VectorType *VT = dyn_cast(C1->getType())) - return Constant::getNullValue(VectorType::getInteger(VT)); - else - return ConstantInt::getFalse(); - } - - if (pred == FCmpInst::FCMP_TRUE) { - if (const VectorType *VT = dyn_cast(C1->getType())) - return Constant::getAllOnesValue(VectorType::getInteger(VT)); - else - return ConstantInt::getTrue(); - } - + if (pred == FCmpInst::FCMP_FALSE) + return Constant::getNullValue(ResultTy); + + if (pred == FCmpInst::FCMP_TRUE) + return Constant::getAllOnesValue(ResultTy); + // Handle some degenerate cases first - if (isa(C1) || isa(C2)) { - // vicmp/vfcmp -> [vector] undef - if (const VectorType *VTy = dyn_cast(C1->getType())) - return UndefValue::get(VectorType::getInteger(VTy)); - - // icmp/fcmp -> i1 undef - return UndefValue::get(Type::Int1Ty); - } + if (isa(C1) || isa(C2)) + return UndefValue::get(ResultTy); // No compile-time operations on this type yet. if (C1->getType() == Type::PPC_FP128Ty) @@ -1375,35 +1367,11 @@ // If we can constant fold the comparison of each element, constant fold // the whole vector comparison. SmallVector ResElts; - const Type *InEltTy = C1Elts[0]->getType(); - bool isFP = InEltTy->isFloatingPoint(); - const Type *ResEltTy = InEltTy; - if (isFP) - ResEltTy = IntegerType::get(InEltTy->getPrimitiveSizeInBits()); - for (unsigned i = 0, e = C1Elts.size(); i != e; ++i) { // Compare the elements, producing an i1 result or constant expr. - Constant *C; - if (isFP) - C = ConstantExpr::getFCmp(pred, C1Elts[i], C2Elts[i]); - else - C = ConstantExpr::getICmp(pred, C1Elts[i], C2Elts[i]); - - // If it is a bool or undef result, convert to the dest type. - if (ConstantInt *CI = dyn_cast(C)) { - if (CI->isZero()) - ResElts.push_back(Constant::getNullValue(ResEltTy)); - else - ResElts.push_back(Constant::getAllOnesValue(ResEltTy)); - } else if (isa(C)) { - ResElts.push_back(UndefValue::get(ResEltTy)); - } else { - break; - } + ResElts.push_back(ConstantExpr::getCompare(pred, C1Elts[i], C2Elts[i])); } - - if (ResElts.size() == C1Elts.size()) - return ConstantVector::get(&ResElts[0], ResElts.size()); + return ConstantVector::get(&ResElts[0], ResElts.size()); } if (C1->getType()->isFloatingPoint()) { @@ -1461,16 +1429,9 @@ } // If we evaluated the result, return it now. - if (Result != -1) { - if (const VectorType *VT = dyn_cast(C1->getType())) { - if (Result == 0) - return Constant::getNullValue(VectorType::getInteger(VT)); - else - return Constant::getAllOnesValue(VectorType::getInteger(VT)); - } + if (Result != -1) return ConstantInt::get(Type::Int1Ty, Result); - } - + } else { // Evaluate the relation between the two constants, per the predicate. int Result = -1; // -1 = unknown, 0 = known false, 1 = known true. @@ -1545,18 +1506,11 @@ } // If we evaluated the result, return it now. - if (Result != -1) { - if (const VectorType *VT = dyn_cast(C1->getType())) { - if (Result == 0) - return Constant::getNullValue(VT); - else - return Constant::getAllOnesValue(VT); - } + if (Result != -1) return ConstantInt::get(Type::Int1Ty, Result); - } if (!isa(C1) && isa(C2)) { - // If C2 is a constant expr and C1 isn't, flop them around and fold the + // If C2 is a constant expr and C1 isn't, flip them around and fold the // other way if possible. switch (pred) { case ICmpInst::ICMP_EQ: @@ -1582,7 +1536,7 @@ } } return 0; -} + } Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, Constant* const *Idxs, Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Tue Jul 7 22:04:38 2009 @@ -814,8 +814,7 @@ } bool ConstantExpr::isCompare() const { - return getOpcode() == Instruction::ICmp || getOpcode() == Instruction::FCmp || - getOpcode() == Instruction::VICmp || getOpcode() == Instruction::VFCmp; + return getOpcode() == Instruction::ICmp || getOpcode() == Instruction::FCmp; } bool ConstantExpr::hasIndices() const { @@ -904,9 +903,7 @@ } unsigned ConstantExpr::getPredicate() const { assert(getOpcode() == Instruction::FCmp || - getOpcode() == Instruction::ICmp || - getOpcode() == Instruction::VFCmp || - getOpcode() == Instruction::VICmp); + getOpcode() == Instruction::ICmp); return ((const CompareConstantExpr*)this)->predicate; } Constant *ConstantExpr::getShl(Constant *C1, Constant *C2) { @@ -1022,8 +1019,6 @@ return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], NumOps-1); case Instruction::ICmp: case Instruction::FCmp: - case Instruction::VICmp: - case Instruction::VFCmp: return ConstantExpr::getCompare(getPredicate(), Ops[0], Ops[1]); default: assert(getNumOperands() == 2 && "Must be binary operator?"); @@ -1944,12 +1939,6 @@ if (V.opcode == Instruction::FCmp) return new CompareConstantExpr(Ty, Instruction::FCmp, V.predicate, V.operands[0], V.operands[1]); - if (V.opcode == Instruction::VICmp) - return new CompareConstantExpr(Ty, Instruction::VICmp, V.predicate, - V.operands[0], V.operands[1]); - if (V.opcode == Instruction::VFCmp) - return new CompareConstantExpr(Ty, Instruction::VFCmp, V.predicate, - V.operands[0], V.operands[1]); assert(0 && "Invalid ConstantExpr!"); return 0; } @@ -2297,7 +2286,6 @@ Constant *ConstantExpr::getCompareTy(unsigned short predicate, Constant *C1, Constant *C2) { - bool isVectorType = C1->getType()->getTypeID() == Type::VectorTyID; switch (predicate) { default: assert(0 && "Invalid CmpInst predicate"); case CmpInst::FCMP_FALSE: case CmpInst::FCMP_OEQ: case CmpInst::FCMP_OGT: @@ -2306,14 +2294,13 @@ case CmpInst::FCMP_UEQ: case CmpInst::FCMP_UGT: case CmpInst::FCMP_UGE: case CmpInst::FCMP_ULT: case CmpInst::FCMP_ULE: case CmpInst::FCMP_UNE: case CmpInst::FCMP_TRUE: - return isVectorType ? getVFCmp(predicate, C1, C2) - : getFCmp(predicate, C1, C2); + return getFCmp(predicate, C1, C2); + case CmpInst::ICMP_EQ: case CmpInst::ICMP_NE: case CmpInst::ICMP_UGT: case CmpInst::ICMP_UGE: case CmpInst::ICMP_ULT: case CmpInst::ICMP_ULE: case CmpInst::ICMP_SGT: case CmpInst::ICMP_SGE: case CmpInst::ICMP_SLT: case CmpInst::ICMP_SLE: - return isVectorType ? getVICmp(predicate, C1, C2) - : getICmp(predicate, C1, C2); + return getICmp(predicate, C1, C2); } } @@ -2488,102 +2475,6 @@ return ExprConstants->getOrCreate(Type::Int1Ty, Key); } -Constant * -ConstantExpr::getVICmp(unsigned short pred, Constant* LHS, Constant* RHS) { - assert(isa(LHS->getType()) && LHS->getType() == RHS->getType() && - "Tried to create vicmp operation on non-vector type!"); - assert(pred >= ICmpInst::FIRST_ICMP_PREDICATE && - pred <= ICmpInst::LAST_ICMP_PREDICATE && "Invalid VICmp Predicate"); - - const VectorType *VTy = cast(LHS->getType()); - const Type *EltTy = VTy->getElementType(); - unsigned NumElts = VTy->getNumElements(); - - // See if we can fold the element-wise comparison of the LHS and RHS. - SmallVector LHSElts, RHSElts; - LHS->getVectorElements(LHSElts); - RHS->getVectorElements(RHSElts); - - if (!LHSElts.empty() && !RHSElts.empty()) { - SmallVector Elts; - for (unsigned i = 0; i != NumElts; ++i) { - Constant *FC = ConstantFoldCompareInstruction(pred, LHSElts[i], - RHSElts[i]); - if (ConstantInt *FCI = dyn_cast_or_null(FC)) { - if (FCI->getZExtValue()) - Elts.push_back(ConstantInt::getAllOnesValue(EltTy)); - else - Elts.push_back(ConstantInt::get(EltTy, 0ULL)); - } else if (FC && isa(FC)) { - Elts.push_back(UndefValue::get(EltTy)); - } else { - break; - } - } - if (Elts.size() == NumElts) - return ConstantVector::get(&Elts[0], Elts.size()); - } - - // Look up the constant in the table first to ensure uniqueness - std::vector ArgVec; - ArgVec.push_back(LHS); - ArgVec.push_back(RHS); - // Get the key type with both the opcode and predicate - const ExprMapKeyType Key(Instruction::VICmp, ArgVec, pred); - - // Implicitly locked. - return ExprConstants->getOrCreate(LHS->getType(), Key); -} - -Constant * -ConstantExpr::getVFCmp(unsigned short pred, Constant* LHS, Constant* RHS) { - assert(isa(LHS->getType()) && - "Tried to create vfcmp operation on non-vector type!"); - assert(LHS->getType() == RHS->getType()); - assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && "Invalid VFCmp Predicate"); - - const VectorType *VTy = cast(LHS->getType()); - unsigned NumElts = VTy->getNumElements(); - const Type *EltTy = VTy->getElementType(); - const Type *REltTy = IntegerType::get(EltTy->getPrimitiveSizeInBits()); - const Type *ResultTy = VectorType::get(REltTy, NumElts); - - // See if we can fold the element-wise comparison of the LHS and RHS. - SmallVector LHSElts, RHSElts; - LHS->getVectorElements(LHSElts); - RHS->getVectorElements(RHSElts); - - if (!LHSElts.empty() && !RHSElts.empty()) { - SmallVector Elts; - for (unsigned i = 0; i != NumElts; ++i) { - Constant *FC = ConstantFoldCompareInstruction(pred, LHSElts[i], - RHSElts[i]); - if (ConstantInt *FCI = dyn_cast_or_null(FC)) { - if (FCI->getZExtValue()) - Elts.push_back(ConstantInt::getAllOnesValue(REltTy)); - else - Elts.push_back(ConstantInt::get(REltTy, 0ULL)); - } else if (FC && isa(FC)) { - Elts.push_back(UndefValue::get(REltTy)); - } else { - break; - } - } - if (Elts.size() == NumElts) - return ConstantVector::get(&Elts[0], Elts.size()); - } - - // Look up the constant in the table first to ensure uniqueness - std::vector ArgVec; - ArgVec.push_back(LHS); - ArgVec.push_back(RHS); - // Get the key type with both the opcode and predicate - const ExprMapKeyType Key(Instruction::VFCmp, ArgVec, pred); - - // Implicitly locked. - return ExprConstants->getOrCreate(ResultTy, Key); -} - Constant *ConstantExpr::getExtractElementTy(const Type *ReqTy, Constant *Val, Constant *Idx) { if (Constant *FC = ConstantFoldExtractElementInstruction(Val, Idx)) @@ -2992,13 +2883,9 @@ if (C2 == From) C2 = To; if (getOpcode() == Instruction::ICmp) Replacement = ConstantExpr::getICmp(getPredicate(), C1, C2); - else if (getOpcode() == Instruction::FCmp) - Replacement = ConstantExpr::getFCmp(getPredicate(), C1, C2); - else if (getOpcode() == Instruction::VICmp) - Replacement = ConstantExpr::getVICmp(getPredicate(), C1, C2); else { - assert(getOpcode() == Instruction::VFCmp); - Replacement = ConstantExpr::getVFCmp(getPredicate(), C1, C2); + assert(getOpcode() == Instruction::FCmp); + Replacement = ConstantExpr::getFCmp(getPredicate(), C1, C2); } } else if (getNumOperands() == 2) { Constant *C1 = getOperand(0); Modified: llvm/trunk/lib/VMCore/Instruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instruction.cpp (original) +++ llvm/trunk/lib/VMCore/Instruction.cpp Tue Jul 7 22:04:38 2009 @@ -143,8 +143,6 @@ // Other instructions... case ICmp: return "icmp"; case FCmp: return "fcmp"; - case VICmp: return "vicmp"; - case VFCmp: return "vfcmp"; case PHI: return "phi"; case Select: return "select"; case Call: return "call"; Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Jul 7 22:04:38 2009 @@ -2583,16 +2583,8 @@ return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, InsertBefore); } - if (Op == Instruction::FCmp) { - return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertBefore); - } - if (Op == Instruction::VICmp) { - return new VICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertBefore); - } - return new VFCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertBefore); + return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, + InsertBefore); } CmpInst * @@ -2602,16 +2594,8 @@ return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, InsertAtEnd); } - if (Op == Instruction::FCmp) { - return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertAtEnd); - } - if (Op == Instruction::VICmp) { - return new VICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertAtEnd); - } - return new VFCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertAtEnd); + return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, + InsertAtEnd); } void CmpInst::swapOperands() { @@ -2951,13 +2935,6 @@ return new ICmpInst(getPredicate(), Op<0>(), Op<1>()); } -VFCmpInst* VFCmpInst::clone() const { - return new VFCmpInst(getPredicate(), Op<0>(), Op<1>()); -} -VICmpInst* VICmpInst::clone() const { - return new VICmpInst(getPredicate(), Op<0>(), Op<1>()); -} - ExtractValueInst *ExtractValueInst::clone() const { return new ExtractValueInst(*this); } Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContext.cpp (original) +++ llvm/trunk/lib/VMCore/LLVMContext.cpp Tue Jul 7 22:04:38 2009 @@ -312,16 +312,6 @@ return ConstantExpr::getFCmp(pred, LHS, RHS); } -Constant* LLVMContext::getConstantExprVICmp(unsigned short pred, Constant* LHS, - Constant* RHS) { - return ConstantExpr::getVICmp(pred, LHS, RHS); -} - -Constant* LLVMContext::getConstantExprVFCmp(unsigned short pred, Constant* LHS, - Constant* RHS) { - return ConstantExpr::getVFCmp(pred, LHS, RHS); -} - Constant* LLVMContext::getConstantExprShl(Constant* C1, Constant* C2) { return ConstantExpr::getShl(C1, C2); } Modified: llvm/trunk/test/Assembler/vector-cmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/vector-cmp.ll?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/test/Assembler/vector-cmp.ll (original) +++ llvm/trunk/test/Assembler/vector-cmp.ll Tue Jul 7 22:04:38 2009 @@ -1,16 +1,16 @@ -; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep {global.*vicmp slt} +; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep {global.*icmp slt} ; PR2317 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i686-apple-darwin9.2.2" -define <4 x i32> @foo(<4 x float> %a, <4 x float> %b) nounwind { +define <4 x i1> @foo(<4 x float> %a, <4 x float> %b) nounwind { entry: - %cmp = vfcmp olt <4 x float> %a, %b ; <4 x i32> [#uses=1] - ret <4 x i32> %cmp + %cmp = fcmp olt <4 x float> %a, %b ; <4 x i32> [#uses=1] + ret <4 x i1> %cmp } -global <4 x i32> vicmp slt ( <4 x i32> , <4 x i32> ) ; +global <4 x i1> icmp slt ( <4 x i32> , <4 x i32> ) ; @B = external global i32; -global <4 x i32> vicmp slt ( <4 x i32> , <4 x i32> ) ; +global <4 x i1> icmp slt ( <4 x i32> , <4 x i32> ) ; Modified: llvm/trunk/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll (original) +++ llvm/trunk/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll Tue Jul 7 22:04:38 2009 @@ -1,28 +1,28 @@ ; RUN: llvm-as < %s | opt -constprop -disable-output ; PR2529 -define <4 x i32> @test1(i32 %argc, i8** %argv) { +define <4 x i1> @test1(i32 %argc, i8** %argv) { entry: - %foo = vicmp slt <4 x i32> undef, - ret <4 x i32> %foo + %foo = icmp slt <4 x i32> undef, + ret <4 x i1> %foo } -define <4 x i32> @test2(i32 %argc, i8** %argv) { +define <4 x i1> @test2(i32 %argc, i8** %argv) { entry: - %foo = vicmp slt <4 x i32> , - ret <4 x i32> %foo + ret <4 x i1> %foo } -define <4 x i32> @test3() { - %foo = vfcmp ueq <4 x float> @test3() { + %foo = fcmp ueq <4 x float> , - ret <4 x i32> %foo + ret <4 x i1> %foo } -define <4 x i32> @test4() { - %foo = vfcmp ueq <4 x float> , +define <4 x i1> @test4() { + %foo = fcmp ueq <4 x float> , - ret <4 x i32> %foo + ret <4 x i1> %foo } Modified: llvm/trunk/utils/llvm.grm URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvm.grm?rev=74991&r1=74990&r2=74991&view=diff ============================================================================== --- llvm/trunk/utils/llvm.grm (original) +++ llvm/trunk/utils/llvm.grm Tue Jul 7 22:04:38 2009 @@ -238,8 +238,6 @@ | LogicalOps "(" ^ ConstVal ^ "," ConstVal ^ ")" | icmp IPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" | fcmp FPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" - | vicmp IPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" - | vfcmp FPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" | extractelement "(" ^ ConstVal ^ "," ConstVal ^ ")" | insertelement "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")" | shufflevector "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")" @@ -382,8 +380,6 @@ | LogicalOps Types ValueRef ^ "," ValueRef | icmp IPredicates Types ValueRef ^ "," ValueRef | fcmp FPredicates Types ValueRef ^ "," ValueRef - | vicmp IPredicates Types ValueRef ^ "," ValueRef - | vfcmp FPredicates Types ValueRef ^ "," ValueRef | CastOps ResolvedVal to Types | select ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal | "va_arg" ResolvedVal ^ "," Types From eli.friedman at gmail.com Tue Jul 7 23:09:24 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 7 Jul 2009 21:09:24 -0700 Subject: [llvm-commits] [llvm] r74964 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/vec_compare.ll In-Reply-To: References: <200907072303.n67N3tpM003424@zion.cs.uiuc.edu> Message-ID: On Tue, Jul 7, 2009 at 7:38 PM, Eli Friedman wrote: > On Tue, Jul 7, 2009 at 7:16 PM, Eli Friedman wrote: >> On Tue, Jul 7, 2009 at 6:29 PM, Dan Gohman wrote: >>> EXTRACT_SUBVECTOR is normally used to extract a legal value from >>> an illegal one. The code above does the opposite, extracting a >>> potentially illegal value from a legal one. >> >> As far as I can tell, we support both cases properly in type >> legalization; what specific case breaks? > > Mmm, nevermind, you're talking about something like the following? > > define void @test2(<2 x i32> %A, <2 x i32> %B, <2 x i32>* %C) nounwind { > ? ? ? %D = icmp sgt <2 x i32> %A, %B > ? ? ? %E = zext <2 x i1> %D to <2 x i32> > ? ? ? store <2 x i32> %E, <2 x i32>* %C > ? ? ? ret void > } > > It's really just falling apart because we don't support various > related cases correctly; first, it hits the "Unimp" assert in this > patch, ?and if you just comment it out (which seems like the right > thing to do), we hit an assertion because we don't support extracting > an i1 from a <2 x i1> in PromoteIntRes_EXTRACT_VECTOR_ELT . ?Still > nothing going wrong with EXTRACT_SUBVECTOR. Attached partially deals with the issues (enough to get the given testcase to compile); it might not be the best approach, though, because changing the definition of EXTRACT_VECTOR_ELT has side-effects all over the place. -Eli -------------- next part -------------- A non-text attachment was scrubbed... Name: x.bc Type: application/octet-stream Size: 280 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090707/92f13bc5/attachment.obj From eli.friedman at gmail.com Tue Jul 7 23:10:07 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 7 Jul 2009 21:10:07 -0700 Subject: [llvm-commits] [llvm] r74964 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/vec_compare.ll In-Reply-To: References: <200907072303.n67N3tpM003424@zion.cs.uiuc.edu> Message-ID: On Tue, Jul 7, 2009 at 9:09 PM, Eli Friedman wrote: > On Tue, Jul 7, 2009 at 7:38 PM, Eli Friedman wrote: >> On Tue, Jul 7, 2009 at 7:16 PM, Eli Friedman wrote: >>> On Tue, Jul 7, 2009 at 6:29 PM, Dan Gohman wrote: >>>> EXTRACT_SUBVECTOR is normally used to extract a legal value from >>>> an illegal one. The code above does the opposite, extracting a >>>> potentially illegal value from a legal one. >>> >>> As far as I can tell, we support both cases properly in type >>> legalization; what specific case breaks? >> >> Mmm, nevermind, you're talking about something like the following? >> >> define void @test2(<2 x i32> %A, <2 x i32> %B, <2 x i32>* %C) nounwind { >> ? ? ? %D = icmp sgt <2 x i32> %A, %B >> ? ? ? %E = zext <2 x i1> %D to <2 x i32> >> ? ? ? store <2 x i32> %E, <2 x i32>* %C >> ? ? ? ret void >> } >> >> It's really just falling apart because we don't support various >> related cases correctly; first, it hits the "Unimp" assert in this >> patch, ?and if you just comment it out (which seems like the right >> thing to do), we hit an assertion because we don't support extracting >> an i1 from a <2 x i1> in PromoteIntRes_EXTRACT_VECTOR_ELT . ?Still >> nothing going wrong with EXTRACT_SUBVECTOR. > > Attached partially deals with the issues (enough to get the given > testcase to compile); it might not be the best approach, though, > because changing the definition of EXTRACT_VECTOR_ELT has side-effects > all over the place. Bleh, accidentally attached the wrong thing. -Eli -------------- next part -------------- Index: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (revision 74987) +++ lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (working copy) @@ -303,52 +303,10 @@ } SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(SDNode *N) { - MVT OldVT = N->getValueType(0); - SDValue OldVec = N->getOperand(0); - if (getTypeAction(OldVec.getValueType()) == WidenVector) - OldVec = GetWidenedVector(N->getOperand(0)); - unsigned OldElts = OldVec.getValueType().getVectorNumElements(); DebugLoc dl = N->getDebugLoc(); - - if (OldElts == 1) { - assert(!isTypeLegal(OldVec.getValueType()) && - "Legal one-element vector of a type needing promotion!"); - // It is tempting to follow GetScalarizedVector by a call to - // GetPromotedInteger, but this would be wrong because the - // scalarized value may not yet have been processed. - return DAG.getNode(ISD::ANY_EXTEND, dl, TLI.getTypeToTransformTo(OldVT), - GetScalarizedVector(OldVec)); - } - - // Convert to a vector half as long with an element type of twice the width, - // for example <4 x i16> -> <2 x i32>. - assert(!(OldElts & 1) && "Odd length vectors not supported!"); - MVT NewVT = MVT::getIntegerVT(2 * OldVT.getSizeInBits()); - assert(OldVT.isSimple() && NewVT.isSimple()); - - SDValue NewVec = DAG.getNode(ISD::BIT_CONVERT, dl, - MVT::getVectorVT(NewVT, OldElts / 2), - OldVec); - - // Extract the element at OldIdx / 2 from the new vector. - SDValue OldIdx = N->getOperand(1); - SDValue NewIdx = DAG.getNode(ISD::SRL, dl, OldIdx.getValueType(), OldIdx, - DAG.getConstant(1, TLI.getPointerTy())); - SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, NewVT, NewVec, NewIdx); - - // Select the appropriate half of the element: Lo if OldIdx was even, - // Hi if it was odd. - SDValue Lo = Elt; - SDValue Hi = DAG.getNode(ISD::SRL, dl, NewVT, Elt, - DAG.getConstant(OldVT.getSizeInBits(), - TLI.getPointerTy())); - if (TLI.isBigEndian()) - std::swap(Lo, Hi); - - // Extend to the promoted type. - SDValue Odd = DAG.getNode(ISD::TRUNCATE, dl, MVT::i1, OldIdx); - SDValue Res = DAG.getNode(ISD::SELECT, dl, NewVT, Odd, Hi, Lo); - return DAG.getNode(ISD::ANY_EXTEND, dl, TLI.getTypeToTransformTo(OldVT), Res); + MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); + return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, NVT, N->getOperand(0), + N->getOperand(1)); } SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT(SDNode *N) { Index: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (revision 74987) +++ lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (working copy) @@ -330,7 +330,11 @@ /// be scalarized, it must be <1 x ty>, so just return the element, ignoring the /// index. SDValue DAGTypeLegalizer::ScalarizeVecOp_EXTRACT_VECTOR_ELT(SDNode *N) { - return GetScalarizedVector(N->getOperand(0)); + SDValue Res = GetScalarizedVector(N->getOperand(0)); + if (Res.getValueType() != N->getValueType(0)) + Res = DAG.getNode(ISD::ANY_EXTEND, N->getDebugLoc(), N->getValueType(0), + Res); + return Res; } /// ScalarizeVecOp_STORE - If the value to store is a vector that needs to be @@ -899,7 +903,7 @@ SDValue LL, LH, RL, RH; switch (getTypeAction(InVT)) { default: assert(0 && "Unexpected type action!"); - case WidenVector: assert(0 && "Unimp"); + case WidenVector: case Legal: { assert(LoVT == HiVT && "Legal non-power-of-two vector type?"); MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(), @@ -1073,7 +1077,8 @@ // Load back the required element. StackPtr = GetVectorElementPointer(StackPtr, EltVT, Idx); - return DAG.getLoad(EltVT, dl, Store, StackPtr, SV, 0); + return DAG.getExtLoad(ISD::EXTLOAD, dl, N->getValueType(0), Store, StackPtr, + SV, 0, EltVT); } SDValue DAGTypeLegalizer::SplitVecOp_STORE(StoreSDNode *N, unsigned OpNo) { @@ -1925,9 +1930,8 @@ SDValue DAGTypeLegalizer::WidenVecOp_EXTRACT_VECTOR_ELT(SDNode *N) { SDValue InOp = GetWidenedVector(N->getOperand(0)); - MVT EltVT = InOp.getValueType().getVectorElementType(); return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, N->getDebugLoc(), - EltVT, InOp, N->getOperand(1)); + N->getValueType(0), InOp, N->getOperand(1)); } SDValue DAGTypeLegalizer::WidenVecOp_STORE(SDNode *N) { Index: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (revision 74987) +++ lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (working copy) @@ -1522,7 +1522,11 @@ StackPtr = DAG.getNode(ISD::ADD, dl, Idx.getValueType(), Idx, StackPtr); - return DAG.getLoad(Op.getValueType(), dl, Ch, StackPtr, NULL, 0); + if (Op.getValueType().isVector()) + return DAG.getLoad(Op.getValueType(), dl, Ch, StackPtr, NULL, 0); + else + return DAG.getExtLoad(ISD::EXTLOAD, dl, Op.getValueType(), Ch, StackPtr, + NULL, 0, Vec.getValueType().getVectorElementType()); } SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) { Index: include/llvm/CodeGen/SelectionDAGNodes.h =================================================================== --- include/llvm/CodeGen/SelectionDAGNodes.h (revision 74987) +++ include/llvm/CodeGen/SelectionDAGNodes.h (working copy) @@ -303,7 +303,9 @@ INSERT_VECTOR_ELT, /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR - /// identified by the (potentially variable) element number IDX. + /// identified by the (potentially variable) element number IDX. If the + /// return type is an integer type larger than the element type of the + /// vector, the result is extended to the width of the return type. EXTRACT_VECTOR_ELT, /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of Index: test/CodeGen/X86/2009-07-07-UnrollICmp.ll =================================================================== --- test/CodeGen/X86/2009-07-07-UnrollICmp.ll (revision 0) +++ test/CodeGen/X86/2009-07-07-UnrollICmp.ll (revision 0) @@ -0,0 +1,8 @@ +; RUN: llvm-as < %s | llc -march=x86 -disable-mmx + +define void @test2(<2 x i32> %A, <2 x i32> %B, <2 x i32>* %C) nounwind { + %D = icmp sgt <2 x i32> %A, %B + %E = zext <2 x i1> %D to <2 x i32> + store <2 x i32> %E, <2 x i32>* %C + ret void +} From sanjiv.gupta at microchip.com Wed Jul 8 00:40:06 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Wed, 08 Jul 2009 05:40:06 -0000 Subject: [llvm-commits] [llvm] r74992 - /llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.td Message-ID: <200907080540.n685e6DK015469@zion.cs.uiuc.edu> Author: sgupta Date: Wed Jul 8 00:40:05 2009 New Revision: 74992 URL: http://llvm.org/viewvc/llvm-project?rev=74992&view=rev Log: Mark sublw_cc and subfw_cc as Terminator insns so that they are part of the terminator insns for a basic block alongwith branch insns. This way a copy is not getting inserted between cmp and branch during PHIElimination disturbing the status flags. Modified: llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.td Modified: llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.td?rev=74992&r1=74991&r2=74992&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.td (original) +++ llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.td Wed Jul 8 00:40:05 2009 @@ -375,8 +375,9 @@ let Uses = [STATUS] in def subfwb: SUBFW<0, "subwfb", sube>; // With Borrow. -def subfw_cc: SUBFW<0, "subwf", PIC16Subcc>; } +let Defs = [STATUS], isTerminator = 1 in +def subfw_cc: SUBFW<0, "subwf", PIC16Subcc>; // [F] -= W ; let mayStore = 1 in @@ -425,8 +426,9 @@ let Defs = [STATUS] in { def sublw_1 : SUBLW<0, sub>; def sublw_2 : SUBLW<0, subc>; -def sublw_cc : SUBLW<0, PIC16Subcc>; } +let Defs = [STATUS], isTerminator = 1 in +def sublw_cc : SUBLW<0, PIC16Subcc>; // Call instruction. let isCall = 1, From evan.cheng at apple.com Wed Jul 8 00:47:39 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 7 Jul 2009 22:47:39 -0700 Subject: [llvm-commits] [llvm] r74964 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/vec_compare.ll In-Reply-To: References: <200907072303.n67N3tpM003424@zion.cs.uiuc.edu> Message-ID: On Jul 7, 2009, at 7:16 PM, Eli Friedman wrote: > On Tue, Jul 7, 2009 at 6:29 PM, Dan Gohman wrote: >> EXTRACT_SUBVECTOR is normally used to extract a legal value from >> an illegal one. The code above does the opposite, extracting a >> potentially illegal value from a legal one. > > As far as I can tell, we support both cases properly in type > legalization; what specific case breaks? There shouldn't be any restriction, right? Why can we use it to extract legal value from legal or any other combinations? Evan > > -Eli > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From Sanjiv.Gupta at microchip.com Wed Jul 8 00:49:18 2009 From: Sanjiv.Gupta at microchip.com (Sanjiv.Gupta at microchip.com) Date: Tue, 7 Jul 2009 22:49:18 -0700 Subject: [llvm-commits] [llvm] r74898 -/llvm/trunk/lib/CodeGen/PHIElimination.cpp In-Reply-To: References: <200907070804.n6784sHX030896@zion.cs.uiuc.edu> Message-ID: We fixed this issue in our port by marking the cmp insn as isTerminator = 1. This way cmp and branch are both part of the terminator group and PHIElimination does not insert a copy in between. So we don't need this patch anymore. - Sanjiv > -----Original Message----- > From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits- > bounces at cs.uiuc.edu] On Behalf Of Evan Cheng > Sent: Tuesday, July 07, 2009 11:20 PM > To: Commit Messages and Patches for LLVM > Subject: Re: [llvm-commits] [llvm] r74898 - > /llvm/trunk/lib/CodeGen/PHIElimination.cpp > > This patch broke a whole bunch of tests. For example on Grawp-PIC: > > New Test Failures: > test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll [DEJAGNU] > test/CodeGen/X86/2006-05-02-InstrSched2.ll [DEJAGNU] > test/CodeGen/X86/2008-05-21-CoalescerBug.ll for PR2343 [DEJAGNU] > test/CodeGen/X86/stack-color-with-reg-2.ll [DEJAGNU] > test/CodeGen/X86/twoaddr-pass-sink.ll [DEJAGNU] > Applications/oggenc/oggenc [LLC compile, ] > Benchmarks/ASCI_Purple/SMG2000/smg2000 [LLC compile, ] > Benchmarks/mafft/pairlocalalign [LLC compile, ] > Benchmarks/MallocBench/gs/gs [LLC compile, ] > Benchmarks/mediabench/mpeg2/mpeg2dec/mpeg2decode [LLC compile, ] > Benchmarks/MiBench/consumer-jpeg/consumer-jpeg [LLC compile, ] > Benchmarks/MiBench/consumer-lame/consumer-lame [LLC compile, ] > Benchmarks/Misc/whetstone [LLC compile, ] > Benchmarks/Ptrdist/yacr2/yacr2 [LLC compile, ] > Nurbs/nurbs [LLC compile, ] > SPEC/CFP2006/433.milc/433.milc [LLC compile, ] > SPEC/CINT2000/176.gcc/176.gcc [LLC compile, ] > SPEC/CINT2000/254.gap/254.gap [LLC compile, ] > SPEC/CINT2006/403.gcc/403.gcc [LLC compile, ] > > > I'll back it out for now. Sanjiv, please investigate. Thanks. > > > Evan > > > On Jul 7, 2009, at 1:04 AM, Sanjiv Gupta wrote: > > > Author: sgupta > Date: Tue Jul 7 03:04:51 2009 > New Revision: 74898 > > URL: http://llvm.org/viewvc/llvm-project?rev=74898&view=rev > Log: > if the terminator is a branch depending upon the side effects of a > previous cmp; a copy can not be inserted here if the copy insn also > has > side effects. We don't have access to the attributes of copy insn > here; > so just play safe by finding a safe locations for branch > terminators. > > Modified: > llvm/trunk/lib/CodeGen/PHIElimination.cpp > > Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp > URL: http://llvm.org/viewvc/llvm- > project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=74898&r1=74897&r2= 74 > 898&view=diff > > ==================================================================== > ========== > --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) > +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Tue Jul 7 03:04:51 > 2009 > @@ -169,9 +169,15 @@ > return MBB.begin(); > > // If this basic block does not contain an invoke, then control > flow always > - // reaches the end of it, so place the copy there. The logic > below works in > - // this case too, but is more expensive. > - if (!isa(MBB.getBasicBlock()->getTerminator())) > + // reaches the end of it, so place the copy there. > + // If the terminator is a branch depending upon the side effects > of a > + // previous cmp; a copy can not be inserted here if the copy insn > also > + // side effects. We don't have access to the attributes of copy > insn here; > + // so just play safe by finding a safe locations for branch > terminators. > + // > + // The logic below works in this case too, but is more expensive. > + const TerminatorInst *TermInst = MBB.getBasicBlock()- > >getTerminator(); > + if (!(isa(TermInst) || isa(TermInst))) > return MBB.getFirstTerminator(); > > // Discover any definition/uses in this basic block. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From evan.cheng at apple.com Wed Jul 8 00:52:44 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 7 Jul 2009 22:52:44 -0700 Subject: [llvm-commits] [llvm] r74955 - /llvm/trunk/include/llvm/Support/StandardPasses.h In-Reply-To: <200907072209.n67M9htk001469@zion.cs.uiuc.edu> References: <200907072209.n67M9htk001469@zion.cs.uiuc.edu> Message-ID: Hi Devang, What prompted this experiment? Evan On Jul 7, 2009, at 3:09 PM, Devang Patel wrote: > Author: dpatel > Date: Tue Jul 7 17:09:42 2009 > New Revision: 74955 > > URL: http://llvm.org/viewvc/llvm-project?rev=74955&view=rev > Log: > Disable loop index split for now and let nightly tester verify its > usefulness. > > Modified: > llvm/trunk/include/llvm/Support/StandardPasses.h > > Modified: llvm/trunk/include/llvm/Support/StandardPasses.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=74955&r1=74954&r2=74955&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) > +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue Jul 7 > 17:09:42 2009 > @@ -129,7 +129,6 @@ > PM->add(createLoopRotatePass()); // Rotate Loop > PM->add(createLICMPass()); // Hoist loop > invariants > PM->add(createLoopUnswitchPass(OptimizeSize)); > - PM->add(createLoopIndexSplitPass()); // Split loop index > PM->add(createInstructionCombiningPass()); > PM->add(createIndVarSimplifyPass()); // Canonicalize > indvars > PM->add(createLoopDeletionPass()); // Delete dead loops > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Wed Jul 8 00:58:24 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 7 Jul 2009 22:58:24 -0700 Subject: [llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction In-Reply-To: <1DDE1F32B1CA4138A16F4434BF65EB36@HPLAPTOP> References: <9719867c0907061057w1c3fc45em92b05528c88aa684@mail.gmail.com> <07E0D0CF-5038-4B7C-AB6F-DA5A5206A4E2@apple.com> <275e64e40907061253y1729940atc4818e9fa244ac5e@mail.gmail.com> <0772BCC55D8C48209386001E95355240@HPLAPTOP> <2754CA63-0EF0-41B7-8217-F464354C6A87@apple.com> <1DDE1F32B1CA4138A16F4434BF65EB36@HPLAPTOP> Message-ID: <2F0BE48A-C692-4633-BA8F-990012D9FF87@apple.com> On Jul 6, 2009, at 3:07 PM, Aaron Gray wrote: >> On Jul 6, 2009, at 2:56 PM, Aaron Gray wrote: >> >>>> We need to revisit the approach. Templatizing the CodeEmitter >>>> class is probably not the right way to go Sorry I didn't think >>>> hard about this when the patch landed back the end of May. >>>> Chris' recent "machine code" work is obsoleting at least object >>>> code emitter so I'll let him comment. >>> >>> I have put alot of work into getting this far. My designs are >>> really dependant upon this approach and it yeilds the fastest code >>> emission at base level. All my subsequet code is really based on >>> this approach. Chris know about the DOE development, and the >>> designs have been on the Wiki for some time. >>> >>> Templating and using inline methods allow the fastest approach to >>> the actual code emission. Its nice clean and efficient code, that >>> allows bespoke usage of the code generator backend, for the JIT >>> and Object Module emission. >> >> Hi Aaron, what part of your design talks about this? What problem >> is templating this all solving? > > Templating allows us to have mutiple types of MachineCodeEmitters, > the JITCodeEmitter, and the ObjectCodeEmitter, and any other kind of > CodeEmitter we require in the future, e.g. Reid Kleckner' > requirements to combine JIT and GDB. It allows these emiiters to be > efficient and be inlined functions. If you study the code you will > see what I mean. What's the state of the current ObjectCodeEmitter? Are we planning to de-templatize X86CodeEmitter, etc? Evan > > Aaron > From clattner at apple.com Wed Jul 8 01:06:39 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 23:06:39 -0700 Subject: [llvm-commits] [llvm] r74991 - in /llvm/trunk: docs/ include/llvm-c/ include/llvm/ include/llvm/Bitcode/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Transforms/Scalar/ lib/VMCore/ test/Assembler/ test/Transforms/ConstProp/ utils/ In-Reply-To: <200907080304.n6834jBx010818@zion.cs.uiuc.edu> References: <200907080304.n6834jBx010818@zion.cs.uiuc.edu> Message-ID: On Jul 7, 2009, at 8:04 PM, Nick Lewycky wrote: > Author: nicholas > Date: Tue Jul 7 22:04:38 2009 > New Revision: 74991 > > URL: http://llvm.org/viewvc/llvm-project?rev=74991&view=rev > Log: > Remove the vicmp and vfcmp instructions. Because we never had a > release with > these instructions, no autoupgrade or backwards compatibility > support is > provided. Nice! > +++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h Tue Jul 7 > 22:04:38 2009 > @@ -210,7 +210,8 @@ > FUNC_CODE_INST_GETRESULT = 25, // GETRESULT: [ty, opval, n] > FUNC_CODE_INST_EXTRACTVAL = 26, // EXTRACTVAL: [n x operands] > FUNC_CODE_INST_INSERTVAL = 27, // INSERTVAL: [n x operands] > - // fcmp/icmp returning Int1TY or vector of Int1Ty, NOT for > vicmp/vfcmp > + // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, > exists to > + // support legacy vicmp/vfcmp instructions. > FUNC_CODE_INST_CMP2 = 28, // CMP2: [opty, opval, > opval, pred] Can this just be removed? -Chris From clattner at apple.com Wed Jul 8 01:07:22 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 23:07:22 -0700 Subject: [llvm-commits] [llvm] r74955 - /llvm/trunk/include/llvm/Support/StandardPasses.h In-Reply-To: References: <200907072209.n67M9htk001469@zion.cs.uiuc.edu> Message-ID: <04F24F1F-7332-4C52-B0E2-A70A22F96264@apple.com> On Jul 7, 2009, at 10:52 PM, Evan Cheng wrote: > Hi Devang, > > What prompted this experiment? There are several outstanding bugzillas about miscompilations by index set splitting. I would much rather the pass be fixed than removed though. -Chris > > Evan > > On Jul 7, 2009, at 3:09 PM, Devang Patel wrote: > >> Author: dpatel >> Date: Tue Jul 7 17:09:42 2009 >> New Revision: 74955 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=74955&view=rev >> Log: >> Disable loop index split for now and let nightly tester verify its >> usefulness. >> >> Modified: >> llvm/trunk/include/llvm/Support/StandardPasses.h >> >> Modified: llvm/trunk/include/llvm/Support/StandardPasses.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=74955&r1=74954&r2=74955&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) >> +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue Jul 7 >> 17:09:42 2009 >> @@ -129,7 +129,6 @@ >> PM->add(createLoopRotatePass()); // Rotate Loop >> PM->add(createLICMPass()); // Hoist loop >> invariants >> PM->add(createLoopUnswitchPass(OptimizeSize)); >> - PM->add(createLoopIndexSplitPass()); // Split loop >> index >> PM->add(createInstructionCombiningPass()); >> PM->add(createIndVarSimplifyPass()); // Canonicalize >> indvars >> PM->add(createLoopDeletionPass()); // Delete dead loops >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Wed Jul 8 01:08:33 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Jul 2009 23:08:33 -0700 Subject: [llvm-commits] [cfe-commits] r74986 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CGCXX.cpp CGDecl.cpp CGExprConstant.cpp CGObjCGNU.cpp CGObjCMac.cpp CodeGenModule.cpp In-Reply-To: <200907080129.n681TJ6Y008080@zion.cs.uiuc.edu> References: <200907080129.n681TJ6Y008080@zion.cs.uiuc.edu> Message-ID: On Jul 7, 2009, at 6:29 PM, Owen Anderson wrote: > Author: resistor > Date: Tue Jul 7 20:29:18 2009 > New Revision: 74986 > > URL: http://llvm.org/viewvc/llvm-project?rev=74986&view=rev > Log: > Update for LLVM API change. Hi Owen, Why do you need to specify a context to the globalvariable ctor when you also specify a module? -Chris From baldrick at free.fr Wed Jul 8 03:08:52 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 08 Jul 2009 10:08:52 +0200 Subject: [llvm-commits] PATCH: remove VICmp and VFCmp. In-Reply-To: <05085D11-65C9-478A-B854-1EAC52FD9E42@apple.com> References: <4A518899.80806@mxc.ca> <7ABB6DFD-7F2E-4F31-A7D9-FC86362095E6@apple.com> <05085D11-65C9-478A-B854-1EAC52FD9E42@apple.com> Message-ID: <4A545414.4080604@free.fr> Hi Dan, > %y has type <4 x i1>. This is not a legal type on most current > architectures. But, many architectures have ways of supporting > this kind of code, often by putting the comparison result in a > <4 x i32> register. > > The main twist is that a type like <4 x i1> might be legalized > to either <4 x i32> or <4 x i64> on a target like x86, depending > on the type of the comparison operands, so the current > getTypeToTransformTo, which assumes that every type has a > unique destination type, isn't sufficient. I think this is a misunderstanding of the roles of type and operation legalization. The getTypeToTransformTo method exists entirely for the benefit of type legalization. Since <4 x i1> is an illegal type, it needs to be transformed into the legal type given by getTypeToTransformTo, for example <4 x i8>. After type legalization has finished you will have vector comparison operations returning <4 x i8>. Now operation legalization kicks in. Since the target machine cannot handle vector comparisons returning <4 x i8>, operation legalization needs to turn that into a comparison returning <4 x i32> or <4 x i64>. It of course needs some way to know which type to use, but this has nothing to do with getTypeToTransformTo. Ciao, Duncan. From eli.friedman at gmail.com Wed Jul 8 03:49:35 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 8 Jul 2009 01:49:35 -0700 Subject: [llvm-commits] PATCH: remove VICmp and VFCmp. In-Reply-To: <4A545414.4080604@free.fr> References: <4A518899.80806@mxc.ca> <7ABB6DFD-7F2E-4F31-A7D9-FC86362095E6@apple.com> <05085D11-65C9-478A-B854-1EAC52FD9E42@apple.com> <4A545414.4080604@free.fr> Message-ID: On Wed, Jul 8, 2009 at 1:08 AM, Duncan Sands wrote: > Hi Dan, > >> %y has type <4 x i1>. This is not a legal type on most current >> architectures. But, many architectures have ways of supporting >> this kind of code, often by putting the comparison result in a >> <4 x i32> register. >> >> The main twist is that a type like <4 x i1> might be legalized >> to either <4 x i32> or <4 x i64> on a target like x86, depending >> on the type of the comparison operands, so the current >> getTypeToTransformTo, which assumes that every type has a >> unique destination type, isn't sufficient. > > I think this is a misunderstanding of the roles of type and > operation legalization. ?The getTypeToTransformTo method exists > entirely for the benefit of type legalization. ?Since <4 x i1> is > an illegal type, it needs to be transformed into the legal type > given by getTypeToTransformTo, for example <4 x i8>. We don't support that kind of promotion at the moment, although I suppose that's an implementation detail rather than a fundamental issue. > After type > legalization has finished you will have vector comparison operations > returning <4 x i8>. ?Now operation legalization kicks in. ?Since the > target machine cannot handle vector comparisons returning <4 x i8>, > operation legalization needs to turn that into a comparison returning > <4 x i32> or <4 x i64>. ?It of course needs some way to know which > type to use, but this has nothing to do with getTypeToTransformTo. Well, suppose a comparison of two <4 x i32> vectors. Your natural promotion for the result on x86 would be to a <4 x i16>. But yes, you could put off the subsequent adjustments to operation legalization, although if it weren't custom-lowered, it would likely end up producing something really ugly. -Eli From baldrick at free.fr Wed Jul 8 04:03:07 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 08 Jul 2009 11:03:07 +0200 Subject: [llvm-commits] PATCH: remove VICmp and VFCmp. In-Reply-To: References: <4A518899.80806@mxc.ca> <7ABB6DFD-7F2E-4F31-A7D9-FC86362095E6@apple.com> <05085D11-65C9-478A-B854-1EAC52FD9E42@apple.com> <4A545414.4080604@free.fr> Message-ID: <4A5460CB.6070802@free.fr> Hi Eli, >> I think this is a misunderstanding of the roles of type and >> operation legalization. The getTypeToTransformTo method exists >> entirely for the benefit of type legalization. Since <4 x i1> is >> an illegal type, it needs to be transformed into the legal type >> given by getTypeToTransformTo, for example <4 x i8>. > > We don't support that kind of promotion at the moment, although I > suppose that's an implementation detail rather than a fundamental > issue. exactly. The fact that this might not actually work right now is an implementation problem, not a conceptual problem. >> After type >> legalization has finished you will have vector comparison operations >> returning <4 x i8>. Now operation legalization kicks in. Since the >> target machine cannot handle vector comparisons returning <4 x i8>, >> operation legalization needs to turn that into a comparison returning >> <4 x i32> or <4 x i64>. It of course needs some way to know which >> type to use, but this has nothing to do with getTypeToTransformTo. > > Well, suppose a comparison of two <4 x i32> vectors. Your natural > promotion for the result on x86 would be to a <4 x i16>. But yes, you > could put off the subsequent adjustments to operation legalization, > although if it weren't custom-lowered, it would likely end up > producing something really ugly. Operation legalization = turning illegal operations into legal operations. This may be via custom lowering or via some kind of generic expansion, it doesn't matter. Since a comparison of two <4 x i32> vectors that returns a <4 x i16> is an illegal operation for x86, but with legal types, it is by definition the job of the operation legalization code to take care of this. Ciao, Duncan. From rafael.espindola at gmail.com Wed Jul 8 06:13:48 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 08 Jul 2009 11:13:48 -0000 Subject: [llvm-commits] [llvm] r75000 - /llvm/trunk/docs/GoldPlugin.html Message-ID: <200907081113.n68BDoJG005632@zion.cs.uiuc.edu> Author: rafael Date: Wed Jul 8 06:13:34 2009 New Revision: 75000 URL: http://llvm.org/viewvc/llvm-project?rev=75000&view=rev Log: Update the example to show that an archive can contain llvm bitcode. Modified: llvm/trunk/docs/GoldPlugin.html Modified: llvm/trunk/docs/GoldPlugin.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GoldPlugin.html?rev=75000&r1=74999&r2=75000&view=diff ============================================================================== --- llvm/trunk/docs/GoldPlugin.html (original) +++ llvm/trunk/docs/GoldPlugin.html Wed Jul 8 06:13:34 2009 @@ -127,8 +127,9 @@ --- command lines --- $ llvm-gcc -flto a.c -c -o a.o # <-- a.o is LLVM bitcode file +$ ar q a.a a.o # <-- a.a is an archive with LLVM bitcode $ llvm-gcc b.c -c -o b.o # <-- b.o is native object file -$ llvm-gcc -use-gold-plugin a.o b.o -o main # <-- link with LLVMgold plugin +$ llvm-gcc -use-gold-plugin a.a b.o -o main # <-- link with LLVMgold plugin

      Gold informs the plugin that foo3 is never referenced outside the IR, leading LLVM to delete that function. However, unlike in the From baldrick at free.fr Wed Jul 8 06:37:12 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 08 Jul 2009 11:37:12 -0000 Subject: [llvm-commits] [llvm] r75001 - in /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeFloatTypes.cpp LegalizeIntegerTypes.cpp LegalizeTypes.h LegalizeTypesGeneric.cpp LegalizeVectorTypes.cpp Message-ID: <200907081137.n68BbJYS006273@zion.cs.uiuc.edu> Author: baldrick Date: Wed Jul 8 06:36:39 2009 New Revision: 75001 URL: http://llvm.org/viewvc/llvm-project?rev=75001&view=rev Log: Remove trailing whitespace. Reorder some methods and cases alphabetically. No functionality change. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=75001&r1=75000&r2=75001&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Wed Jul 8 06:36:39 2009 @@ -491,7 +491,7 @@ SDValue NewVAARG; NewVAARG = DAG.getVAArg(NVT, dl, Chain, Ptr, N->getOperand(2)); - + // Legalized the chain result - switch anything that used the old chain to // use the new one. ReplaceValueWith(SDValue(N, 1), NewVAARG.getValue(1)); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=75001&r1=75000&r2=75001&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Wed Jul 8 06:36:39 2009 @@ -359,7 +359,7 @@ // If we're promoting a UINT to a larger size and the larger FP_TO_UINT is // not Legal, check to see if we can use FP_TO_SINT instead. (If both UINT // and SINT conversions are Custom, there is no way to tell which is preferable. - // We choose SINT because that's the right thing on PPC.) + // We choose SINT because that's the right thing on PPC.) if (N->getOpcode() == ISD::FP_TO_UINT && !TLI.isOperationLegal(ISD::FP_TO_UINT, NVT) && TLI.isOperationLegalOrCustom(ISD::FP_TO_SINT, NVT)) @@ -1838,7 +1838,7 @@ else if (VT == MVT::i128) LC = RTLIB::SRA_I128; } - + if (LC != RTLIB::UNKNOWN_LIBCALL && TLI.getLibcallName(LC)) { SDValue Ops[2] = { N->getOperand(0), N->getOperand(1) }; SplitInteger(MakeLibCall(LC, VT, Ops, 2, isSigned, dl), Lo, Hi); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=75001&r1=75000&r2=75001&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Wed Jul 8 06:36:39 2009 @@ -517,10 +517,10 @@ SDValue ScalarizeVecRes_SCALAR_TO_VECTOR(SDNode *N); SDValue ScalarizeVecRes_SELECT(SDNode *N); SDValue ScalarizeVecRes_SELECT_CC(SDNode *N); + SDValue ScalarizeVecRes_SETCC(SDNode *N); SDValue ScalarizeVecRes_UNDEF(SDNode *N); SDValue ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N); SDValue ScalarizeVecRes_VSETCC(SDNode *N); - SDValue ScalarizeVecRes_SETCC(SDNode *N); // Vector Operand Scalarization: <1 x ty> -> ty. bool ScalarizeVectorOperand(SDNode *N, unsigned OpNo); @@ -558,10 +558,10 @@ void SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDValue &Lo, SDValue &Hi); void SplitVecRes_LOAD(LoadSDNode *N, SDValue &Lo, SDValue &Hi); void SplitVecRes_SCALAR_TO_VECTOR(SDNode *N, SDValue &Lo, SDValue &Hi); + void SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi); void SplitVecRes_UNDEF(SDNode *N, SDValue &Lo, SDValue &Hi); - void SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N, SDValue &Lo, + void SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N, SDValue &Lo, SDValue &Hi); - void SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi); // Vector Operand Splitting: <128 x ty> -> 2 x <64 x ty>. bool SplitVectorOperand(SDNode *N, unsigned OpNo); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp?rev=75001&r1=75000&r2=75001&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Wed Jul 8 06:36:39 2009 @@ -106,7 +106,7 @@ if (TLI.isBigEndian()) std::swap(Lo, Hi); - + return; } } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=75001&r1=75000&r2=75001&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Wed Jul 8 06:36:39 2009 @@ -53,10 +53,10 @@ case ISD::SCALAR_TO_VECTOR: R = ScalarizeVecRes_SCALAR_TO_VECTOR(N); break; case ISD::SELECT: R = ScalarizeVecRes_SELECT(N); break; case ISD::SELECT_CC: R = ScalarizeVecRes_SELECT_CC(N); break; + case ISD::SETCC: R = ScalarizeVecRes_SETCC(N); break; case ISD::UNDEF: R = ScalarizeVecRes_UNDEF(N); break; case ISD::VECTOR_SHUFFLE: R = ScalarizeVecRes_VECTOR_SHUFFLE(N); break; case ISD::VSETCC: R = ScalarizeVecRes_VSETCC(N); break; - case ISD::SETCC: R = ScalarizeVecRes_SETCC(N); break; case ISD::CTLZ: case ISD::CTPOP: @@ -207,6 +207,15 @@ N->getOperand(4)); } +SDValue DAGTypeLegalizer::ScalarizeVecRes_SETCC(SDNode *N) { + SDValue LHS = GetScalarizedVector(N->getOperand(0)); + SDValue RHS = GetScalarizedVector(N->getOperand(1)); + DebugLoc DL = N->getDebugLoc(); + + // Turn it into a scalar SETCC. + return DAG.getNode(ISD::SETCC, DL, MVT::i1, LHS, RHS, N->getOperand(2)); +} + SDValue DAGTypeLegalizer::ScalarizeVecRes_UNDEF(SDNode *N) { return DAG.getUNDEF(N->getValueType(0).getVectorElementType()); } @@ -242,7 +251,7 @@ // Truncate to the final type. return DAG.getNode(ISD::TRUNCATE, DL, NVT, Res); } - + // The SETCC result type is smaller than the vector element type. // If the SetCC result is not sign-extended, chop it down to MVT::i1. if (TLI.getBooleanContents() != @@ -251,14 +260,6 @@ // Sign extend to the final type. return DAG.getNode(ISD::SIGN_EXTEND, DL, NVT, Res); } -SDValue DAGTypeLegalizer::ScalarizeVecRes_SETCC(SDNode *N) { - SDValue LHS = GetScalarizedVector(N->getOperand(0)); - SDValue RHS = GetScalarizedVector(N->getOperand(1)); - DebugLoc DL = N->getDebugLoc(); - - // Turn it into a scalar SETCC. - return DAG.getNode(ISD::SETCC, DL, MVT::i1, LHS, RHS, N->getOperand(2)); -} //===----------------------------------------------------------------------===// @@ -392,14 +393,13 @@ case ISD::LOAD: SplitVecRes_LOAD(cast(N), Lo, Hi); break; - case ISD::VECTOR_SHUFFLE: - SplitVecRes_VECTOR_SHUFFLE(cast(N), Lo, Hi); - break; - - case ISD::VSETCC: case ISD::SETCC: + case ISD::VSETCC: SplitVecRes_SETCC(N, Lo, Hi); break; + case ISD::VECTOR_SHUFFLE: + SplitVecRes_VECTOR_SHUFFLE(cast(N), Lo, Hi); + break; case ISD::CTTZ: case ISD::CTLZ: @@ -735,6 +735,42 @@ ReplaceValueWith(SDValue(LD, 1), Ch); } +void DAGTypeLegalizer::SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi) { + MVT LoVT, HiVT; + DebugLoc DL = N->getDebugLoc(); + GetSplitDestVTs(N->getValueType(0), LoVT, HiVT); + + // Split the input. + MVT InVT = N->getOperand(0).getValueType(); + SDValue LL, LH, RL, RH; + switch (getTypeAction(InVT)) { + default: assert(0 && "Unexpected type action!"); + case WidenVector: assert(0 && "Unimp"); + case Legal: { + assert(LoVT == HiVT && "Legal non-power-of-two vector type?"); + MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(), + LoVT.getVectorNumElements()); + LL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0), + DAG.getIntPtrConstant(0)); + LH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0), + DAG.getIntPtrConstant(InNVT.getVectorNumElements())); + + RL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1), + DAG.getIntPtrConstant(0)); + RH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1), + DAG.getIntPtrConstant(InNVT.getVectorNumElements())); + break; + } + case SplitVector: + GetSplitVector(N->getOperand(0), LL, LH); + GetSplitVector(N->getOperand(1), RL, RH); + break; + } + + Lo = DAG.getNode(N->getOpcode(), DL, LoVT, LL, RL, N->getOperand(2)); + Hi = DAG.getNode(N->getOpcode(), DL, HiVT, LH, RH, N->getOperand(2)); +} + void DAGTypeLegalizer::SplitVecRes_UnaryOp(SDNode *N, SDValue &Lo, SDValue &Hi) { // Get the dest types - they may not match the input types, e.g. int_to_fp. @@ -889,41 +925,6 @@ } } -void DAGTypeLegalizer::SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi) { - MVT LoVT, HiVT; - DebugLoc DL = N->getDebugLoc(); - GetSplitDestVTs(N->getValueType(0), LoVT, HiVT); - - // Split the input. - MVT InVT = N->getOperand(0).getValueType(); - SDValue LL, LH, RL, RH; - switch (getTypeAction(InVT)) { - default: assert(0 && "Unexpected type action!"); - case WidenVector: assert(0 && "Unimp"); - case Legal: { - assert(LoVT == HiVT && "Legal non-power-of-two vector type?"); - MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(), - LoVT.getVectorNumElements()); - LL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0), - DAG.getIntPtrConstant(0)); - LH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0), - DAG.getIntPtrConstant(InNVT.getVectorNumElements())); - - RL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1), - DAG.getIntPtrConstant(0)); - RH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1), - DAG.getIntPtrConstant(InNVT.getVectorNumElements())); - break; - } - case SplitVector: - GetSplitVector(N->getOperand(0), LL, LH); - GetSplitVector(N->getOperand(1), RL, RH); - break; - } - - Lo = DAG.getNode(N->getOpcode(), DL, LoVT, LL, RL, N->getOperand(2)); - Hi = DAG.getNode(N->getOpcode(), DL, HiVT, LH, RH, N->getOperand(2)); -} //===----------------------------------------------------------------------===// // Operand Vector Splitting @@ -1149,7 +1150,7 @@ case ISD::SELECT: Res = WidenVecRes_SELECT(N); break; case ISD::SELECT_CC: Res = WidenVecRes_SELECT_CC(N); break; case ISD::UNDEF: Res = WidenVecRes_UNDEF(N); break; - case ISD::VECTOR_SHUFFLE: + case ISD::VECTOR_SHUFFLE: Res = WidenVecRes_VECTOR_SHUFFLE(cast(N)); break; case ISD::VSETCC: @@ -1464,7 +1465,7 @@ MaskOps[i] = i; MaskOps[i+WidenNumElts/2] = i+WidenNumElts; } - return DAG.getVectorShuffle(WidenVT, dl, + return DAG.getVectorShuffle(WidenVT, dl, GetWidenedVector(N->getOperand(0)), GetWidenedVector(N->getOperand(1)), &MaskOps[0]); From aaronngray.lists at googlemail.com Wed Jul 8 08:59:32 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Wed, 8 Jul 2009 14:59:32 +0100 Subject: [llvm-commits] [patch] JITCodeEmitter speedup patch In-Reply-To: <9a9942200907071024l5186d982m86afbaff2326dc03@mail.gmail.com> References: <9719867c0907070827r60eb90c2q52c6a3fa52b933d7@mail.gmail.com> <9a9942200907071024l5186d982m86afbaff2326dc03@mail.gmail.com> Message-ID: <9719867c0907080659g53c7455dwab9caad365ffd2a0@mail.gmail.com> Ah Reid, I sent out the wrong patch in panick over the templating bussiness. The actual patch has extra emit methods after the extend() method calls that allow the exection to continue after the JITCodeEmitter's parent has changed the buffer for an extended one. Aaron 2009/7/7 Reid Kleckner > On Tue, Jul 7, 2009 at 8:27 AM, Aaron > Gray wrote: > > It also has a extend() method for extending the buffer and continuing if > th > > buffer overfolws. And a reserveBytes that can be used in conjunction with > > the raw*emit methods to allow a whole instruction to be output without > any > > buffer checking. > > Are you planning to change the JITEmitter to JITMemoryManager API with > this extend method? From what I can tell this just moves the FIXME > around. > > There are two ways I can see the JITEmitter working: > > 1) The current API where the target-specific CodeEmitters wrap > emission in a do { startFunction(F); ... } while (finishFunction(F)); > loop. When finishFunction fails and returns true, the memory manager > needs to try again with more memory next time. This is what I've been > working on. I've fixed up the emitter so that it will request more > memory, and the memory manager so that it will actually allocate more > blocks of memory when it runs out. > > 2) A nicer API where we emit code into a buffer, say a raw_ostream or > vector, figure out how big it is, allocate exactly that much > memory, and then run the relocations over it *after* it has been > emitted. The trick here is that you don't actually know the function > start address until after you've emitted the code, and I don't know > how much that complicates code generation. If we can take care of > that with relocations, then I see no reason to use the more complex > API #1. However, there could be other reasons why people chose API #1 > back in the day that I'm not aware of. > > I'm just wondering what the plan is. > > Reid > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090708/a140f7c1/attachment.html From criswell at uiuc.edu Wed Jul 8 10:25:15 2009 From: criswell at uiuc.edu (John Criswell) Date: Wed, 08 Jul 2009 15:25:15 -0000 Subject: [llvm-commits] [poolalloc] r75008 - in /poolalloc/trunk/lib/PoolAllocate: Heuristic.cpp PAMultipleGlobalPool.cpp PASimple.cpp PoolAllocate.cpp Message-ID: <200907081525.n68FPVbi013880@zion.cs.uiuc.edu> Author: criswell Date: Wed Jul 8 10:24:19 2009 New Revision: 75008 URL: http://llvm.org/viewvc/llvm-project?rev=75008&view=rev Log: Switch to the new LLVM API which requires that the GlobalVariable constructor take a pointer to an LLVMContext. Modified: poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp poolalloc/trunk/lib/PoolAllocate/PASimple.cpp poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Modified: poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp?rev=75008&r1=75007&r2=75008&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp Wed Jul 8 10:24:19 2009 @@ -440,7 +440,8 @@ static Value *NullGlobal = 0; if (!NullGlobal) { Module *M = I->getParent()->getParent()->getParent(); - NullGlobal = new GlobalVariable(PoolAllocate::PoolDescPtrTy, false, + NullGlobal = new GlobalVariable(M->getContext(), + PoolAllocate::PoolDescPtrTy, false, GlobalValue::ExternalLinkage, Constant::getNullValue(PoolAllocate::PoolDescPtrTy), "llvm-poolalloc-null-init", M); Modified: poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp?rev=75008&r1=75007&r2=75008&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp Wed Jul 8 10:24:19 2009 @@ -321,7 +321,8 @@ E = G->node_end(); I != E; ++I) { GlobalVariable *GV = - new GlobalVariable(getPoolType(), false, GlobalValue::ExternalLinkage, + new GlobalVariable(M.getContext(), + getPoolType(), false, GlobalValue::ExternalLinkage, Constant::getNullValue(getPoolType()), "__poolalloc_GlobalPool", &M); Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=75008&r1=75007&r2=75008&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Wed Jul 8 10:24:19 2009 @@ -353,8 +353,10 @@ unsigned Align, Module& M) { GlobalVariable *GV = - new GlobalVariable(getPoolType(), false, GlobalValue::ExternalLinkage, - Constant::getNullValue(getPoolType()), "__poolalloc_GlobalPool", + new GlobalVariable(M.getContext(), + getPoolType(), false, GlobalValue::ExternalLinkage, + Constant::getNullValue(getPoolType()), + "__poolalloc_GlobalPool", &M); Function *InitFunc = Function::Create Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=75008&r1=75007&r2=75008&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Wed Jul 8 10:24:19 2009 @@ -600,7 +600,8 @@ GlobalVariable *PoolAllocate::CreateGlobalPool(unsigned RecSize, unsigned Align, Instruction *IPHint) { GlobalVariable *GV = - new GlobalVariable(PoolDescType, false, GlobalValue::InternalLinkage, + new GlobalVariable(CurModule->getContext(), + PoolDescType, false, GlobalValue::InternalLinkage, Constant::getNullValue(PoolDescType), "GlobalPool", CurModule); From aaronngray.lists at googlemail.com Wed Jul 8 10:53:32 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Wed, 8 Jul 2009 16:53:32 +0100 Subject: [llvm-commits] [patch] JITCodeEmitter speedup patch In-Reply-To: <9719867c0907080659g53c7455dwab9caad365ffd2a0@mail.gmail.com> References: <9719867c0907070827r60eb90c2q52c6a3fa52b933d7@mail.gmail.com> <9a9942200907071024l5186d982m86afbaff2326dc03@mail.gmail.com> <9719867c0907080659g53c7455dwab9caad365ffd2a0@mail.gmail.com> Message-ID: <9719867c0907080853t64300ed0ie81466afe1adb630@mail.gmail.com> Reid, Sorry it was the right patch, yes your option #2 looks like the best solution. We are probably going to have to revert back to the old MachineCodeEmitter class as for some reason Chris and Evan don't like templates in the CodeEmitter's. So we will probably be employing the same extend method and relocations as with the JITCodeEmitter patch I forwarded earlier. Thanks, Aaron 2009/7/8 Aaron Gray > Ah Reid, > > I sent out the wrong patch in panick over the templating bussiness. The > actual patch has extra emit methods after the extend() method calls that > allow the exection to continue after the JITCodeEmitter's parent has changed > the buffer for an extended one. > > Aaron > > 2009/7/7 Reid Kleckner > > On Tue, Jul 7, 2009 at 8:27 AM, Aaron >> Gray wrote: >> > It also has a extend() method for extending the buffer and continuing if >> th >> > buffer overfolws. And a reserveBytes that can be used in conjunction >> with >> > the raw*emit methods to allow a whole instruction to be output without >> any >> > buffer checking. >> >> Are you planning to change the JITEmitter to JITMemoryManager API with >> this extend method? From what I can tell this just moves the FIXME >> around. >> >> There are two ways I can see the JITEmitter working: >> >> 1) The current API where the target-specific CodeEmitters wrap >> emission in a do { startFunction(F); ... } while (finishFunction(F)); >> loop. When finishFunction fails and returns true, the memory manager >> needs to try again with more memory next time. This is what I've been >> working on. I've fixed up the emitter so that it will request more >> memory, and the memory manager so that it will actually allocate more >> blocks of memory when it runs out. >> >> 2) A nicer API where we emit code into a buffer, say a raw_ostream or >> vector, figure out how big it is, allocate exactly that much >> memory, and then run the relocations over it *after* it has been >> emitted. The trick here is that you don't actually know the function >> start address until after you've emitted the code, and I don't know >> how much that complicates code generation. If we can take care of >> that with relocations, then I see no reason to use the more complex >> API #1. However, there could be other reasons why people chose API #1 >> back in the day that I'm not aware of. >> >> I'm just wondering what the plan is. >> >> Reid >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090708/ea1b74e4/attachment.html From david_goodwin at apple.com Wed Jul 8 11:09:58 2009 From: david_goodwin at apple.com (David Goodwin) Date: Wed, 08 Jul 2009 16:09:58 -0000 Subject: [llvm-commits] [llvm] r75010 - in /llvm/trunk: lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/ARM/ARMBaseInstrInfo.h lib/Target/ARM/ARMInstrInfo.cpp lib/Target/ARM/ARMInstrInfo.h lib/Target/ARM/ARMInstrThumb.td lib/Target/ARM/ARMInstrThumb2.td lib/Target/ARM/CMakeLists.txt lib/Target/ARM/Thumb1InstrInfo.cpp lib/Target/ARM/Thumb1InstrInfo.h lib/Target/ARM/Thumb2InstrInfo.cpp lib/Target/ARM/Thumb2InstrInfo.h test/CodeGen/Thumb2/thumb2-select_xform.ll Message-ID: <200907081610.n68GAQaX015465@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Jul 8 11:09:28 2009 New Revision: 75010 URL: http://llvm.org/viewvc/llvm-project?rev=75010&view=rev Log: Checkpoint Thumb2 Instr info work. Generalized base code so that it can be shared between ARM and Thumb2. Not yet activated because register information must be generalized first. Added: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp - copied, changed from r74731, llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h - copied, changed from r74731, llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.h llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/CMakeLists.txt llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll Copied: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (from r74731, llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?p2=llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp&p1=llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp&r1=74731&r2=75010&rev=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Wed Jul 8 11:09:28 2009 @@ -1,4 +1,4 @@ -//===- ARMInstrInfo.cpp - ARM Instruction Information -----------*- C++ -*-===// +//===- ARMBaseInstrInfo.cpp - ARM Instruction Information -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// // -// This file contains the ARM implementation of the TargetInstrInfo class. +// This file contains the Base ARM implementation of the TargetInstrInfo class. // //===----------------------------------------------------------------------===// -#include "ARMInstrInfo.h" +#include "ARMBaseInstrInfo.h" #include "ARM.h" #include "ARMAddressingModes.h" #include "ARMGenInstrInfo.inc" @@ -43,60 +43,6 @@ : TargetInstrInfoImpl(ARMInsts, array_lengthof(ARMInsts)) { } -ARMInstrInfo::ARMInstrInfo(const ARMSubtarget &STI) - : ARMBaseInstrInfo(STI), RI(*this, STI) { -} - -void ARMInstrInfo::reMaterialize(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, - unsigned DestReg, - const MachineInstr *Orig) const { - DebugLoc dl = Orig->getDebugLoc(); - if (Orig->getOpcode() == ARM::MOVi2pieces) { - RI.emitLoadConstPool(MBB, I, this, dl, - DestReg, - Orig->getOperand(1).getImm(), - (ARMCC::CondCodes)Orig->getOperand(2).getImm(), - Orig->getOperand(3).getReg()); - return; - } - - MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); - MI->getOperand(0).setReg(DestReg); - MBB.insert(I, MI); -} - -static unsigned getUnindexedOpcode(unsigned Opc) { - switch (Opc) { - default: break; - case ARM::LDR_PRE: - case ARM::LDR_POST: - return ARM::LDR; - case ARM::LDRH_PRE: - case ARM::LDRH_POST: - return ARM::LDRH; - case ARM::LDRB_PRE: - case ARM::LDRB_POST: - return ARM::LDRB; - case ARM::LDRSH_PRE: - case ARM::LDRSH_POST: - return ARM::LDRSH; - case ARM::LDRSB_PRE: - case ARM::LDRSB_POST: - return ARM::LDRSB; - case ARM::STR_PRE: - case ARM::STR_POST: - return ARM::STR; - case ARM::STRH_PRE: - case ARM::STRH_POST: - return ARM::STRH; - case ARM::STRB_PRE: - case ARM::STRB_POST: - return ARM::STRB; - } - return 0; -} - MachineInstr * ARMBaseInstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI, MachineBasicBlock::iterator &MBBI, @@ -151,19 +97,22 @@ // add more than 1 instruction. Abandon! return NULL; UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBri : ARM::ADDri), WBReg) + get(isSub ? getOpcode(ARMII::SUBri) : + getOpcode(ARMII::ADDri)), WBReg) .addReg(BaseReg).addImm(SOImmVal) .addImm(Pred).addReg(0).addReg(0); } else if (Amt != 0) { ARM_AM::ShiftOpc ShOpc = ARM_AM::getAM2ShiftOpc(OffImm); unsigned SOOpc = ARM_AM::getSORegOpc(ShOpc, Amt); UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBrs : ARM::ADDrs), WBReg) + get(isSub ? getOpcode(ARMII::SUBrs) : + getOpcode(ARMII::ADDrs)), WBReg) .addReg(BaseReg).addReg(OffReg).addReg(0).addImm(SOOpc) .addImm(Pred).addReg(0).addReg(0); } else UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg) + get(isSub ? getOpcode(ARMII::SUBrr) : + getOpcode(ARMII::ADDrr)), WBReg) .addReg(BaseReg).addReg(OffReg) .addImm(Pred).addReg(0).addReg(0); break; @@ -174,12 +123,14 @@ if (OffReg == 0) // Immediate is 8-bits. It's guaranteed to fit in a so_imm operand. UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBri : ARM::ADDri), WBReg) + get(isSub ? getOpcode(ARMII::SUBri) : + getOpcode(ARMII::ADDri)), WBReg) .addReg(BaseReg).addImm(Amt) .addImm(Pred).addReg(0).addReg(0); else UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg) + get(isSub ? getOpcode(ARMII::SUBrr) : + getOpcode(ARMII::ADDrr)), WBReg) .addReg(BaseReg).addReg(OffReg) .addImm(Pred).addReg(0).addReg(0); break; @@ -265,11 +216,11 @@ // If there is only one terminator instruction, process it. unsigned LastOpc = LastInst->getOpcode(); if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) { - if (LastOpc == ARM::B || LastOpc == ARM::tB || LastOpc == ARM::t2B) { + if (LastOpc == getOpcode(ARMII::B)) { TBB = LastInst->getOperand(0).getMBB(); return false; } - if (LastOpc == ARM::Bcc || LastOpc == ARM::tBcc || LastOpc == ARM::t2Bcc) { + if (LastOpc == getOpcode(ARMII::Bcc)) { // Block ends with fall-through condbranch. TBB = LastInst->getOperand(0).getMBB(); Cond.push_back(LastInst->getOperand(1)); @@ -286,12 +237,10 @@ if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(--I)) return true; - // If the block ends with ARM::B/ARM::tB/ARM::t2B and a - // ARM::Bcc/ARM::tBcc/ARM::t2Bcc, handle it. + // If the block ends with ARMII::B and a ARMII::Bcc, handle it. unsigned SecondLastOpc = SecondLastInst->getOpcode(); - if ((SecondLastOpc == ARM::Bcc && LastOpc == ARM::B) || - (SecondLastOpc == ARM::tBcc && LastOpc == ARM::tB) || - (SecondLastOpc == ARM::t2Bcc && LastOpc == ARM::t2B)) { + if ((SecondLastOpc == getOpcode(ARMII::Bcc)) && + (LastOpc == getOpcode(ARMII::B))) { TBB = SecondLastInst->getOperand(0).getMBB(); Cond.push_back(SecondLastInst->getOperand(1)); Cond.push_back(SecondLastInst->getOperand(2)); @@ -301,9 +250,8 @@ // If the block ends with two unconditional branches, handle it. The second // one is not executed, so remove it. - if ((SecondLastOpc == ARM::B || SecondLastOpc==ARM::tB || - SecondLastOpc==ARM::t2B) && - (LastOpc == ARM::B || LastOpc == ARM::tB || LastOpc == ARM::t2B)) { + if ((SecondLastOpc == getOpcode(ARMII::B)) && + (LastOpc == getOpcode(ARMII::B))) { TBB = SecondLastInst->getOperand(0).getMBB(); I = LastInst; if (AllowModify) @@ -314,11 +262,10 @@ // ...likewise if it ends with a branch table followed by an unconditional // branch. The branch folder can create these, and we must get rid of them for // correctness of Thumb constant islands. - if ((SecondLastOpc == ARM::BR_JTr || SecondLastOpc==ARM::BR_JTm || - SecondLastOpc == ARM::BR_JTadd || SecondLastOpc==ARM::tBR_JTr || - SecondLastOpc == ARM::t2BR_JTr || SecondLastOpc==ARM::t2BR_JTm || - SecondLastOpc == ARM::t2BR_JTadd) && - (LastOpc == ARM::B || LastOpc == ARM::tB || LastOpc == ARM::t2B)) { + if (((SecondLastOpc == getOpcode(ARMII::BR_JTr)) || + (SecondLastOpc == getOpcode(ARMII::BR_JTm)) || + (SecondLastOpc == getOpcode(ARMII::BR_JTadd))) && + (LastOpc == getOpcode(ARMII::B))) { I = LastInst; if (AllowModify) I->eraseFromParent(); @@ -331,12 +278,8 @@ unsigned ARMBaseInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const { - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo(); - int BOpc = AFI->isThumbFunction() ? - (AFI->isThumb2Function() ? ARM::t2B : ARM::tB) : ARM::B; - int BccOpc = AFI->isThumbFunction() ? - (AFI->isThumb2Function() ? ARM::t2Bcc : ARM::tBcc) : ARM::Bcc; + int BOpc = getOpcode(ARMII::B); + int BccOpc = getOpcode(ARMII::Bcc); MachineBasicBlock::iterator I = MBB.end(); if (I == MBB.begin()) return 0; @@ -365,12 +308,8 @@ const SmallVectorImpl &Cond) const { // FIXME this should probably have a DebugLoc argument DebugLoc dl = DebugLoc::getUnknownLoc(); - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo(); - int BOpc = AFI->isThumbFunction() ? - (AFI->isThumb2Function() ? ARM::t2B : ARM::tB) : ARM::B; - int BccOpc = AFI->isThumbFunction() ? - (AFI->isThumb2Function() ? ARM::t2Bcc : ARM::tBcc) : ARM::Bcc; + int BOpc = getOpcode(ARMII::B); + int BccOpc = getOpcode(ARMII::Bcc); // Shouldn't be a fall through. assert(TBB && "InsertBranch must not be told to insert a fallthrough"); @@ -393,31 +332,6 @@ return 2; } -bool -ARMBaseInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case ARM::BX_RET: // Return. - case ARM::LDM_RET: - case ARM::tBX_RET: - case ARM::tBX_RET_vararg: - case ARM::tPOP_RET: - case ARM::B: - case ARM::tB: - case ARM::t2B: // Uncond branch. - case ARM::tBR_JTr: - case ARM::t2BR_JTr: - case ARM::BR_JTr: // Jumptable branch. - case ARM::t2BR_JTm: - case ARM::BR_JTm: // Jumptable branch through mem. - case ARM::t2BR_JTadd: - case ARM::BR_JTadd: // Jumptable branch add to pc. - return true; - default: return false; - } -} - bool ARMBaseInstrInfo:: ReverseBranchCondition(SmallVectorImpl &Cond) const { ARMCC::CondCodes CC = (ARMCC::CondCodes)(int)Cond[0].getImm(); @@ -434,9 +348,8 @@ PredicateInstruction(MachineInstr *MI, const SmallVectorImpl &Pred) const { unsigned Opc = MI->getOpcode(); - if (Opc == ARM::B || Opc == ARM::tB || Opc == ARM::t2B) { - MI->setDesc(get((Opc == ARM::B) ? ARM::Bcc : - ((Opc == ARM::tB) ? ARM::tBcc : ARM::t2Bcc))); + if (Opc == getOpcode(ARMII::B)) { + MI->setDesc(get(getOpcode(ARMII::Bcc))); MI->addOperand(MachineOperand::CreateImm(Pred[0].getImm())); MI->addOperand(MachineOperand::CreateReg(Pred[1].getReg(), false)); return true; @@ -591,17 +504,15 @@ SrcSubIdx = DstSubIdx = 0; // No sub-registers. unsigned oc = MI.getOpcode(); - switch (oc) { - default: - return false; - case ARM::FCPYS: - case ARM::FCPYD: - case ARM::VMOVD: - case ARM::VMOVQ: + if ((oc == getOpcode(ARMII::FCPYS)) || + (oc == getOpcode(ARMII::FCPYD)) || + (oc == getOpcode(ARMII::VMOVD)) || + (oc == getOpcode(ARMII::VMOVQ))) { SrcReg = MI.getOperand(1).getReg(); DstReg = MI.getOperand(0).getReg(); return true; - case ARM::MOVr: + } + else if (oc == getOpcode(ARMII::MOVr)) { assert(MI.getDesc().getNumOperands() >= 2 && MI.getOperand(0).isReg() && MI.getOperand(1).isReg() && @@ -610,14 +521,15 @@ DstReg = MI.getOperand(0).getReg(); return true; } + + return false; } unsigned ARMBaseInstrInfo::isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const { - switch (MI->getOpcode()) { - default: break; - case ARM::LDR: + unsigned oc = MI->getOpcode(); + if (oc == getOpcode(ARMII::LDR)) { if (MI->getOperand(1).isFI() && MI->getOperand(2).isReg() && MI->getOperand(3).isImm() && @@ -626,26 +538,25 @@ FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } - break; - case ARM::FLDD: - case ARM::FLDS: + } + else if ((oc == getOpcode(ARMII::FLDD)) || + (oc == getOpcode(ARMII::FLDS))) { if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && MI->getOperand(2).getImm() == 0) { FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } - break; } + return 0; } unsigned ARMBaseInstrInfo::isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const { - switch (MI->getOpcode()) { - default: break; - case ARM::STR: + unsigned oc = MI->getOpcode(); + if (oc == getOpcode(ARMII::STR)) { if (MI->getOperand(1).isFI() && MI->getOperand(2).isReg() && MI->getOperand(3).isImm() && @@ -654,16 +565,15 @@ FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } - break; - case ARM::FSTD: - case ARM::FSTS: + } + else if ((oc == getOpcode(ARMII::FSTD)) || + (oc == getOpcode(ARMII::FSTS))) { if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && MI->getOperand(2).getImm() == 0) { FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } - break; } return 0; @@ -684,16 +594,16 @@ } if (DestRC == ARM::GPRRegisterClass) - AddDefaultCC(AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::MOVr), DestReg) + AddDefaultCC(AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::MOVr)), DestReg) .addReg(SrcReg))); else if (DestRC == ARM::SPRRegisterClass) - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FCPYS), DestReg) + AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::FCPYS)), DestReg) .addReg(SrcReg)); else if (DestRC == ARM::DPRRegisterClass) - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FCPYD), DestReg) + AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::FCPYD)), DestReg) .addReg(SrcReg)); else if (DestRC == ARM::QPRRegisterClass) - BuildMI(MBB, I, DL, get(ARM::VMOVQ), DestReg).addReg(SrcReg); + BuildMI(MBB, I, DL, get(getOpcode(ARMII::VMOVQ)), DestReg).addReg(SrcReg); else return false; @@ -708,16 +618,16 @@ if (I != MBB.end()) DL = I->getDebugLoc(); if (RC == ARM::GPRRegisterClass) { - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::STR)) + AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::STR))) .addReg(SrcReg, getKillRegState(isKill)) .addFrameIndex(FI).addReg(0).addImm(0)); } else if (RC == ARM::DPRRegisterClass) { - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FSTD)) + AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::FSTD))) .addReg(SrcReg, getKillRegState(isKill)) .addFrameIndex(FI).addImm(0)); } else { assert(RC == ARM::SPRRegisterClass && "Unknown regclass!"); - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FSTS)) + AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::FSTS))) .addReg(SrcReg, getKillRegState(isKill)) .addFrameIndex(FI).addImm(0)); } @@ -732,12 +642,12 @@ DebugLoc DL = DebugLoc::getUnknownLoc(); unsigned Opc = 0; if (RC == ARM::GPRRegisterClass) { - Opc = ARM::STR; + Opc = getOpcode(ARMII::STR); } else if (RC == ARM::DPRRegisterClass) { - Opc = ARM::FSTD; + Opc = getOpcode(ARMII::FSTD); } else { assert(RC == ARM::SPRRegisterClass && "Unknown regclass!"); - Opc = ARM::FSTS; + Opc = getOpcode(ARMII::FSTS); } MachineInstrBuilder MIB = @@ -757,14 +667,14 @@ if (I != MBB.end()) DL = I->getDebugLoc(); if (RC == ARM::GPRRegisterClass) { - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::LDR), DestReg) + AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::LDR)), DestReg) .addFrameIndex(FI).addReg(0).addImm(0)); } else if (RC == ARM::DPRRegisterClass) { - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FLDD), DestReg) + AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::FLDD)), DestReg) .addFrameIndex(FI).addImm(0)); } else { assert(RC == ARM::SPRRegisterClass && "Unknown regclass!"); - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FLDS), DestReg) + AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::FLDS)), DestReg) .addFrameIndex(FI).addImm(0)); } } @@ -777,12 +687,12 @@ DebugLoc DL = DebugLoc::getUnknownLoc(); unsigned Opc = 0; if (RC == ARM::GPRRegisterClass) { - Opc = ARM::LDR; + Opc = getOpcode(ARMII::LDR); } else if (RC == ARM::DPRRegisterClass) { - Opc = ARM::FLDD; + Opc = getOpcode(ARMII::FLDD); } else { assert(RC == ARM::SPRRegisterClass && "Unknown regclass!"); - Opc = ARM::FLDS; + Opc = getOpcode(ARMII::FLDS); } MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc), DestReg); @@ -801,42 +711,39 @@ unsigned OpNum = Ops[0]; unsigned Opc = MI->getOpcode(); MachineInstr *NewMI = NULL; - switch (Opc) { - default: break; - case ARM::MOVr: { - if (MI->getOperand(4).getReg() == ARM::CPSR) - // If it is updating CPSR, then it cannot be folded. - break; - unsigned Pred = MI->getOperand(2).getImm(); - unsigned PredReg = MI->getOperand(3).getReg(); - if (OpNum == 0) { // move -> store - unsigned SrcReg = MI->getOperand(1).getReg(); - bool isKill = MI->getOperand(1).isKill(); - bool isUndef = MI->getOperand(1).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::STR)) - .addReg(SrcReg, getKillRegState(isKill) | getUndefRegState(isUndef)) - .addFrameIndex(FI).addReg(0).addImm(0).addImm(Pred).addReg(PredReg); - } else { // move -> load - unsigned DstReg = MI->getOperand(0).getReg(); - bool isDead = MI->getOperand(0).isDead(); - bool isUndef = MI->getOperand(0).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::LDR)) - .addReg(DstReg, - RegState::Define | - getDeadRegState(isDead) | - getUndefRegState(isUndef)) - .addFrameIndex(FI).addReg(0).addImm(0).addImm(Pred).addReg(PredReg); + if (Opc == getOpcode(ARMII::MOVr)) { + // If it is updating CPSR, then it cannot be folded. + if (MI->getOperand(4).getReg() != ARM::CPSR) { + unsigned Pred = MI->getOperand(2).getImm(); + unsigned PredReg = MI->getOperand(3).getReg(); + if (OpNum == 0) { // move -> store + unsigned SrcReg = MI->getOperand(1).getReg(); + bool isKill = MI->getOperand(1).isKill(); + bool isUndef = MI->getOperand(1).isUndef(); + NewMI = BuildMI(MF, MI->getDebugLoc(), get(getOpcode(ARMII::STR))) + .addReg(SrcReg, getKillRegState(isKill) | getUndefRegState(isUndef)) + .addFrameIndex(FI).addReg(0).addImm(0).addImm(Pred).addReg(PredReg); + } else { // move -> load + unsigned DstReg = MI->getOperand(0).getReg(); + bool isDead = MI->getOperand(0).isDead(); + bool isUndef = MI->getOperand(0).isUndef(); + NewMI = BuildMI(MF, MI->getDebugLoc(), get(getOpcode(ARMII::LDR))) + .addReg(DstReg, + RegState::Define | + getDeadRegState(isDead) | + getUndefRegState(isUndef)) + .addFrameIndex(FI).addReg(0).addImm(0).addImm(Pred).addReg(PredReg); + } } - break; } - case ARM::FCPYS: { + else if (Opc == getOpcode(ARMII::FCPYS)) { unsigned Pred = MI->getOperand(2).getImm(); unsigned PredReg = MI->getOperand(3).getReg(); if (OpNum == 0) { // move -> store unsigned SrcReg = MI->getOperand(1).getReg(); bool isKill = MI->getOperand(1).isKill(); bool isUndef = MI->getOperand(1).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::FSTS)) + NewMI = BuildMI(MF, MI->getDebugLoc(), get(getOpcode(ARMII::FSTS))) .addReg(SrcReg, getKillRegState(isKill) | getUndefRegState(isUndef)) .addFrameIndex(FI) .addImm(0).addImm(Pred).addReg(PredReg); @@ -844,38 +751,35 @@ unsigned DstReg = MI->getOperand(0).getReg(); bool isDead = MI->getOperand(0).isDead(); bool isUndef = MI->getOperand(0).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::FLDS)) + NewMI = BuildMI(MF, MI->getDebugLoc(), get(getOpcode(ARMII::FLDS))) .addReg(DstReg, RegState::Define | getDeadRegState(isDead) | getUndefRegState(isUndef)) .addFrameIndex(FI).addImm(0).addImm(Pred).addReg(PredReg); } - break; } - case ARM::FCPYD: { + else if (Opc == getOpcode(ARMII::FCPYD)) { unsigned Pred = MI->getOperand(2).getImm(); unsigned PredReg = MI->getOperand(3).getReg(); if (OpNum == 0) { // move -> store unsigned SrcReg = MI->getOperand(1).getReg(); bool isKill = MI->getOperand(1).isKill(); bool isUndef = MI->getOperand(1).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::FSTD)) + NewMI = BuildMI(MF, MI->getDebugLoc(), get(getOpcode(ARMII::FSTD))) .addReg(SrcReg, getKillRegState(isKill) | getUndefRegState(isUndef)) .addFrameIndex(FI).addImm(0).addImm(Pred).addReg(PredReg); } else { // move -> load unsigned DstReg = MI->getOperand(0).getReg(); bool isDead = MI->getOperand(0).isDead(); bool isUndef = MI->getOperand(0).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::FLDD)) + NewMI = BuildMI(MF, MI->getDebugLoc(), get(getOpcode(ARMII::FLDD))) .addReg(DstReg, RegState::Define | getDeadRegState(isDead) | getUndefRegState(isUndef)) .addFrameIndex(FI).addImm(0).addImm(Pred).addReg(PredReg); } - break; - } } return NewMI; @@ -895,17 +799,16 @@ if (Ops.size() != 1) return false; unsigned Opc = MI->getOpcode(); - switch (Opc) { - default: break; - case ARM::MOVr: + if (Opc == getOpcode(ARMII::MOVr)) { // If it is updating CPSR, then it cannot be folded. return MI->getOperand(4).getReg() != ARM::CPSR; - case ARM::FCPYS: - case ARM::FCPYD: + } + else if ((Opc == getOpcode(ARMII::FCPYS)) || + (Opc == getOpcode(ARMII::FCPYD))) { return true; - - case ARM::VMOVD: - case ARM::VMOVQ: + } + else if ((Opc == getOpcode(ARMII::VMOVD)) || + (Opc == getOpcode(ARMII::VMOVQ))) { return false; // FIXME } Copied: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (from r74731, llvm/trunk/lib/Target/ARM/ARMInstrInfo.h) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?p2=llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h&p1=llvm/trunk/lib/Target/ARM/ARMInstrInfo.h&r1=74731&r2=75010&rev=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Wed Jul 8 11:09:28 2009 @@ -1,4 +1,4 @@ -//===- ARMInstrInfo.h - ARM Instruction Information -------------*- C++ -*-===// +//===- ARMBaseInstrInfo.h - ARM Base Instruction Information -------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// // -// This file contains the ARM implementation of the TargetInstrInfo class. +// This file contains the Base ARM implementation of the TargetInstrInfo class. // //===----------------------------------------------------------------------===// -#ifndef ARMINSTRUCTIONINFO_H -#define ARMINSTRUCTIONINFO_H +#ifndef ARMBASEINSTRUCTIONINFO_H +#define ARMBASEINSTRUCTIONINFO_H #include "llvm/Target/TargetInstrInfo.h" #include "ARMRegisterInfo.h" @@ -66,17 +66,10 @@ IndexModePost = 2, //===------------------------------------------------------------------===// - // Misc flags. - - // UnaryDP - Indicates this is a unary data processing instruction, i.e. - // it doesn't have a Rn operand. - UnaryDP = 1 << 9, - - //===------------------------------------------------------------------===// // Instruction encoding formats. // - FormShift = 10, - FormMask = 0x1f << FormShift, + FormShift = 9, + FormMask = 0x3f << FormShift, // Pseudo instructions Pseudo = 0 << FormShift, @@ -127,6 +120,17 @@ NEONDupFrm = 27 << FormShift, //===------------------------------------------------------------------===// + // Misc flags. + + // UnaryDP - Indicates this is a unary data processing instruction, i.e. + // it doesn't have a Rn operand. + UnaryDP = 1 << 15, + + // Xform16Bit - Indicates this Thumb2 instruction may be transformed into + // a 16-bit Thumb instruction if certain conditions are met. + Xform16Bit = 1 << 16, + + //===------------------------------------------------------------------===// // Field shifts - such shifts are used to set field while generating // machine instructions. M_BitShift = 5, @@ -150,6 +154,36 @@ I_BitShift = 25, CondShift = 28 }; + + /// ARMII::Op - Holds all of the instruction types required by + /// target specific instruction and register code. ARMBaseInstrInfo + /// and subclasses should return a specific opcode that implements + /// the instruction type. + /// + enum Op { + ADDri, + ADDrs, + ADDrr, + B, + Bcc, + BR_JTr, + BR_JTm, + BR_JTadd, + FCPYS, + FCPYD, + FLDD, + FLDS, + FSTD, + FSTS, + LDR, + MOVr, + STR, + SUBri, + SUBrs, + SUBrr, + VMOVD, + VMOVQ + }; } class ARMBaseInstrInfo : public TargetInstrInfoImpl { @@ -157,6 +191,16 @@ // Can be only subclassed. explicit ARMBaseInstrInfo(const ARMSubtarget &STI); public: + // Return the non-pre/post incrementing version of 'Opc'. Return 0 + // if there is not such an opcode. + virtual unsigned getUnindexedOpcode(unsigned Opc) const =0; + + // Return the opcode that implements 'Op', or 0 if no opcode + virtual unsigned getOpcode(ARMII::Op Op) const =0; + + // Return true if the block does not fall through. + virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const =0; + virtual MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI, MachineBasicBlock::iterator &MBBI, LiveVariables *LV) const; @@ -173,7 +217,6 @@ MachineBasicBlock *FBB, const SmallVectorImpl &Cond) const; - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; virtual bool ReverseBranchCondition(SmallVectorImpl &Cond) const; @@ -250,22 +293,6 @@ const SmallVectorImpl &Ops, MachineInstr* LoadMI) const; }; - -class ARMInstrInfo : public ARMBaseInstrInfo { - ARMRegisterInfo RI; -public: - explicit ARMInstrInfo(const ARMSubtarget &STI); - - /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As - /// such, whenever a client has an instance of instruction info, it should - /// always be able to get register info as well (through this method). - /// - const ARMRegisterInfo &getRegisterInfo() const { return RI; } - - void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, - unsigned DestReg, const MachineInstr *Orig) const; -}; - } #endif Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Wed Jul 8 11:09:28 2009 @@ -25,48 +25,12 @@ #include "llvm/Support/CommandLine.h" using namespace llvm; -static cl::opt -EnableARM3Addr("enable-arm-3-addr-conv", cl::Hidden, - cl::desc("Enable ARM 2-addr to 3-addr conv")); - -static inline -const MachineInstrBuilder &AddDefaultPred(const MachineInstrBuilder &MIB) { - return MIB.addImm((int64_t)ARMCC::AL).addReg(0); -} - -static inline -const MachineInstrBuilder &AddDefaultCC(const MachineInstrBuilder &MIB) { - return MIB.addReg(0); -} - -ARMBaseInstrInfo::ARMBaseInstrInfo(const ARMSubtarget &STI) - : TargetInstrInfoImpl(ARMInsts, array_lengthof(ARMInsts)) { -} - ARMInstrInfo::ARMInstrInfo(const ARMSubtarget &STI) : ARMBaseInstrInfo(STI), RI(*this, STI) { } -void ARMInstrInfo::reMaterialize(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, - unsigned DestReg, - const MachineInstr *Orig) const { - DebugLoc dl = Orig->getDebugLoc(); - if (Orig->getOpcode() == ARM::MOVi2pieces) { - RI.emitLoadConstPool(MBB, I, this, dl, - DestReg, - Orig->getOperand(1).getImm(), - (ARMCC::CondCodes)Orig->getOperand(2).getImm(), - Orig->getOperand(3).getReg()); - return; - } - - MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); - MI->getOperand(0).setReg(DestReg); - MBB.insert(I, MI); -} - -static unsigned getUnindexedOpcode(unsigned Opc) { +unsigned ARMInstrInfo:: +getUnindexedOpcode(unsigned Opc) const { switch (Opc) { default: break; case ARM::LDR_PRE: @@ -94,820 +58,77 @@ case ARM::STRB_POST: return ARM::STRB; } + return 0; } -MachineInstr * -ARMBaseInstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI, - MachineBasicBlock::iterator &MBBI, - LiveVariables *LV) const { - if (!EnableARM3Addr) - return NULL; - - MachineInstr *MI = MBBI; - MachineFunction &MF = *MI->getParent()->getParent(); - unsigned TSFlags = MI->getDesc().TSFlags; - bool isPre = false; - switch ((TSFlags & ARMII::IndexModeMask) >> ARMII::IndexModeShift) { - default: return NULL; - case ARMII::IndexModePre: - isPre = true; - break; - case ARMII::IndexModePost: - break; - } - - // Try splitting an indexed load/store to an un-indexed one plus an add/sub - // operation. - unsigned MemOpc = getUnindexedOpcode(MI->getOpcode()); - if (MemOpc == 0) - return NULL; - - MachineInstr *UpdateMI = NULL; - MachineInstr *MemMI = NULL; - unsigned AddrMode = (TSFlags & ARMII::AddrModeMask); - const TargetInstrDesc &TID = MI->getDesc(); - unsigned NumOps = TID.getNumOperands(); - bool isLoad = !TID.mayStore(); - const MachineOperand &WB = isLoad ? MI->getOperand(1) : MI->getOperand(0); - const MachineOperand &Base = MI->getOperand(2); - const MachineOperand &Offset = MI->getOperand(NumOps-3); - unsigned WBReg = WB.getReg(); - unsigned BaseReg = Base.getReg(); - unsigned OffReg = Offset.getReg(); - unsigned OffImm = MI->getOperand(NumOps-2).getImm(); - ARMCC::CondCodes Pred = (ARMCC::CondCodes)MI->getOperand(NumOps-1).getImm(); - switch (AddrMode) { +unsigned ARMInstrInfo:: +getOpcode(ARMII::Op Op) const { + switch (Op) { + case ARMII::ADDri: return ARM::ADDri; + case ARMII::ADDrs: return ARM::ADDrs; + case ARMII::ADDrr: return ARM::ADDrr; + case ARMII::B: return ARM::B; + case ARMII::Bcc: return ARM::Bcc; + case ARMII::BR_JTr: return ARM::BR_JTr; + case ARMII::BR_JTm: return ARM::BR_JTm; + case ARMII::BR_JTadd: return ARM::BR_JTadd; + case ARMII::FCPYS: return ARM::FCPYS; + case ARMII::FCPYD: return ARM::FCPYD; + case ARMII::FLDD: return ARM::FLDD; + case ARMII::FLDS: return ARM::FLDS; + case ARMII::FSTD: return ARM::FSTD; + case ARMII::FSTS: return ARM::FSTS; + case ARMII::LDR: return ARM::LDR; + case ARMII::MOVr: return ARM::MOVr; + case ARMII::STR: return ARM::STR; + case ARMII::SUBri: return ARM::SUBri; + case ARMII::SUBrs: return ARM::SUBrs; + case ARMII::SUBrr: return ARM::SUBrr; + case ARMII::VMOVD: return ARM::VMOVD; + case ARMII::VMOVQ: return ARM::VMOVQ; default: - assert(false && "Unknown indexed op!"); - return NULL; - case ARMII::AddrMode2: { - bool isSub = ARM_AM::getAM2Op(OffImm) == ARM_AM::sub; - unsigned Amt = ARM_AM::getAM2Offset(OffImm); - if (OffReg == 0) { - int SOImmVal = ARM_AM::getSOImmVal(Amt); - if (SOImmVal == -1) - // Can't encode it in a so_imm operand. This transformation will - // add more than 1 instruction. Abandon! - return NULL; - UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBri : ARM::ADDri), WBReg) - .addReg(BaseReg).addImm(SOImmVal) - .addImm(Pred).addReg(0).addReg(0); - } else if (Amt != 0) { - ARM_AM::ShiftOpc ShOpc = ARM_AM::getAM2ShiftOpc(OffImm); - unsigned SOOpc = ARM_AM::getSORegOpc(ShOpc, Amt); - UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBrs : ARM::ADDrs), WBReg) - .addReg(BaseReg).addReg(OffReg).addReg(0).addImm(SOOpc) - .addImm(Pred).addReg(0).addReg(0); - } else - UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg) - .addReg(BaseReg).addReg(OffReg) - .addImm(Pred).addReg(0).addReg(0); break; } - case ARMII::AddrMode3 : { - bool isSub = ARM_AM::getAM3Op(OffImm) == ARM_AM::sub; - unsigned Amt = ARM_AM::getAM3Offset(OffImm); - if (OffReg == 0) - // Immediate is 8-bits. It's guaranteed to fit in a so_imm operand. - UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBri : ARM::ADDri), WBReg) - .addReg(BaseReg).addImm(Amt) - .addImm(Pred).addReg(0).addReg(0); - else - UpdateMI = BuildMI(MF, MI->getDebugLoc(), - get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg) - .addReg(BaseReg).addReg(OffReg) - .addImm(Pred).addReg(0).addReg(0); - break; - } - } - - std::vector NewMIs; - if (isPre) { - if (isLoad) - MemMI = BuildMI(MF, MI->getDebugLoc(), - get(MemOpc), MI->getOperand(0).getReg()) - .addReg(WBReg).addReg(0).addImm(0).addImm(Pred); - else - MemMI = BuildMI(MF, MI->getDebugLoc(), - get(MemOpc)).addReg(MI->getOperand(1).getReg()) - .addReg(WBReg).addReg(0).addImm(0).addImm(Pred); - NewMIs.push_back(MemMI); - NewMIs.push_back(UpdateMI); - } else { - if (isLoad) - MemMI = BuildMI(MF, MI->getDebugLoc(), - get(MemOpc), MI->getOperand(0).getReg()) - .addReg(BaseReg).addReg(0).addImm(0).addImm(Pred); - else - MemMI = BuildMI(MF, MI->getDebugLoc(), - get(MemOpc)).addReg(MI->getOperand(1).getReg()) - .addReg(BaseReg).addReg(0).addImm(0).addImm(Pred); - if (WB.isDead()) - UpdateMI->getOperand(0).setIsDead(); - NewMIs.push_back(UpdateMI); - NewMIs.push_back(MemMI); - } - - // Transfer LiveVariables states, kill / dead info. - if (LV) { - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand &MO = MI->getOperand(i); - if (MO.isReg() && MO.getReg() && - TargetRegisterInfo::isVirtualRegister(MO.getReg())) { - unsigned Reg = MO.getReg(); - - LiveVariables::VarInfo &VI = LV->getVarInfo(Reg); - if (MO.isDef()) { - MachineInstr *NewMI = (Reg == WBReg) ? UpdateMI : MemMI; - if (MO.isDead()) - LV->addVirtualRegisterDead(Reg, NewMI); - } - if (MO.isUse() && MO.isKill()) { - for (unsigned j = 0; j < 2; ++j) { - // Look at the two new MI's in reverse order. - MachineInstr *NewMI = NewMIs[j]; - if (!NewMI->readsRegister(Reg)) - continue; - LV->addVirtualRegisterKilled(Reg, NewMI); - if (VI.removeKill(MI)) - VI.Kills.push_back(NewMI); - break; - } - } - } - } - } - - MFI->insert(MBBI, NewMIs[1]); - MFI->insert(MBBI, NewMIs[0]); - return NewMIs[0]; -} - -// Branch analysis. -bool -ARMBaseInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB, - MachineBasicBlock *&FBB, - SmallVectorImpl &Cond, - bool AllowModify) const { - // If the block has no terminators, it just falls into the block after it. - MachineBasicBlock::iterator I = MBB.end(); - if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) - return false; - - // Get the last instruction in the block. - MachineInstr *LastInst = I; - - // If there is only one terminator instruction, process it. - unsigned LastOpc = LastInst->getOpcode(); - if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) { - if (LastOpc == ARM::B || LastOpc == ARM::tB || LastOpc == ARM::t2B) { - TBB = LastInst->getOperand(0).getMBB(); - return false; - } - if (LastOpc == ARM::Bcc || LastOpc == ARM::tBcc || LastOpc == ARM::t2Bcc) { - // Block ends with fall-through condbranch. - TBB = LastInst->getOperand(0).getMBB(); - Cond.push_back(LastInst->getOperand(1)); - Cond.push_back(LastInst->getOperand(2)); - return false; - } - return true; // Can't handle indirect branch. - } - - // Get the instruction before it if it is a terminator. - MachineInstr *SecondLastInst = I; - - // If there are three terminators, we don't know what sort of block this is. - if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(--I)) - return true; - - // If the block ends with ARM::B/ARM::tB/ARM::t2B and a - // ARM::Bcc/ARM::tBcc/ARM::t2Bcc, handle it. - unsigned SecondLastOpc = SecondLastInst->getOpcode(); - if ((SecondLastOpc == ARM::Bcc && LastOpc == ARM::B) || - (SecondLastOpc == ARM::tBcc && LastOpc == ARM::tB) || - (SecondLastOpc == ARM::t2Bcc && LastOpc == ARM::t2B)) { - TBB = SecondLastInst->getOperand(0).getMBB(); - Cond.push_back(SecondLastInst->getOperand(1)); - Cond.push_back(SecondLastInst->getOperand(2)); - FBB = LastInst->getOperand(0).getMBB(); - return false; - } - - // If the block ends with two unconditional branches, handle it. The second - // one is not executed, so remove it. - if ((SecondLastOpc == ARM::B || SecondLastOpc==ARM::tB || - SecondLastOpc==ARM::t2B) && - (LastOpc == ARM::B || LastOpc == ARM::tB || LastOpc == ARM::t2B)) { - TBB = SecondLastInst->getOperand(0).getMBB(); - I = LastInst; - if (AllowModify) - I->eraseFromParent(); - return false; - } - - // ...likewise if it ends with a branch table followed by an unconditional - // branch. The branch folder can create these, and we must get rid of them for - // correctness of Thumb constant islands. - if ((SecondLastOpc == ARM::BR_JTr || SecondLastOpc==ARM::BR_JTm || - SecondLastOpc == ARM::BR_JTadd || SecondLastOpc==ARM::tBR_JTr || - SecondLastOpc == ARM::t2BR_JTr || SecondLastOpc==ARM::t2BR_JTm || - SecondLastOpc == ARM::t2BR_JTadd) && - (LastOpc == ARM::B || LastOpc == ARM::tB || LastOpc == ARM::t2B)) { - I = LastInst; - if (AllowModify) - I->eraseFromParent(); - return true; - } - - // Otherwise, can't handle this. - return true; -} - - -unsigned ARMBaseInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const { - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo(); - int BOpc = AFI->isThumbFunction() ? - (AFI->isThumb2Function() ? ARM::t2B : ARM::tB) : ARM::B; - int BccOpc = AFI->isThumbFunction() ? - (AFI->isThumb2Function() ? ARM::t2Bcc : ARM::tBcc) : ARM::Bcc; - MachineBasicBlock::iterator I = MBB.end(); - if (I == MBB.begin()) return 0; - --I; - if (I->getOpcode() != BOpc && I->getOpcode() != BccOpc) - return 0; - - // Remove the branch. - I->eraseFromParent(); - - I = MBB.end(); - - if (I == MBB.begin()) return 1; - --I; - if (I->getOpcode() != BccOpc) - return 1; - - // Remove the branch. - I->eraseFromParent(); - return 2; -} - -unsigned -ARMBaseInstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, - MachineBasicBlock *FBB, - const SmallVectorImpl &Cond) const { - // FIXME this should probably have a DebugLoc argument - DebugLoc dl = DebugLoc::getUnknownLoc(); - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo(); - int BOpc = AFI->isThumbFunction() ? - (AFI->isThumb2Function() ? ARM::t2B : ARM::tB) : ARM::B; - int BccOpc = AFI->isThumbFunction() ? - (AFI->isThumb2Function() ? ARM::t2Bcc : ARM::tBcc) : ARM::Bcc; - - // Shouldn't be a fall through. - assert(TBB && "InsertBranch must not be told to insert a fallthrough"); - assert((Cond.size() == 2 || Cond.size() == 0) && - "ARM branch conditions have two components!"); - - if (FBB == 0) { - if (Cond.empty()) // Unconditional branch? - BuildMI(&MBB, dl, get(BOpc)).addMBB(TBB); - else - BuildMI(&MBB, dl, get(BccOpc)).addMBB(TBB) - .addImm(Cond[0].getImm()).addReg(Cond[1].getReg()); - return 1; - } - - // Two-way conditional branch. - BuildMI(&MBB, dl, get(BccOpc)).addMBB(TBB) - .addImm(Cond[0].getImm()).addReg(Cond[1].getReg()); - BuildMI(&MBB, dl, get(BOpc)).addMBB(FBB); - return 2; + return 0; } -bool -ARMBaseInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { +bool ARMInstrInfo:: +BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { if (MBB.empty()) return false; switch (MBB.back().getOpcode()) { case ARM::BX_RET: // Return. case ARM::LDM_RET: - case ARM::tBX_RET: - case ARM::tBX_RET_vararg: - case ARM::tPOP_RET: case ARM::B: - case ARM::tB: - case ARM::t2B: // Uncond branch. - case ARM::tBR_JTr: - case ARM::t2BR_JTr: case ARM::BR_JTr: // Jumptable branch. - case ARM::t2BR_JTm: case ARM::BR_JTm: // Jumptable branch through mem. - case ARM::t2BR_JTadd: case ARM::BR_JTadd: // Jumptable branch add to pc. return true; - default: return false; - } -} - -bool ARMBaseInstrInfo:: -ReverseBranchCondition(SmallVectorImpl &Cond) const { - ARMCC::CondCodes CC = (ARMCC::CondCodes)(int)Cond[0].getImm(); - Cond[0].setImm(ARMCC::getOppositeCondition(CC)); - return false; -} - -bool ARMBaseInstrInfo::isPredicated(const MachineInstr *MI) const { - int PIdx = MI->findFirstPredOperandIdx(); - return PIdx != -1 && MI->getOperand(PIdx).getImm() != ARMCC::AL; -} - -bool ARMBaseInstrInfo:: -PredicateInstruction(MachineInstr *MI, - const SmallVectorImpl &Pred) const { - unsigned Opc = MI->getOpcode(); - if (Opc == ARM::B || Opc == ARM::tB || Opc == ARM::t2B) { - MI->setDesc(get((Opc == ARM::B) ? ARM::Bcc : - ((Opc == ARM::tB) ? ARM::tBcc : ARM::t2Bcc))); - MI->addOperand(MachineOperand::CreateImm(Pred[0].getImm())); - MI->addOperand(MachineOperand::CreateReg(Pred[1].getReg(), false)); - return true; - } - - int PIdx = MI->findFirstPredOperandIdx(); - if (PIdx != -1) { - MachineOperand &PMO = MI->getOperand(PIdx); - PMO.setImm(Pred[0].getImm()); - MI->getOperand(PIdx+1).setReg(Pred[1].getReg()); - return true; - } - return false; -} - -bool ARMBaseInstrInfo:: -SubsumesPredicate(const SmallVectorImpl &Pred1, - const SmallVectorImpl &Pred2) const { - if (Pred1.size() > 2 || Pred2.size() > 2) - return false; - - ARMCC::CondCodes CC1 = (ARMCC::CondCodes)Pred1[0].getImm(); - ARMCC::CondCodes CC2 = (ARMCC::CondCodes)Pred2[0].getImm(); - if (CC1 == CC2) - return true; - - switch (CC1) { - default: - return false; - case ARMCC::AL: - return true; - case ARMCC::HS: - return CC2 == ARMCC::HI; - case ARMCC::LS: - return CC2 == ARMCC::LO || CC2 == ARMCC::EQ; - case ARMCC::GE: - return CC2 == ARMCC::GT; - case ARMCC::LE: - return CC2 == ARMCC::LT; - } -} - -bool ARMBaseInstrInfo::DefinesPredicate(MachineInstr *MI, - std::vector &Pred) const { - const TargetInstrDesc &TID = MI->getDesc(); - if (!TID.getImplicitDefs() && !TID.hasOptionalDef()) - return false; - - bool Found = false; - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = MI->getOperand(i); - if (MO.isReg() && MO.getReg() == ARM::CPSR) { - Pred.push_back(MO); - Found = true; - } - } - - return Found; -} - - -/// FIXME: Works around a gcc miscompilation with -fstrict-aliasing -static unsigned getNumJTEntries(const std::vector &JT, - unsigned JTI) DISABLE_INLINE; -static unsigned getNumJTEntries(const std::vector &JT, - unsigned JTI) { - return JT[JTI].MBBs.size(); -} - -/// GetInstSize - Return the size of the specified MachineInstr. -/// -unsigned ARMBaseInstrInfo::GetInstSizeInBytes(const MachineInstr *MI) const { - const MachineBasicBlock &MBB = *MI->getParent(); - const MachineFunction *MF = MBB.getParent(); - const TargetAsmInfo *TAI = MF->getTarget().getTargetAsmInfo(); - - // Basic size info comes from the TSFlags field. - const TargetInstrDesc &TID = MI->getDesc(); - unsigned TSFlags = TID.TSFlags; - - switch ((TSFlags & ARMII::SizeMask) >> ARMII::SizeShift) { - default: { - // If this machine instr is an inline asm, measure it. - if (MI->getOpcode() == ARM::INLINEASM) - return TAI->getInlineAsmLength(MI->getOperand(0).getSymbolName()); - if (MI->isLabel()) - return 0; - switch (MI->getOpcode()) { - default: - assert(0 && "Unknown or unset size field for instr!"); - break; - case TargetInstrInfo::IMPLICIT_DEF: - case TargetInstrInfo::DECLARE: - case TargetInstrInfo::DBG_LABEL: - case TargetInstrInfo::EH_LABEL: - return 0; - } - break; - } - case ARMII::Size8Bytes: return 8; // Arm instruction x 2. - case ARMII::Size4Bytes: return 4; // Arm instruction. - case ARMII::Size2Bytes: return 2; // Thumb instruction. - case ARMII::SizeSpecial: { - switch (MI->getOpcode()) { - case ARM::CONSTPOOL_ENTRY: - // If this machine instr is a constant pool entry, its size is recorded as - // operand #2. - return MI->getOperand(2).getImm(); - case ARM::Int_eh_sjlj_setjmp: return 12; - case ARM::BR_JTr: - case ARM::BR_JTm: - case ARM::BR_JTadd: - case ARM::t2BR_JTr: - case ARM::t2BR_JTm: - case ARM::t2BR_JTadd: - case ARM::tBR_JTr: { - // These are jumptable branches, i.e. a branch followed by an inlined - // jumptable. The size is 4 + 4 * number of entries. - unsigned NumOps = TID.getNumOperands(); - MachineOperand JTOP = - MI->getOperand(NumOps - (TID.isPredicable() ? 3 : 2)); - unsigned JTI = JTOP.getIndex(); - const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo(); - const std::vector &JT = MJTI->getJumpTables(); - assert(JTI < JT.size()); - // Thumb instructions are 2 byte aligned, but JT entries are 4 byte - // 4 aligned. The assembler / linker may add 2 byte padding just before - // the JT entries. The size does not include this padding; the - // constant islands pass does separate bookkeeping for it. - // FIXME: If we know the size of the function is less than (1 << 16) *2 - // bytes, we can use 16-bit entries instead. Then there won't be an - // alignment issue. - return getNumJTEntries(JT, JTI) * 4 + - ((MI->getOpcode()==ARM::tBR_JTr) ? 2 : 4); - } - default: - // Otherwise, pseudo-instruction sizes are zero. - return 0; - } - } - } - return 0; // Not reached -} - -/// Return true if the instruction is a register to register move and -/// leave the source and dest operands in the passed parameters. -/// -bool -ARMBaseInstrInfo::isMoveInstr(const MachineInstr &MI, - unsigned &SrcReg, unsigned &DstReg, - unsigned& SrcSubIdx, unsigned& DstSubIdx) const { - SrcSubIdx = DstSubIdx = 0; // No sub-registers. - - unsigned oc = MI.getOpcode(); - switch (oc) { default: - return false; - case ARM::FCPYS: - case ARM::FCPYD: - case ARM::VMOVD: - case ARM::VMOVQ: - SrcReg = MI.getOperand(1).getReg(); - DstReg = MI.getOperand(0).getReg(); - return true; - case ARM::MOVr: - assert(MI.getDesc().getNumOperands() >= 2 && - MI.getOperand(0).isReg() && - MI.getOperand(1).isReg() && - "Invalid ARM MOV instruction"); - SrcReg = MI.getOperand(1).getReg(); - DstReg = MI.getOperand(0).getReg(); - return true; - } -} - -unsigned -ARMBaseInstrInfo::isLoadFromStackSlot(const MachineInstr *MI, - int &FrameIndex) const { - switch (MI->getOpcode()) { - default: break; - case ARM::LDR: - if (MI->getOperand(1).isFI() && - MI->getOperand(2).isReg() && - MI->getOperand(3).isImm() && - MI->getOperand(2).getReg() == 0 && - MI->getOperand(3).getImm() == 0) { - FrameIndex = MI->getOperand(1).getIndex(); - return MI->getOperand(0).getReg(); - } - break; - case ARM::FLDD: - case ARM::FLDS: - if (MI->getOperand(1).isFI() && - MI->getOperand(2).isImm() && - MI->getOperand(2).getImm() == 0) { - FrameIndex = MI->getOperand(1).getIndex(); - return MI->getOperand(0).getReg(); - } - break; - } - return 0; -} - -unsigned -ARMBaseInstrInfo::isStoreToStackSlot(const MachineInstr *MI, - int &FrameIndex) const { - switch (MI->getOpcode()) { - default: break; - case ARM::STR: - if (MI->getOperand(1).isFI() && - MI->getOperand(2).isReg() && - MI->getOperand(3).isImm() && - MI->getOperand(2).getReg() == 0 && - MI->getOperand(3).getImm() == 0) { - FrameIndex = MI->getOperand(1).getIndex(); - return MI->getOperand(0).getReg(); - } - break; - case ARM::FSTD: - case ARM::FSTS: - if (MI->getOperand(1).isFI() && - MI->getOperand(2).isImm() && - MI->getOperand(2).getImm() == 0) { - FrameIndex = MI->getOperand(1).getIndex(); - return MI->getOperand(0).getReg(); - } - break; - } - - return 0; -} - -bool -ARMBaseInstrInfo::copyRegToReg(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, - unsigned DestReg, unsigned SrcReg, - const TargetRegisterClass *DestRC, - const TargetRegisterClass *SrcRC) const { - DebugLoc DL = DebugLoc::getUnknownLoc(); - if (I != MBB.end()) DL = I->getDebugLoc(); - - if (DestRC != SrcRC) { - // Not yet supported! - return false; - } - - if (DestRC == ARM::GPRRegisterClass) - AddDefaultCC(AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::MOVr), DestReg) - .addReg(SrcReg))); - else if (DestRC == ARM::SPRRegisterClass) - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FCPYS), DestReg) - .addReg(SrcReg)); - else if (DestRC == ARM::DPRRegisterClass) - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FCPYD), DestReg) - .addReg(SrcReg)); - else if (DestRC == ARM::QPRRegisterClass) - BuildMI(MBB, I, DL, get(ARM::VMOVQ), DestReg).addReg(SrcReg); - else - return false; - - return true; -} - -void ARMBaseInstrInfo:: -storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, - unsigned SrcReg, bool isKill, int FI, - const TargetRegisterClass *RC) const { - DebugLoc DL = DebugLoc::getUnknownLoc(); - if (I != MBB.end()) DL = I->getDebugLoc(); - - if (RC == ARM::GPRRegisterClass) { - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::STR)) - .addReg(SrcReg, getKillRegState(isKill)) - .addFrameIndex(FI).addReg(0).addImm(0)); - } else if (RC == ARM::DPRRegisterClass) { - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FSTD)) - .addReg(SrcReg, getKillRegState(isKill)) - .addFrameIndex(FI).addImm(0)); - } else { - assert(RC == ARM::SPRRegisterClass && "Unknown regclass!"); - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FSTS)) - .addReg(SrcReg, getKillRegState(isKill)) - .addFrameIndex(FI).addImm(0)); - } -} - -void -ARMBaseInstrInfo::storeRegToAddr(MachineFunction &MF, unsigned SrcReg, - bool isKill, - SmallVectorImpl &Addr, - const TargetRegisterClass *RC, - SmallVectorImpl &NewMIs) const{ - DebugLoc DL = DebugLoc::getUnknownLoc(); - unsigned Opc = 0; - if (RC == ARM::GPRRegisterClass) { - Opc = ARM::STR; - } else if (RC == ARM::DPRRegisterClass) { - Opc = ARM::FSTD; - } else { - assert(RC == ARM::SPRRegisterClass && "Unknown regclass!"); - Opc = ARM::FSTS; - } - - MachineInstrBuilder MIB = - BuildMI(MF, DL, get(Opc)).addReg(SrcReg, getKillRegState(isKill)); - for (unsigned i = 0, e = Addr.size(); i != e; ++i) - MIB.addOperand(Addr[i]); - AddDefaultPred(MIB); - NewMIs.push_back(MIB); - return; -} - -void ARMBaseInstrInfo:: -loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, - unsigned DestReg, int FI, - const TargetRegisterClass *RC) const { - DebugLoc DL = DebugLoc::getUnknownLoc(); - if (I != MBB.end()) DL = I->getDebugLoc(); - - if (RC == ARM::GPRRegisterClass) { - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::LDR), DestReg) - .addFrameIndex(FI).addReg(0).addImm(0)); - } else if (RC == ARM::DPRRegisterClass) { - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FLDD), DestReg) - .addFrameIndex(FI).addImm(0)); - } else { - assert(RC == ARM::SPRRegisterClass && "Unknown regclass!"); - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FLDS), DestReg) - .addFrameIndex(FI).addImm(0)); - } -} - -void ARMBaseInstrInfo:: -loadRegFromAddr(MachineFunction &MF, unsigned DestReg, - SmallVectorImpl &Addr, - const TargetRegisterClass *RC, - SmallVectorImpl &NewMIs) const { - DebugLoc DL = DebugLoc::getUnknownLoc(); - unsigned Opc = 0; - if (RC == ARM::GPRRegisterClass) { - Opc = ARM::LDR; - } else if (RC == ARM::DPRRegisterClass) { - Opc = ARM::FLDD; - } else { - assert(RC == ARM::SPRRegisterClass && "Unknown regclass!"); - Opc = ARM::FLDS; - } - - MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc), DestReg); - for (unsigned i = 0, e = Addr.size(); i != e; ++i) - MIB.addOperand(Addr[i]); - AddDefaultPred(MIB); - NewMIs.push_back(MIB); - return; -} - -MachineInstr *ARMBaseInstrInfo:: -foldMemoryOperandImpl(MachineFunction &MF, MachineInstr *MI, - const SmallVectorImpl &Ops, int FI) const { - if (Ops.size() != 1) return NULL; - - unsigned OpNum = Ops[0]; - unsigned Opc = MI->getOpcode(); - MachineInstr *NewMI = NULL; - switch (Opc) { - default: break; - case ARM::MOVr: { - if (MI->getOperand(4).getReg() == ARM::CPSR) - // If it is updating CPSR, then it cannot be folded. - break; - unsigned Pred = MI->getOperand(2).getImm(); - unsigned PredReg = MI->getOperand(3).getReg(); - if (OpNum == 0) { // move -> store - unsigned SrcReg = MI->getOperand(1).getReg(); - bool isKill = MI->getOperand(1).isKill(); - bool isUndef = MI->getOperand(1).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::STR)) - .addReg(SrcReg, getKillRegState(isKill) | getUndefRegState(isUndef)) - .addFrameIndex(FI).addReg(0).addImm(0).addImm(Pred).addReg(PredReg); - } else { // move -> load - unsigned DstReg = MI->getOperand(0).getReg(); - bool isDead = MI->getOperand(0).isDead(); - bool isUndef = MI->getOperand(0).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::LDR)) - .addReg(DstReg, - RegState::Define | - getDeadRegState(isDead) | - getUndefRegState(isUndef)) - .addFrameIndex(FI).addReg(0).addImm(0).addImm(Pred).addReg(PredReg); - } - break; - } - case ARM::FCPYS: { - unsigned Pred = MI->getOperand(2).getImm(); - unsigned PredReg = MI->getOperand(3).getReg(); - if (OpNum == 0) { // move -> store - unsigned SrcReg = MI->getOperand(1).getReg(); - bool isKill = MI->getOperand(1).isKill(); - bool isUndef = MI->getOperand(1).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::FSTS)) - .addReg(SrcReg, getKillRegState(isKill) | getUndefRegState(isUndef)) - .addFrameIndex(FI) - .addImm(0).addImm(Pred).addReg(PredReg); - } else { // move -> load - unsigned DstReg = MI->getOperand(0).getReg(); - bool isDead = MI->getOperand(0).isDead(); - bool isUndef = MI->getOperand(0).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::FLDS)) - .addReg(DstReg, - RegState::Define | - getDeadRegState(isDead) | - getUndefRegState(isUndef)) - .addFrameIndex(FI).addImm(0).addImm(Pred).addReg(PredReg); - } - break; - } - case ARM::FCPYD: { - unsigned Pred = MI->getOperand(2).getImm(); - unsigned PredReg = MI->getOperand(3).getReg(); - if (OpNum == 0) { // move -> store - unsigned SrcReg = MI->getOperand(1).getReg(); - bool isKill = MI->getOperand(1).isKill(); - bool isUndef = MI->getOperand(1).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::FSTD)) - .addReg(SrcReg, getKillRegState(isKill) | getUndefRegState(isUndef)) - .addFrameIndex(FI).addImm(0).addImm(Pred).addReg(PredReg); - } else { // move -> load - unsigned DstReg = MI->getOperand(0).getReg(); - bool isDead = MI->getOperand(0).isDead(); - bool isUndef = MI->getOperand(0).isUndef(); - NewMI = BuildMI(MF, MI->getDebugLoc(), get(ARM::FLDD)) - .addReg(DstReg, - RegState::Define | - getDeadRegState(isDead) | - getUndefRegState(isUndef)) - .addFrameIndex(FI).addImm(0).addImm(Pred).addReg(PredReg); - } break; } - } - - return NewMI; -} -MachineInstr* -ARMBaseInstrInfo::foldMemoryOperandImpl(MachineFunction &MF, - MachineInstr* MI, - const SmallVectorImpl &Ops, - MachineInstr* LoadMI) const { - return 0; + return false; } -bool -ARMBaseInstrInfo::canFoldMemoryOperand(const MachineInstr *MI, - const SmallVectorImpl &Ops) const { - if (Ops.size() != 1) return false; - - unsigned Opc = MI->getOpcode(); - switch (Opc) { - default: break; - case ARM::MOVr: - // If it is updating CPSR, then it cannot be folded. - return MI->getOperand(4).getReg() != ARM::CPSR; - case ARM::FCPYS: - case ARM::FCPYD: - return true; - - case ARM::VMOVD: - case ARM::VMOVQ: - return false; // FIXME +void ARMInstrInfo:: +reMaterialize(MachineBasicBlock &MBB, + MachineBasicBlock::iterator I, + unsigned DestReg, + const MachineInstr *Orig) const { + DebugLoc dl = Orig->getDebugLoc(); + if (Orig->getOpcode() == ARM::MOVi2pieces) { + RI.emitLoadConstPool(MBB, I, this, dl, + DestReg, + Orig->getOperand(1).getImm(), + (ARMCC::CondCodes)Orig->getOperand(2).getImm(), + Orig->getOperand(3).getReg()); + return; } - return false; + MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); + MI->getOperand(0).setReg(DestReg); + MBB.insert(I, MI); } Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.h?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Wed Jul 8 11:09:28 2009 @@ -15,251 +15,29 @@ #define ARMINSTRUCTIONINFO_H #include "llvm/Target/TargetInstrInfo.h" +#include "ARMBaseInstrInfo.h" #include "ARMRegisterInfo.h" +#include "ARMSubtarget.h" #include "ARM.h" namespace llvm { class ARMSubtarget; -/// ARMII - This namespace holds all of the target specific flags that -/// instruction info tracks. -/// -namespace ARMII { - enum { - //===------------------------------------------------------------------===// - // Instruction Flags. - - //===------------------------------------------------------------------===// - // This four-bit field describes the addressing mode used. - - AddrModeMask = 0xf, - AddrModeNone = 0, - AddrMode1 = 1, - AddrMode2 = 2, - AddrMode3 = 3, - AddrMode4 = 4, - AddrMode5 = 5, - AddrMode6 = 6, - AddrModeT1_1 = 7, - AddrModeT1_2 = 8, - AddrModeT1_4 = 9, - AddrModeT1_s = 10, // i8 * 4 for pc and sp relative data - AddrModeT2_i12 = 11, - AddrModeT2_i8 = 12, - AddrModeT2_so = 13, - AddrModeT2_pc = 14, // +/- i12 for pc relative data - AddrModeT2_i8s4 = 15, // i8 * 4 - - // Size* - Flags to keep track of the size of an instruction. - SizeShift = 4, - SizeMask = 7 << SizeShift, - SizeSpecial = 1, // 0 byte pseudo or special case. - Size8Bytes = 2, - Size4Bytes = 3, - Size2Bytes = 4, - - // IndexMode - Unindex, pre-indexed, or post-indexed. Only valid for load - // and store ops - IndexModeShift = 7, - IndexModeMask = 3 << IndexModeShift, - IndexModePre = 1, - IndexModePost = 2, - - //===------------------------------------------------------------------===// - // Instruction encoding formats. - // - FormShift = 9, - FormMask = 0x3f << FormShift, - - // Pseudo instructions - Pseudo = 0 << FormShift, - - // Multiply instructions - MulFrm = 1 << FormShift, - - // Branch instructions - BrFrm = 2 << FormShift, - BrMiscFrm = 3 << FormShift, - - // Data Processing instructions - DPFrm = 4 << FormShift, - DPSoRegFrm = 5 << FormShift, - - // Load and Store - LdFrm = 6 << FormShift, - StFrm = 7 << FormShift, - LdMiscFrm = 8 << FormShift, - StMiscFrm = 9 << FormShift, - LdStMulFrm = 10 << FormShift, - - // Miscellaneous arithmetic instructions - ArithMiscFrm = 11 << FormShift, - - // Extend instructions - ExtFrm = 12 << FormShift, - - // VFP formats - VFPUnaryFrm = 13 << FormShift, - VFPBinaryFrm = 14 << FormShift, - VFPConv1Frm = 15 << FormShift, - VFPConv2Frm = 16 << FormShift, - VFPConv3Frm = 17 << FormShift, - VFPConv4Frm = 18 << FormShift, - VFPConv5Frm = 19 << FormShift, - VFPLdStFrm = 20 << FormShift, - VFPLdStMulFrm = 21 << FormShift, - VFPMiscFrm = 22 << FormShift, - - // Thumb format - ThumbFrm = 23 << FormShift, - - // NEON format - NEONFrm = 24 << FormShift, - NEONGetLnFrm = 25 << FormShift, - NEONSetLnFrm = 26 << FormShift, - NEONDupFrm = 27 << FormShift, - - //===------------------------------------------------------------------===// - // Misc flags. - - // UnaryDP - Indicates this is a unary data processing instruction, i.e. - // it doesn't have a Rn operand. - UnaryDP = 1 << 15, - - // Xform16Bit - Indicates this Thumb2 instruction may be transformed into - // a 16-bit Thumb instruction if certain conditions are met. - Xform16Bit = 1 << 16, - - //===------------------------------------------------------------------===// - // Field shifts - such shifts are used to set field while generating - // machine instructions. - M_BitShift = 5, - ShiftImmShift = 5, - ShiftShift = 7, - N_BitShift = 7, - ImmHiShift = 8, - SoRotImmShift = 8, - RegRsShift = 8, - ExtRotImmShift = 10, - RegRdLoShift = 12, - RegRdShift = 12, - RegRdHiShift = 16, - RegRnShift = 16, - S_BitShift = 20, - W_BitShift = 21, - AM3_I_BitShift = 22, - D_BitShift = 22, - U_BitShift = 23, - P_BitShift = 24, - I_BitShift = 25, - CondShift = 28 - }; -} - -class ARMBaseInstrInfo : public TargetInstrInfoImpl { -protected: - // Can be only subclassed. - explicit ARMBaseInstrInfo(const ARMSubtarget &STI); -public: - virtual MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI, - MachineBasicBlock::iterator &MBBI, - LiveVariables *LV) const; - - virtual const ARMBaseRegisterInfo &getRegisterInfo() const =0; - - // Branch analysis. - virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, - MachineBasicBlock *&FBB, - SmallVectorImpl &Cond, - bool AllowModify) const; - virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const; - virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, - MachineBasicBlock *FBB, - const SmallVectorImpl &Cond) const; - - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; - virtual - bool ReverseBranchCondition(SmallVectorImpl &Cond) const; - - // Predication support. - virtual bool isPredicated(const MachineInstr *MI) const; - - ARMCC::CondCodes getPredicate(const MachineInstr *MI) const { - int PIdx = MI->findFirstPredOperandIdx(); - return PIdx != -1 ? (ARMCC::CondCodes)MI->getOperand(PIdx).getImm() - : ARMCC::AL; - } - - virtual - bool PredicateInstruction(MachineInstr *MI, - const SmallVectorImpl &Pred) const; - - virtual - bool SubsumesPredicate(const SmallVectorImpl &Pred1, - const SmallVectorImpl &Pred2) const; - - virtual bool DefinesPredicate(MachineInstr *MI, - std::vector &Pred) const; - - /// GetInstSize - Returns the size of the specified MachineInstr. - /// - virtual unsigned GetInstSizeInBytes(const MachineInstr* MI) const; - - /// Return true if the instruction is a register to register move and return - /// the source and dest operands and their sub-register indices by reference. - virtual bool isMoveInstr(const MachineInstr &MI, - unsigned &SrcReg, unsigned &DstReg, - unsigned &SrcSubIdx, unsigned &DstSubIdx) const; - - virtual unsigned isLoadFromStackSlot(const MachineInstr *MI, - int &FrameIndex) const; - virtual unsigned isStoreToStackSlot(const MachineInstr *MI, - int &FrameIndex) const; - - virtual bool copyRegToReg(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, - unsigned DestReg, unsigned SrcReg, - const TargetRegisterClass *DestRC, - const TargetRegisterClass *SrcRC) const; - virtual void storeRegToStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MBBI, - unsigned SrcReg, bool isKill, int FrameIndex, - const TargetRegisterClass *RC) const; - - virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill, - SmallVectorImpl &Addr, - const TargetRegisterClass *RC, - SmallVectorImpl &NewMIs) const; - - virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MBBI, - unsigned DestReg, int FrameIndex, - const TargetRegisterClass *RC) const; - - virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg, - SmallVectorImpl &Addr, - const TargetRegisterClass *RC, - SmallVectorImpl &NewMIs) const; - - virtual bool canFoldMemoryOperand(const MachineInstr *MI, - const SmallVectorImpl &Ops) const; - - virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, - MachineInstr* MI, - const SmallVectorImpl &Ops, - int FrameIndex) const; - - virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, - MachineInstr* MI, - const SmallVectorImpl &Ops, - MachineInstr* LoadMI) const; -}; - class ARMInstrInfo : public ARMBaseInstrInfo { ARMRegisterInfo RI; public: explicit ARMInstrInfo(const ARMSubtarget &STI); + // Return the non-pre/post incrementing version of 'Opc'. Return 0 + // if there is not such an opcode. + unsigned getUnindexedOpcode(unsigned Opc) const; + + // Return the opcode that implements 'Op', or 0 if no opcode + unsigned getOpcode(ARMII::Op Op) const; + + // Return true if the block does not fall through. + bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; + /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should /// always be able to get register info as well (through this method). Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Wed Jul 8 11:09:28 2009 @@ -157,29 +157,29 @@ let isReturn = 1, isTerminator = 1 in { def tBX_RET : TI<(outs), (ins), "bx lr", [(ARMretflag)]>; // Alternative return instruction used by vararg functions. - def tBX_RET_vararg : TI<(outs), (ins tGPR:$target), "bx $target", []>; + def tBX_RET_vararg : T1I<(outs), (ins tGPR:$target), "bx $target", []>; } // FIXME: remove when we have a way to marking a MI with these properties. let isReturn = 1, isTerminator = 1 in -def tPOP_RET : TI<(outs reglist:$dst1, variable_ops), (ins), +def tPOP_RET : T1I<(outs reglist:$dst1, variable_ops), (ins), "pop $dst1", []>; let isCall = 1, Defs = [R0, R1, R2, R3, LR, D0, D1, D2, D3, D4, D5, D6, D7] in { - def tBL : TIx2<(outs), (ins i32imm:$func, variable_ops), + def tBL : T1Ix2<(outs), (ins i32imm:$func, variable_ops), "bl ${func:call}", [(ARMtcall tglobaladdr:$func)]>; // ARMv5T and above - def tBLXi : TIx2<(outs), (ins i32imm:$func, variable_ops), + def tBLXi : T1Ix2<(outs), (ins i32imm:$func, variable_ops), "blx ${func:call}", [(ARMcall tglobaladdr:$func)]>, Requires<[HasV5T]>; - def tBLXr : TI<(outs), (ins tGPR:$func, variable_ops), + def tBLXr : T1I<(outs), (ins tGPR:$func, variable_ops), "blx $func", [(ARMtcall tGPR:$func)]>, Requires<[HasV5T]>; // ARMv4T - def tBX : TIx2<(outs), (ins tGPR:$func, variable_ops), + def tBX : T1Ix2<(outs), (ins tGPR:$func, variable_ops), "cpy lr, pc\n\tbx $func", [(ARMcall_nolink tGPR:$func)]>; } @@ -284,11 +284,11 @@ // TODO: A7-44: LDMIA - load multiple let mayLoad = 1 in -def tPOP : TI<(outs reglist:$dst1, variable_ops), (ins), +def tPOP : T1I<(outs reglist:$dst1, variable_ops), (ins), "pop $dst1", []>; let mayStore = 1 in -def tPUSH : TI<(outs), (ins reglist:$src1, variable_ops), +def tPUSH : T1I<(outs), (ins reglist:$src1, variable_ops), "push $src1", []>; //===----------------------------------------------------------------------===// @@ -577,14 +577,14 @@ // tLEApcrel - Load a pc-relative address into a register without offending the // assembler. -def tLEApcrel : TIx2<(outs tGPR:$dst), (ins i32imm:$label), +def tLEApcrel : T1Ix2<(outs tGPR:$dst), (ins i32imm:$label), !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(", "${:private}PCRELL${:uid}+4))\n"), !strconcat("\tmov $dst, #PCRELV${:uid}\n", "${:private}PCRELL${:uid}:\n\tadd $dst, pc")), []>; -def tLEApcrelJT : TIx2<(outs tGPR:$dst), (ins i32imm:$label, i32imm:$id), +def tLEApcrelJT : T1Ix2<(outs tGPR:$dst), (ins i32imm:$label, i32imm:$id), !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(", "${:private}PCRELL${:uid}+4))\n"), !strconcat("\tmov $dst, #PCRELV${:uid}\n", @@ -598,7 +598,7 @@ // __aeabi_read_tp preserves the registers r1-r3. let isCall = 1, Defs = [R0, LR] in { - def tTPsoft : TIx2<(outs), (ins), + def tTPsoft : T1Ix2<(outs), (ins), "bl __aeabi_read_tp", [(set R0, ARMthread_pointer)]>; } Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Wed Jul 8 11:09:28 2009 @@ -1048,9 +1048,50 @@ RegConstraint<"$false = $dst">; //===----------------------------------------------------------------------===// +// TLS Instructions +// + +// __aeabi_read_tp preserves the registers r1-r3. +let isCall = 1, + Defs = [R0, R12, LR, CPSR] in { + def t2TPsoft : T2XI<(outs), (ins), + "bl __aeabi_read_tp", + [(set R0, ARMthread_pointer)]>; +} + +//===----------------------------------------------------------------------===// // Control-Flow Instructions // +//let isReturn = 1, isTerminator = 1 in +// def t2BX_RET : T2XI<(outs), (ins), "bx lr", [(ARMretflag)]>; +// +// On non-Darwin platforms R9 is callee-saved. +//let isCall = 1, +// Defs = [R0, R1, R2, R3, R12, LR, +// D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in { +//def t2BL : T2XI<(outs), (ins i32imm:$func, variable_ops), +// "bl ${func:call}", +// [(ARMcall tglobaladdr:$func)]>, Requires<[IsNotDarwin]>; +// +//def t2BLX : T2XI<(outs), (ins GPR:$func, variable_ops), +// "blx $func", +// [(ARMcall GPR:$func)]>, Requires<[IsNotDarwin]>; +//} + +// On Darwin R9 is call-clobbered. +//let isCall = 1, +// Defs = [R0, R1, R2, R3, R9, R12, LR, +// D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in { +//def t2BLr9 : T2XI<(outs), (ins i32imm:$func, variable_ops), +// "bl ${func:call}", +// [(ARMcall tglobaladdr:$func)]>, Requires<[IsDarwin]>; +// +//def t2BLXr9 : T2XI<(outs), (ins GPR:$func, variable_ops), +// "blx $func", +// [(ARMcall GPR:$func)]>, Requires<[IsDarwin]>; +//} + let isBranch = 1, isTerminator = 1, isBarrier = 1 in { let isPredicable = 1 in def t2B : T2XI<(outs), (ins brtarget:$target), Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/CMakeLists.txt?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/ARM/CMakeLists.txt Wed Jul 8 11:09:28 2009 @@ -12,6 +12,7 @@ tablegen(ARMGenSubtarget.inc -gen-subtarget) add_llvm_target(ARMCodeGen + ARMBaseInstrInfo.cpp ARMCodeEmitter.cpp ARMConstantIslandPass.cpp ARMConstantPoolValue.cpp Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Wed Jul 8 11:09:28 2009 @@ -26,6 +26,61 @@ : ARMBaseInstrInfo(STI), RI(*this, STI) { } +unsigned Thumb1InstrInfo:: +getUnindexedOpcode(unsigned Opc) const { + return 0; +} + +unsigned Thumb1InstrInfo:: +getOpcode(ARMII::Op Op) const { + switch (Op) { + case ARMII::ADDri: return ARM::tADDi8; + case ARMII::ADDrs: return 0; + case ARMII::ADDrr: return ARM::tADDrr; + case ARMII::B: return ARM::tB; + case ARMII::Bcc: return ARM::tBcc; + case ARMII::BR_JTr: return ARM::tBR_JTr; + case ARMII::BR_JTm: return 0; + case ARMII::BR_JTadd: return 0; + case ARMII::FCPYS: return 0; + case ARMII::FCPYD: return 0; + case ARMII::FLDD: return 0; + case ARMII::FLDS: return 0; + case ARMII::FSTD: return 0; + case ARMII::FSTS: return 0; + case ARMII::LDR: return ARM::tLDR; + case ARMII::MOVr: return ARM::tMOVr; + case ARMII::STR: return ARM::tSTR; + case ARMII::SUBri: return ARM::tSUBi8; + case ARMII::SUBrs: return 0; + case ARMII::SUBrr: return ARM::tSUBrr; + case ARMII::VMOVD: return 0; + case ARMII::VMOVQ: return 0; + default: + break; + } + + return 0; +} + +bool +Thumb1InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { + if (MBB.empty()) return false; + + switch (MBB.back().getOpcode()) { + case ARM::tBX_RET: + case ARM::tBX_RET_vararg: + case ARM::tPOP_RET: + case ARM::tB: + case ARM::tBR_JTr: + return true; + default: + break; + } + + return false; +} + bool Thumb1InstrInfo::isMoveInstr(const MachineInstr &MI, unsigned &SrcReg, unsigned &DstReg, unsigned& SrcSubIdx, unsigned& DstSubIdx) const { Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h Wed Jul 8 11:09:28 2009 @@ -27,6 +27,16 @@ public: explicit Thumb1InstrInfo(const ARMSubtarget &STI); + // Return the non-pre/post incrementing version of 'Opc'. Return 0 + // if there is not such an opcode. + unsigned getUnindexedOpcode(unsigned Opc) const; + + // Return the opcode that implements 'Op', or 0 if no opcode + unsigned getOpcode(ARMII::Op Op) const; + + // Return true if the block does not fall through. + bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; + /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should /// always be able to get register info as well (through this method). Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Wed Jul 8 11:09:28 2009 @@ -26,6 +26,104 @@ : ARMBaseInstrInfo(STI), RI(*this, STI) { } +unsigned Thumb2InstrInfo:: +getUnindexedOpcode(unsigned Opc) const { + // FIXME + return 0; +} + +unsigned Thumb2InstrInfo:: +getOpcode(ARMII::Op Op) const { + switch (Op) { + case ARMII::ADDri: return ARM::t2ADDri; + case ARMII::ADDrs: return ARM::t2ADDrs; + case ARMII::ADDrr: return ARM::t2ADDrr; + case ARMII::B: return ARM::t2B; + case ARMII::Bcc: return ARM::t2Bcc; + case ARMII::BR_JTr: return ARM::t2BR_JTr; + case ARMII::BR_JTm: return ARM::t2BR_JTm; + case ARMII::BR_JTadd: return ARM::t2BR_JTadd; + case ARMII::FCPYS: return ARM::FCPYS; + case ARMII::FCPYD: return ARM::FCPYD; + case ARMII::FLDD: return ARM::FLDD; + case ARMII::FLDS: return ARM::FLDS; + case ARMII::FSTD: return ARM::FSTD; + case ARMII::FSTS: return ARM::FSTS; + case ARMII::LDR: return ARM::LDR; // FIXME + case ARMII::MOVr: return ARM::t2MOVr; + case ARMII::STR: return ARM::STR; // FIXME + case ARMII::SUBri: return ARM::t2SUBri; + case ARMII::SUBrs: return ARM::t2SUBrs; + case ARMII::SUBrr: return ARM::t2SUBrr; + case ARMII::VMOVD: return ARM::VMOVD; + case ARMII::VMOVQ: return ARM::VMOVQ; + default: + break; + } + + return 0; +} + +bool +Thumb2InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { + if (MBB.empty()) return false; + + // FIXME + switch (MBB.back().getOpcode()) { + //case ARM::t2BX_RET: + // case ARM::LDM_RET: + case ARM::t2B: // Uncond branch. + case ARM::t2BR_JTr: // Jumptable branch. + case ARM::t2BR_JTm: // Jumptable branch through mem. + case ARM::t2BR_JTadd: // Jumptable branch add to pc. + return true; + case ARM::tBX_RET: + case ARM::tBX_RET_vararg: + case ARM::tPOP_RET: + case ARM::tB: + case ARM::tBR_JTr: + return true; + default: + break; + } + + return false; +} + + +bool Thumb2InstrInfo::copyRegToReg(MachineBasicBlock &MBB, + MachineBasicBlock::iterator I, + unsigned DestReg, unsigned SrcReg, + const TargetRegisterClass *DestRC, + const TargetRegisterClass *SrcRC) const { + DebugLoc DL = DebugLoc::getUnknownLoc(); + if (I != MBB.end()) DL = I->getDebugLoc(); + + if (DestRC == ARM::GPRRegisterClass) { + if (SrcRC == ARM::GPRRegisterClass) { + return ARMBaseInstrInfo::copyRegToReg(MBB, I, DestReg, SrcReg, DestRC, SrcRC); + } else if (SrcRC == ARM::tGPRRegisterClass) { + BuildMI(MBB, I, DL, get(ARM::tMOVlor2hir), DestReg).addReg(SrcReg); + return true; + } + } else if (DestRC == ARM::tGPRRegisterClass) { + if (SrcRC == ARM::GPRRegisterClass) { + BuildMI(MBB, I, DL, get(ARM::tMOVhir2lor), DestReg).addReg(SrcReg); + return true; + } else if (SrcRC == ARM::tGPRRegisterClass) { + BuildMI(MBB, I, DL, get(ARM::tMOVr), DestReg).addReg(SrcReg); + return true; + } + } + + return false; +} + + + + + + bool Thumb2InstrInfo::isMoveInstr(const MachineInstr &MI, unsigned &SrcReg, unsigned &DstReg, unsigned& SrcSubIdx, unsigned& DstSubIdx) const { @@ -35,7 +133,6 @@ switch (oc) { default: return false; - // FIXME: Thumb2 case ARM::tMOVr: case ARM::tMOVhir2lor: case ARM::tMOVlor2hir: @@ -54,7 +151,6 @@ int &FrameIndex) const { switch (MI->getOpcode()) { default: break; - // FIXME: Thumb2 case ARM::tRestore: if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && @@ -71,7 +167,6 @@ int &FrameIndex) const { switch (MI->getOpcode()) { default: break; - // FIXME: Thumb2 case ARM::tSpill: if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && @@ -84,36 +179,6 @@ return 0; } -bool Thumb2InstrInfo::copyRegToReg(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, - unsigned DestReg, unsigned SrcReg, - const TargetRegisterClass *DestRC, - const TargetRegisterClass *SrcRC) const { - DebugLoc DL = DebugLoc::getUnknownLoc(); - if (I != MBB.end()) DL = I->getDebugLoc(); - - // FIXME: Thumb2 - if (DestRC == ARM::GPRRegisterClass) { - if (SrcRC == ARM::GPRRegisterClass) { - BuildMI(MBB, I, DL, get(ARM::tMOVhir2hir), DestReg).addReg(SrcReg); - return true; - } else if (SrcRC == ARM::tGPRRegisterClass) { - BuildMI(MBB, I, DL, get(ARM::tMOVlor2hir), DestReg).addReg(SrcReg); - return true; - } - } else if (DestRC == ARM::tGPRRegisterClass) { - if (SrcRC == ARM::GPRRegisterClass) { - BuildMI(MBB, I, DL, get(ARM::tMOVhir2lor), DestReg).addReg(SrcReg); - return true; - } else if (SrcRC == ARM::tGPRRegisterClass) { - BuildMI(MBB, I, DL, get(ARM::tMOVr), DestReg).addReg(SrcReg); - return true; - } - } - - return false; -} - bool Thumb2InstrInfo:: canFoldMemoryOperand(const MachineInstr *MI, const SmallVectorImpl &Ops) const { @@ -154,7 +219,6 @@ assert(RC == ARM::tGPRRegisterClass && "Unknown regclass!"); - // FIXME: Thumb2 if (RC == ARM::tGPRRegisterClass) { BuildMI(MBB, I, DL, get(ARM::tSpill)) .addReg(SrcReg, getKillRegState(isKill)) @@ -170,7 +234,6 @@ DebugLoc DL = DebugLoc::getUnknownLoc(); unsigned Opc = 0; - // FIXME: Thumb2. Is GPRRegClass here correct? assert(RC == ARM::GPRRegisterClass && "Unknown regclass!"); if (RC == ARM::GPRRegisterClass) { Opc = Addr[0].isFI() ? ARM::tSpill : ARM::tSTR; @@ -191,7 +254,6 @@ DebugLoc DL = DebugLoc::getUnknownLoc(); if (I != MBB.end()) DL = I->getDebugLoc(); - // FIXME: Thumb2 assert(RC == ARM::tGPRRegisterClass && "Unknown regclass!"); if (RC == ARM::tGPRRegisterClass) { @@ -208,7 +270,6 @@ DebugLoc DL = DebugLoc::getUnknownLoc(); unsigned Opc = 0; - // FIXME: Thumb2. Is GPRRegClass ok here? if (RC == ARM::GPRRegisterClass) { Opc = Addr[0].isFI() ? ARM::tRestore : ARM::tLDR; } Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Wed Jul 8 11:09:28 2009 @@ -27,12 +27,31 @@ public: explicit Thumb2InstrInfo(const ARMSubtarget &STI); + // Return the non-pre/post incrementing version of 'Opc'. Return 0 + // if there is not such an opcode. + unsigned getUnindexedOpcode(unsigned Opc) const; + + // Return the opcode that implements 'Op', or 0 if no opcode + unsigned getOpcode(ARMII::Op Op) const; + + // Return true if the block does not fall through. + bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; + /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should /// always be able to get register info as well (through this method). /// const Thumb2RegisterInfo &getRegisterInfo() const { return RI; } + bool copyRegToReg(MachineBasicBlock &MBB, + MachineBasicBlock::iterator I, + unsigned DestReg, unsigned SrcReg, + const TargetRegisterClass *DestRC, + const TargetRegisterClass *SrcRC) const; + + + + bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector &CSI) const; @@ -48,11 +67,6 @@ unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const; - bool copyRegToReg(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, - unsigned DestReg, unsigned SrcReg, - const TargetRegisterClass *DestRC, - const TargetRegisterClass *SrcRC) const; void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, @@ -80,13 +94,15 @@ MachineInstr* MI, const SmallVectorImpl &Ops, int FrameIndex) const; - + MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, MachineInstr* MI, const SmallVectorImpl &Ops, MachineInstr* LoadMI) const { return 0; } + + }; } Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll?rev=75010&r1=75009&r2=75010&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-select_xform.ll Wed Jul 8 11:09:28 2009 @@ -1,3 +1,5 @@ +; XFAIL: * +; fixme ; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | count 3 ; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mvn | count 1 From david_goodwin at apple.com Wed Jul 8 11:12:16 2009 From: david_goodwin at apple.com (David Goodwin) Date: Wed, 08 Jul 2009 16:12:16 -0000 Subject: [llvm-commits] [llvm] r75011 - /llvm/trunk/CREDITS.TXT Message-ID: <200907081612.n68GCGXd015544@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Jul 8 11:12:12 2009 New Revision: 75011 URL: http://llvm.org/viewvc/llvm-project?rev=75011&view=rev Log: Add myself to blame file... Modified: llvm/trunk/CREDITS.TXT Modified: llvm/trunk/CREDITS.TXT URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CREDITS.TXT?rev=75011&r1=75010&r2=75011&view=diff ============================================================================== --- llvm/trunk/CREDITS.TXT (original) +++ llvm/trunk/CREDITS.TXT Wed Jul 8 11:12:12 2009 @@ -306,3 +306,7 @@ N: Bob Wilson E: bob.wilson at acm.org D: Advanced SIMD (NEON) support in the ARM backend + +N: David Goodwin +E: david at goodwinz.net +D: Thumb-2 code generator From david_goodwin at apple.com Wed Jul 8 11:15:18 2009 From: david_goodwin at apple.com (David Goodwin) Date: Wed, 08 Jul 2009 16:15:18 -0000 Subject: [llvm-commits] [llvm] r75012 - /llvm/trunk/test/CodeGen/Thumb2/thumb2-rev16.ll Message-ID: <200907081615.n68GFK0t015632@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Jul 8 11:15:06 2009 New Revision: 75012 URL: http://llvm.org/viewvc/llvm-project?rev=75012&view=rev Log: Add rev16 test... xfail for now Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-rev16.ll Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-rev16.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-rev16.ll?rev=75012&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-rev16.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-rev16.ll Wed Jul 8 11:15:06 2009 @@ -0,0 +1,32 @@ +; XFAIL: * +; fixme rev16 pattern is not matching + +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep {rev16\\W*r\[0-9\]*,\\W*r\[0-9\]*} | count 1 + +; 0xff00ff00 = 4278255360 +; 0x00ff00ff = 16711935 +define i32 @f1(i32 %a) { + %l8 = shl i32 %a, 8 + %r8 = lshr i32 %a, 8 + %mask_l8 = and i32 %l8, 4278255360 + %mask_r8 = and i32 %r8, 16711935 + %tmp = or i32 %mask_l8, %mask_r8 + ret i32 %tmp +} + +; 0xff000000 = 4278190080 +; 0x00ff0000 = 16711680 +; 0x0000ff00 = 65280 +; 0x000000ff = 255 +define i32 @f2(i32 %a) { + %l8 = shl i32 %a, 8 + %r8 = lshr i32 %a, 8 + %masklo_l8 = and i32 %l8, 65280 + %maskhi_l8 = and i32 %l8, 4278190080 + %masklo_r8 = and i32 %r8, 255 + %maskhi_r8 = and i32 %r8, 16711680 + %tmp1 = or i32 %masklo_l8, %masklo_r8 + %tmp2 = or i32 %maskhi_l8, %maskhi_r8 + %tmp = or i32 %tmp1, %tmp2 + ret i32 %tmp +} From clattner at apple.com Wed Jul 8 11:15:24 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 8 Jul 2009 09:15:24 -0700 Subject: [llvm-commits] [cfe-commits] r74986 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CGCXX.cpp CGDecl.cpp CGExprConstant.cpp CGObjCGNU.cpp CGObjCMac.cpp CodeGenModule.cpp In-Reply-To: References: <200907080129.n681TJ6Y008080@zion.cs.uiuc.edu> Message-ID: <694E86D6-696C-4D5D-958F-9314E1AFBE61@apple.com> On Jul 8, 2009, at 8:48 AM, Owen Anderson wrote: > On Jul 7, 2009, at 11:08 PM, Chris Lattner wrote: > On Jul 7, 2009, at 6:29 PM, Owen Anderson wrote: >>> Author: resistor >>> Date: Tue Jul 7 20:29:18 2009 >>> New Revision: 74986 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=74986&view=rev >>> Log: >>> Update for LLVM API change. >> >> Hi Owen, >> >> Why do you need to specify a context to the globalvariable ctor >> when you also specify a module? > > Because the Module is optional, and we use this when building the GV > sentinels. Why not have two different methods, one that requires a context, and one that requires a module? Alternatively, why not just make the existing method require a module, and add a method on context for making a GV without a module? -Chris From devang.patel at gmail.com Wed Jul 8 11:16:14 2009 From: devang.patel at gmail.com (Devang Patel) Date: Wed, 8 Jul 2009 09:16:14 -0700 Subject: [llvm-commits] [llvm] r74955 - /llvm/trunk/include/llvm/Support/StandardPasses.h In-Reply-To: <04F24F1F-7332-4C52-B0E2-A70A22F96264@apple.com> References: <200907072209.n67M9htk001469@zion.cs.uiuc.edu> <04F24F1F-7332-4C52-B0E2-A70A22F96264@apple.com> Message-ID: <352a1fb20907080916p59f7c9ffqdfaad4cc5230999f@mail.gmail.com> On Tue, Jul 7, 2009 at 11:07 PM, Chris Lattner wrote: > > On Jul 7, 2009, at 10:52 PM, Evan Cheng wrote: > >> Hi Devang, >> >> What prompted this experiment? > > There are several outstanding bugzillas about miscompilations by index > set splitting. Yup. > ?I would much rather the pass be fixed than removed though. I agree. Right now pass needs high maintenance and my attention is somewhere else so I think it is not a good idea to keep it on and ignore those miscompilations for long. > -Chris > - Devang From bob.wilson at apple.com Wed Jul 8 11:50:53 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 8 Jul 2009 09:50:53 -0700 Subject: [llvm-commits] [llvm] r75011 - /llvm/trunk/CREDITS.TXT In-Reply-To: <200907081612.n68GCGXd015544@zion.cs.uiuc.edu> References: <200907081612.n68GCGXd015544@zion.cs.uiuc.edu> Message-ID: <4EDA4A70-E2B9-4BF6-9B6C-09AF93D83BF6@apple.com> Can you change it to be in alphabetical order? Thanks. On Jul 8, 2009, at 9:12 AM, David Goodwin wrote: > Author: david_goodwin > Date: Wed Jul 8 11:12:12 2009 > New Revision: 75011 > > URL: http://llvm.org/viewvc/llvm-project?rev=75011&view=rev > Log: > Add myself to blame file... > > Modified: > llvm/trunk/CREDITS.TXT > > Modified: llvm/trunk/CREDITS.TXT > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CREDITS.TXT?rev=75011&r1=75010&r2=75011&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/CREDITS.TXT (original) > +++ llvm/trunk/CREDITS.TXT Wed Jul 8 11:12:12 2009 > @@ -306,3 +306,7 @@ > N: Bob Wilson > E: bob.wilson at acm.org > D: Advanced SIMD (NEON) support in the ARM backend > + > +N: David Goodwin > +E: david at goodwinz.net > +D: Thumb-2 code generator > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Wed Jul 8 11:53:34 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 8 Jul 2009 09:53:34 -0700 Subject: [llvm-commits] [llvm] r75011 - /llvm/trunk/CREDITS.TXT In-Reply-To: <200907081612.n68GCGXd015544@zion.cs.uiuc.edu> References: <200907081612.n68GCGXd015544@zion.cs.uiuc.edu> Message-ID: <16e5fdf90907080953j749251cat7befbb2d3ef99adc@mail.gmail.com> On Wed, Jul 8, 2009 at 9:12 AM, David Goodwin wrote: > Author: david_goodwin > Date: Wed Jul ?8 11:12:12 2009 > New Revision: 75011 > > URL: http://llvm.org/viewvc/llvm-project?rev=75011&view=rev > Log: > Add myself to blame file... > > Modified: > ? ?llvm/trunk/CREDITS.TXT > > Modified: llvm/trunk/CREDITS.TXT > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CREDITS.TXT?rev=75011&r1=75010&r2=75011&view=diff > > ============================================================================== > --- llvm/trunk/CREDITS.TXT (original) > +++ llvm/trunk/CREDITS.TXT Wed Jul ?8 11:12:12 2009 > @@ -306,3 +306,7 @@ > ?N: Bob Wilson > ?E: bob.wilson at acm.org > ?D: Advanced SIMD (NEON) support in the ARM backend > + > +N: David Goodwin > +E: david at goodwinz.net > +D: Thumb-2 code generator > Hi David, Could you alphabetize your entry please? :-) (Go by surname.) -bw From gohman at apple.com Wed Jul 8 11:53:56 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 8 Jul 2009 09:53:56 -0700 Subject: [llvm-commits] PATCH: remove VICmp and VFCmp. In-Reply-To: <4A5460CB.6070802@free.fr> References: <4A518899.80806@mxc.ca> <7ABB6DFD-7F2E-4F31-A7D9-FC86362095E6@apple.com> <05085D11-65C9-478A-B854-1EAC52FD9E42@apple.com> <4A545414.4080604@free.fr> <4A5460CB.6070802@free.fr> Message-ID: <3ECC9511-11A5-4735-A5F7-C2974C59D0F2@apple.com> On Jul 8, 2009, at 2:03 AM, Duncan Sands wrote: > Hi Eli, > > >>> I think this is a misunderstanding of the roles of type and >>> >>> operation legalization. The getTypeToTransformTo method exists >>> >>> entirely for the benefit of type legalization. Since <4 x i1> is >>> >>> an illegal type, it needs to be transformed into the legal type >>> >>> given by getTypeToTransformTo, for example <4 x i8>. >>> >> >> >> We don't support that kind of promotion at the moment, although I >> >> suppose that's an implementation detail rather than a fundamental >> >> issue. >> > > exactly. The fact that this might not actually work right now is > an implementation problem, not a conceptual problem. I'm not saying there are fundamental obstacles here, just that there is more work to be done than just hooking up existing parts. Teaching type legalization how to promote illegal vectors of i1 to legal vectors of wider element types and using operand legalization to finish the work is an interesting idea. However, I'm also thinking a few steps beyond what's immediately being sought here. The removal of v[if]cmp doesn't require this level of generality. Dan From clattner at apple.com Wed Jul 8 11:54:07 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 8 Jul 2009 09:54:07 -0700 Subject: [llvm-commits] [llvm] r74964 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/vec_compare.ll In-Reply-To: References: <200907072303.n67N3tpM003424@zion.cs.uiuc.edu> Message-ID: <1C001B95-9130-472F-AF55-EF2AF70F6688@apple.com> On Jul 7, 2009, at 7:38 PM, Eli Friedman wrote: > On Tue, Jul 7, 2009 at 7:16 PM, Eli Friedman > wrote: >> On Tue, Jul 7, 2009 at 6:29 PM, Dan Gohman wrote: >>> EXTRACT_SUBVECTOR is normally used to extract a legal value from >>> an illegal one. The code above does the opposite, extracting a >>> potentially illegal value from a legal one. >> >> As far as I can tell, we support both cases properly in type >> legalization; what specific case breaks? > > Mmm, nevermind, you're talking about something like the following? > > define void @test2(<2 x i32> %A, <2 x i32> %B, <2 x i32>* %C) > nounwind { > %D = icmp sgt <2 x i32> %A, %B > %E = zext <2 x i1> %D to <2 x i32> > store <2 x i32> %E, <2 x i32>* %C > ret void > } > > It's really just falling apart because we don't support various > related cases correctly; first, it hits the "Unimp" assert in this > patch, and if you just comment it out (which seems like the right > thing to do), we hit an assertion because we don't support extracting > an i1 from a <2 x i1> in PromoteIntRes_EXTRACT_VECTOR_ELT . Still > nothing going wrong with EXTRACT_SUBVECTOR. Right, "what Eli said". :) Type legalization is inherently iterative, so producing illegal EXTRACT_SUBVECTOR's is not a problem. I don't claim that vector comparisons are perfect, in practice they are really only trustworthy for native datatypes right now. This is the same situation as VSETCC. It would be great to improve this, of course, but that was unrelated to slaying v[fi]cmp, so I didn't tackle it. -Chris From sabre at nondot.org Wed Jul 8 11:56:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 8 Jul 2009 11:56:11 -0500 Subject: [llvm-commits] CVS: llvm-www/OpenProjects.html Message-ID: <200907081656.n68GuBL7017131@zion.cs.uiuc.edu> Changes in directory llvm-www: OpenProjects.html updated: 1.51 -> 1.52 --- Log message: LTO works fine on linux now! --- Diffs of the changes: (+1 -4) OpenProjects.html | 5 +---- 1 files changed, 1 insertion(+), 4 deletions(-) Index: llvm-www/OpenProjects.html diff -u llvm-www/OpenProjects.html:1.51 llvm-www/OpenProjects.html:1.52 --- llvm-www/OpenProjects.html:1.51 Tue Jun 16 01:31:47 2009 +++ llvm-www/OpenProjects.html Wed Jul 8 11:44:17 2009 @@ -203,9 +203,6 @@ transactions to the PassManager for improved bugpoint.

    11. Improve bugpoint to support running tests in parallel on MP machines.
    12. -
    13. Add support for -transparent LTO on linux.
    14. -
    @@ -509,7 +506,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> LLVM Compiler Infrastructure
    - Last modified: $Date: 2009/06/16 06:31:47 $ + Last modified: $Date: 2009/07/08 16:44:17 $ From public at alisdairm.net Wed Jul 8 04:04:28 2009 From: public at alisdairm.net (Alisdair Meredith) Date: Wed, 08 Jul 2009 09:04:28 -0000 Subject: [llvm-commits] [llvm] r74995 - /llvm/trunk/include/llvm/Support/ErrorHandling.h Message-ID: <200907080904.n6894Vi7001028@zion.cs.uiuc.edu> Author: alisdairm Date: Wed Jul 8 04:04:19 2009 New Revision: 74995 URL: http://llvm.org/viewvc/llvm-project?rev=74995&view=rev Log: Trial first commit Fixed build, requires std header before using std::string Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=74995&r1=74994&r2=74995&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ErrorHandling.h (original) +++ llvm/trunk/include/llvm/Support/ErrorHandling.h Wed Jul 8 04:04:19 2009 @@ -16,6 +16,7 @@ #define LLVM_SUPPORT_ERRORHANDLING_H #include "llvm/Support/Compiler.h" +#include namespace llvm { // An error handler callback. From sabre at nondot.org Wed Jul 8 12:09:31 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 17:09:31 -0000 Subject: [llvm-commits] [llvm] r75015 - /llvm/trunk/include/llvm/Support/ErrorHandling.h Message-ID: <200907081709.n68H9cpx017673@zion.cs.uiuc.edu> Author: lattner Date: Wed Jul 8 12:09:18 2009 New Revision: 75015 URL: http://llvm.org/viewvc/llvm-project?rev=75015&view=rev Log: convert comments to doxygen style Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=75015&r1=75014&r2=75015&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ErrorHandling.h (original) +++ llvm/trunk/include/llvm/Support/ErrorHandling.h Wed Jul 8 12:09:18 2009 @@ -19,33 +19,33 @@ #include namespace llvm { - // An error handler callback. + /// An error handler callback. typedef void (*llvm_error_handler_t)(const std::string& reason); - // Installs a new error handler: this function will be called whenever a - // serious error is encountered by LLVM. - // If you are using llvm_start_multithreaded, you should register the handler - // before doing that. - // - // If no error handler is installed the default is to print the error message - // to stderr, and call exit(1). - // If an error handler is installed then it is the handler's responsibility to - // log the message, it will no longer be printed to stderr. - // If the error handler returns, then exit(1) will be called. + /// Installs a new error handler: this function will be called whenever a + /// serious error is encountered by LLVM. + /// If you are using llvm_start_multithreaded, you should register the handler + /// before doing that. + /// + /// If no error handler is installed the default is to print the error message + /// to stderr, and call exit(1). + /// If an error handler is installed then it is the handler's responsibility + /// to log the message, it will no longer be printed to stderr. + /// If the error handler returns, then exit(1) will be called. void llvm_install_error_handler(llvm_error_handler_t handler); - // Restores default error handling behaviour. - // This must not be called between llvm_start_multithreaded() and - // llvm_stop_multithreaded(). + /// Restores default error handling behaviour. + /// This must not be called between llvm_start_multithreaded() and + /// llvm_stop_multithreaded(). void llvm_remove_error_handler(void); - // Reports a serious error, calling any installed error handler. - // If no error handler is installed the default is to print the message to + /// Reports a serious error, calling any installed error handler. + /// If no error handler is installed the default is to print the message to void llvm_report_error(const std::string &reason) NORETURN; - // This function calls abort(). - // Call this after assert(0), so that compiler knows the path is not - // reachable. + /// This function calls abort(). + /// Call this after assert(0), so that compiler knows the path is not + /// reachable. void llvm_unreachable(void) NORETURN; } From david_goodwin at apple.com Wed Jul 8 12:29:26 2009 From: david_goodwin at apple.com (David Goodwin) Date: Wed, 08 Jul 2009 17:29:26 -0000 Subject: [llvm-commits] [llvm] r75016 - in /llvm/trunk/lib/Target/ARM: ARMBaseRegisterInfo.cpp ARMBaseRegisterInfo.h ARMRegisterInfo.cpp ARMRegisterInfo.h Message-ID: <200907081729.n68HTY4f018478@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Jul 8 12:28:55 2009 New Revision: 75016 URL: http://llvm.org/viewvc/llvm-project?rev=75016&view=rev Log: Start breaking out common base functionality for register info. Added: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h Added: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=75016&view=auto ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (added) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Jul 8 12:28:55 2009 @@ -0,0 +1,865 @@ +//===- ARMBaseRegisterInfo.cpp - ARM Register Information -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the base ARM implementation of TargetRegisterInfo class. +// +//===----------------------------------------------------------------------===// + +#include "ARM.h" +#include "ARMAddressingModes.h" +#include "ARMBaseRegisterInfo.h" +#include "ARMInstrInfo.h" +#include "ARMMachineFunctionInfo.h" +#include "ARMSubtarget.h" +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/CodeGen/MachineConstantPool.h" +#include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineLocation.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/RegisterScavenging.h" +#include "llvm/Target/TargetFrameInfo.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetOptions.h" +#include "llvm/ADT/BitVector.h" +#include "llvm/ADT/SmallVector.h" +using namespace llvm; + +unsigned ARMBaseRegisterInfo::getRegisterNumbering(unsigned RegEnum) { + using namespace ARM; + switch (RegEnum) { + case R0: case S0: case D0: return 0; + case R1: case S1: case D1: return 1; + case R2: case S2: case D2: return 2; + case R3: case S3: case D3: return 3; + case R4: case S4: case D4: return 4; + case R5: case S5: case D5: return 5; + case R6: case S6: case D6: return 6; + case R7: case S7: case D7: return 7; + case R8: case S8: case D8: return 8; + case R9: case S9: case D9: return 9; + case R10: case S10: case D10: return 10; + case R11: case S11: case D11: return 11; + case R12: case S12: case D12: return 12; + case SP: case S13: case D13: return 13; + case LR: case S14: case D14: return 14; + case PC: case S15: case D15: return 15; + case S16: return 16; + case S17: return 17; + case S18: return 18; + case S19: return 19; + case S20: return 20; + case S21: return 21; + case S22: return 22; + case S23: return 23; + case S24: return 24; + case S25: return 25; + case S26: return 26; + case S27: return 27; + case S28: return 28; + case S29: return 29; + case S30: return 30; + case S31: return 31; + default: + assert(0 && "Unknown ARM register!"); + abort(); + } +} + +unsigned ARMBaseRegisterInfo::getRegisterNumbering(unsigned RegEnum, + bool &isSPVFP) { + isSPVFP = false; + + using namespace ARM; + switch (RegEnum) { + default: + assert(0 && "Unknown ARM register!"); + abort(); + case R0: case D0: return 0; + case R1: case D1: return 1; + case R2: case D2: return 2; + case R3: case D3: return 3; + case R4: case D4: return 4; + case R5: case D5: return 5; + case R6: case D6: return 6; + case R7: case D7: return 7; + case R8: case D8: return 8; + case R9: case D9: return 9; + case R10: case D10: return 10; + case R11: case D11: return 11; + case R12: case D12: return 12; + case SP: case D13: return 13; + case LR: case D14: return 14; + case PC: case D15: return 15; + + case S0: case S1: case S2: case S3: + case S4: case S5: case S6: case S7: + case S8: case S9: case S10: case S11: + case S12: case S13: case S14: case S15: + case S16: case S17: case S18: case S19: + case S20: case S21: case S22: case S23: + case S24: case S25: case S26: case S27: + case S28: case S29: case S30: case S31: { + isSPVFP = true; + switch (RegEnum) { + default: return 0; // Avoid compile time warning. + case S0: return 0; + case S1: return 1; + case S2: return 2; + case S3: return 3; + case S4: return 4; + case S5: return 5; + case S6: return 6; + case S7: return 7; + case S8: return 8; + case S9: return 9; + case S10: return 10; + case S11: return 11; + case S12: return 12; + case S13: return 13; + case S14: return 14; + case S15: return 15; + case S16: return 16; + case S17: return 17; + case S18: return 18; + case S19: return 19; + case S20: return 20; + case S21: return 21; + case S22: return 22; + case S23: return 23; + case S24: return 24; + case S25: return 25; + case S26: return 26; + case S27: return 27; + case S28: return 28; + case S29: return 29; + case S30: return 30; + case S31: return 31; + } + } + } +} + +ARMBaseRegisterInfo::ARMBaseRegisterInfo(const TargetInstrInfo &tii, + const ARMSubtarget &sti) + : ARMGenRegisterInfo(ARM::ADJCALLSTACKDOWN, ARM::ADJCALLSTACKUP), + TII(tii), STI(sti), + FramePtr((STI.isTargetDarwin() || STI.isThumb()) ? ARM::R7 : ARM::R11) { +} + +const unsigned* +ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { + static const unsigned CalleeSavedRegs[] = { + ARM::LR, ARM::R11, ARM::R10, ARM::R9, ARM::R8, + ARM::R7, ARM::R6, ARM::R5, ARM::R4, + + ARM::D15, ARM::D14, ARM::D13, ARM::D12, + ARM::D11, ARM::D10, ARM::D9, ARM::D8, + 0 + }; + + static const unsigned DarwinCalleeSavedRegs[] = { + // Darwin ABI deviates from ARM standard ABI. R9 is not a callee-saved + // register. + ARM::LR, ARM::R7, ARM::R6, ARM::R5, ARM::R4, + ARM::R11, ARM::R10, ARM::R8, + + ARM::D15, ARM::D14, ARM::D13, ARM::D12, + ARM::D11, ARM::D10, ARM::D9, ARM::D8, + 0 + }; + return STI.isTargetDarwin() ? DarwinCalleeSavedRegs : CalleeSavedRegs; +} + +const TargetRegisterClass* const * +ARMBaseRegisterInfo::getCalleeSavedRegClasses(const MachineFunction *MF) const { + static const TargetRegisterClass * const CalleeSavedRegClasses[] = { + &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, + &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, + &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, + + &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, + &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, + 0 + }; + + static const TargetRegisterClass * const ThumbCalleeSavedRegClasses[] = { + &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, + &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::tGPRRegClass, + &ARM::tGPRRegClass,&ARM::tGPRRegClass,&ARM::tGPRRegClass, + + &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, + &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, + 0 + }; + + static const TargetRegisterClass * const DarwinCalleeSavedRegClasses[] = { + &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, + &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, + &ARM::GPRRegClass, &ARM::GPRRegClass, + + &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, + &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, + 0 + }; + + static const TargetRegisterClass * const DarwinThumbCalleeSavedRegClasses[] ={ + &ARM::GPRRegClass, &ARM::tGPRRegClass, &ARM::tGPRRegClass, + &ARM::tGPRRegClass, &ARM::tGPRRegClass, &ARM::GPRRegClass, + &ARM::GPRRegClass, &ARM::GPRRegClass, + + &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, + &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, + 0 + }; + + if (STI.isThumb()) { + return STI.isTargetDarwin() + ? DarwinThumbCalleeSavedRegClasses : ThumbCalleeSavedRegClasses; + } + return STI.isTargetDarwin() + ? DarwinCalleeSavedRegClasses : CalleeSavedRegClasses; +} + +BitVector ARMBaseRegisterInfo::getReservedRegs(const MachineFunction &MF) const { + // FIXME: avoid re-calculating this everytime. + BitVector Reserved(getNumRegs()); + Reserved.set(ARM::SP); + Reserved.set(ARM::PC); + if (STI.isTargetDarwin() || hasFP(MF)) + Reserved.set(FramePtr); + // Some targets reserve R9. + if (STI.isR9Reserved()) + Reserved.set(ARM::R9); + return Reserved; +} + +bool +ARMBaseRegisterInfo::isReservedReg(const MachineFunction &MF, unsigned Reg) const { + switch (Reg) { + default: break; + case ARM::SP: + case ARM::PC: + return true; + case ARM::R7: + case ARM::R11: + if (FramePtr == Reg && (STI.isTargetDarwin() || hasFP(MF))) + return true; + break; + case ARM::R9: + return STI.isR9Reserved(); + } + + return false; +} + +const TargetRegisterClass *ARMBaseRegisterInfo::getPointerRegClass() const { + return &ARM::GPRRegClass; +} + +/// getAllocationOrder - Returns the register allocation order for a specified +/// register class in the form of a pair of TargetRegisterClass iterators. +std::pair +ARMBaseRegisterInfo::getAllocationOrder(const TargetRegisterClass *RC, + unsigned HintType, unsigned HintReg, + const MachineFunction &MF) const { + // Alternative register allocation orders when favoring even / odd registers + // of register pairs. + + // No FP, R9 is available. + static const unsigned GPREven1[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R6, ARM::R8, ARM::R10, + ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R7, + ARM::R9, ARM::R11 + }; + static const unsigned GPROdd1[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R7, ARM::R9, ARM::R11, + ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, + ARM::R8, ARM::R10 + }; + + // FP is R7, R9 is available. + static const unsigned GPREven2[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R8, ARM::R10, + ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R6, + ARM::R9, ARM::R11 + }; + static const unsigned GPROdd2[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R9, ARM::R11, + ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, + ARM::R8, ARM::R10 + }; + + // FP is R11, R9 is available. + static const unsigned GPREven3[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R6, ARM::R8, + ARM::R1, ARM::R3, ARM::R10,ARM::R12,ARM::LR, ARM::R5, ARM::R7, + ARM::R9 + }; + static const unsigned GPROdd3[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R6, ARM::R9, + ARM::R0, ARM::R2, ARM::R10,ARM::R12,ARM::LR, ARM::R4, ARM::R7, + ARM::R8 + }; + + // No FP, R9 is not available. + static const unsigned GPREven4[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R6, ARM::R10, + ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R7, ARM::R8, + ARM::R11 + }; + static const unsigned GPROdd4[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R7, ARM::R11, + ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8, + ARM::R10 + }; + + // FP is R7, R9 is not available. + static const unsigned GPREven5[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R10, + ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R6, ARM::R8, + ARM::R11 + }; + static const unsigned GPROdd5[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R11, + ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8, + ARM::R10 + }; + + // FP is R11, R9 is not available. + static const unsigned GPREven6[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R6, + ARM::R1, ARM::R3, ARM::R10,ARM::R12,ARM::LR, ARM::R5, ARM::R7, ARM::R8 + }; + static const unsigned GPROdd6[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R7, + ARM::R0, ARM::R2, ARM::R10,ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8 + }; + + + if (HintType == ARMRI::RegPairEven) { + if (isPhysicalRegister(HintReg) && getRegisterPairEven(HintReg, MF) == 0) + // It's no longer possible to fulfill this hint. Return the default + // allocation order. + return std::make_pair(RC->allocation_order_begin(MF), + RC->allocation_order_end(MF)); + + if (!STI.isTargetDarwin() && !hasFP(MF)) { + if (!STI.isR9Reserved()) + return std::make_pair(GPREven1, + GPREven1 + (sizeof(GPREven1)/sizeof(unsigned))); + else + return std::make_pair(GPREven4, + GPREven4 + (sizeof(GPREven4)/sizeof(unsigned))); + } else if (FramePtr == ARM::R7) { + if (!STI.isR9Reserved()) + return std::make_pair(GPREven2, + GPREven2 + (sizeof(GPREven2)/sizeof(unsigned))); + else + return std::make_pair(GPREven5, + GPREven5 + (sizeof(GPREven5)/sizeof(unsigned))); + } else { // FramePtr == ARM::R11 + if (!STI.isR9Reserved()) + return std::make_pair(GPREven3, + GPREven3 + (sizeof(GPREven3)/sizeof(unsigned))); + else + return std::make_pair(GPREven6, + GPREven6 + (sizeof(GPREven6)/sizeof(unsigned))); + } + } else if (HintType == ARMRI::RegPairOdd) { + if (isPhysicalRegister(HintReg) && getRegisterPairOdd(HintReg, MF) == 0) + // It's no longer possible to fulfill this hint. Return the default + // allocation order. + return std::make_pair(RC->allocation_order_begin(MF), + RC->allocation_order_end(MF)); + + if (!STI.isTargetDarwin() && !hasFP(MF)) { + if (!STI.isR9Reserved()) + return std::make_pair(GPROdd1, + GPROdd1 + (sizeof(GPROdd1)/sizeof(unsigned))); + else + return std::make_pair(GPROdd4, + GPROdd4 + (sizeof(GPROdd4)/sizeof(unsigned))); + } else if (FramePtr == ARM::R7) { + if (!STI.isR9Reserved()) + return std::make_pair(GPROdd2, + GPROdd2 + (sizeof(GPROdd2)/sizeof(unsigned))); + else + return std::make_pair(GPROdd5, + GPROdd5 + (sizeof(GPROdd5)/sizeof(unsigned))); + } else { // FramePtr == ARM::R11 + if (!STI.isR9Reserved()) + return std::make_pair(GPROdd3, + GPROdd3 + (sizeof(GPROdd3)/sizeof(unsigned))); + else + return std::make_pair(GPROdd6, + GPROdd6 + (sizeof(GPROdd6)/sizeof(unsigned))); + } + } + return std::make_pair(RC->allocation_order_begin(MF), + RC->allocation_order_end(MF)); +} + +/// ResolveRegAllocHint - Resolves the specified register allocation hint +/// to a physical register. Returns the physical register if it is successful. +unsigned +ARMBaseRegisterInfo::ResolveRegAllocHint(unsigned Type, unsigned Reg, + const MachineFunction &MF) const { + if (Reg == 0 || !isPhysicalRegister(Reg)) + return 0; + if (Type == 0) + return Reg; + else if (Type == (unsigned)ARMRI::RegPairOdd) + // Odd register. + return getRegisterPairOdd(Reg, MF); + else if (Type == (unsigned)ARMRI::RegPairEven) + // Even register. + return getRegisterPairEven(Reg, MF); + return 0; +} + +void +ARMBaseRegisterInfo::UpdateRegAllocHint(unsigned Reg, unsigned NewReg, + MachineFunction &MF) const { + MachineRegisterInfo *MRI = &MF.getRegInfo(); + std::pair Hint = MRI->getRegAllocationHint(Reg); + if ((Hint.first == (unsigned)ARMRI::RegPairOdd || + Hint.first == (unsigned)ARMRI::RegPairEven) && + Hint.second && TargetRegisterInfo::isVirtualRegister(Hint.second)) { + // If 'Reg' is one of the even / odd register pair and it's now changed + // (e.g. coalesced) into a different register. The other register of the + // pair allocation hint must be updated to reflect the relationship + // change. + unsigned OtherReg = Hint.second; + Hint = MRI->getRegAllocationHint(OtherReg); + if (Hint.second == Reg) + // Make sure the pair has not already divorced. + MRI->setRegAllocationHint(OtherReg, Hint.first, NewReg); + } +} + +/// hasFP - Return true if the specified function should have a dedicated frame +/// pointer register. This is true if the function has variable sized allocas +/// or if frame pointer elimination is disabled. +/// +bool ARMBaseRegisterInfo::hasFP(const MachineFunction &MF) const { + const MachineFrameInfo *MFI = MF.getFrameInfo(); + return (NoFramePointerElim || + MFI->hasVarSizedObjects() || + MFI->isFrameAddressTaken()); +} + +static unsigned estimateStackSize(MachineFunction &MF, MachineFrameInfo *MFI) { + const MachineFrameInfo *FFI = MF.getFrameInfo(); + int Offset = 0; + for (int i = FFI->getObjectIndexBegin(); i != 0; ++i) { + int FixedOff = -FFI->getObjectOffset(i); + if (FixedOff > Offset) Offset = FixedOff; + } + for (unsigned i = 0, e = FFI->getObjectIndexEnd(); i != e; ++i) { + if (FFI->isDeadObjectIndex(i)) + continue; + Offset += FFI->getObjectSize(i); + unsigned Align = FFI->getObjectAlignment(i); + // Adjust to alignment boundary + Offset = (Offset+Align-1)/Align*Align; + } + return (unsigned)Offset; +} + +void +ARMBaseRegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF, + RegScavenger *RS) const { + // This tells PEI to spill the FP as if it is any other callee-save register + // to take advantage the eliminateFrameIndex machinery. This also ensures it + // is spilled in the order specified by getCalleeSavedRegs() to make it easier + // to combine multiple loads / stores. + bool CanEliminateFrame = true; + bool CS1Spilled = false; + bool LRSpilled = false; + unsigned NumGPRSpills = 0; + SmallVector UnspilledCS1GPRs; + SmallVector UnspilledCS2GPRs; + ARMFunctionInfo *AFI = MF.getInfo(); + + // Don't spill FP if the frame can be eliminated. This is determined + // by scanning the callee-save registers to see if any is used. + const unsigned *CSRegs = getCalleeSavedRegs(); + const TargetRegisterClass* const *CSRegClasses = getCalleeSavedRegClasses(); + for (unsigned i = 0; CSRegs[i]; ++i) { + unsigned Reg = CSRegs[i]; + bool Spilled = false; + if (MF.getRegInfo().isPhysRegUsed(Reg)) { + AFI->setCSRegisterIsSpilled(Reg); + Spilled = true; + CanEliminateFrame = false; + } else { + // Check alias registers too. + for (const unsigned *Aliases = getAliasSet(Reg); *Aliases; ++Aliases) { + if (MF.getRegInfo().isPhysRegUsed(*Aliases)) { + Spilled = true; + CanEliminateFrame = false; + } + } + } + + if (CSRegClasses[i] == &ARM::GPRRegClass) { + if (Spilled) { + NumGPRSpills++; + + if (!STI.isTargetDarwin()) { + if (Reg == ARM::LR) + LRSpilled = true; + CS1Spilled = true; + continue; + } + + // Keep track if LR and any of R4, R5, R6, and R7 is spilled. + switch (Reg) { + case ARM::LR: + LRSpilled = true; + // Fallthrough + case ARM::R4: + case ARM::R5: + case ARM::R6: + case ARM::R7: + CS1Spilled = true; + break; + default: + break; + } + } else { + if (!STI.isTargetDarwin()) { + UnspilledCS1GPRs.push_back(Reg); + continue; + } + + switch (Reg) { + case ARM::R4: + case ARM::R5: + case ARM::R6: + case ARM::R7: + case ARM::LR: + UnspilledCS1GPRs.push_back(Reg); + break; + default: + UnspilledCS2GPRs.push_back(Reg); + break; + } + } + } + } + + bool ForceLRSpill = false; + if (!LRSpilled && AFI->isThumbFunction()) { + unsigned FnSize = TII.GetFunctionSizeInBytes(MF); + // Force LR to be spilled if the Thumb function size is > 2048. This enables + // use of BL to implement far jump. If it turns out that it's not needed + // then the branch fix up path will undo it. + if (FnSize >= (1 << 11)) { + CanEliminateFrame = false; + ForceLRSpill = true; + } + } + + bool ExtraCSSpill = false; + if (!CanEliminateFrame || hasFP(MF)) { + AFI->setHasStackFrame(true); + + // If LR is not spilled, but at least one of R4, R5, R6, and R7 is spilled. + // Spill LR as well so we can fold BX_RET to the registers restore (LDM). + if (!LRSpilled && CS1Spilled) { + MF.getRegInfo().setPhysRegUsed(ARM::LR); + AFI->setCSRegisterIsSpilled(ARM::LR); + NumGPRSpills++; + UnspilledCS1GPRs.erase(std::find(UnspilledCS1GPRs.begin(), + UnspilledCS1GPRs.end(), (unsigned)ARM::LR)); + ForceLRSpill = false; + ExtraCSSpill = true; + } + + // Darwin ABI requires FP to point to the stack slot that contains the + // previous FP. + if (STI.isTargetDarwin() || hasFP(MF)) { + MF.getRegInfo().setPhysRegUsed(FramePtr); + NumGPRSpills++; + } + + // If stack and double are 8-byte aligned and we are spilling an odd number + // of GPRs. Spill one extra callee save GPR so we won't have to pad between + // the integer and double callee save areas. + unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); + if (TargetAlign == 8 && (NumGPRSpills & 1)) { + if (CS1Spilled && !UnspilledCS1GPRs.empty()) { + for (unsigned i = 0, e = UnspilledCS1GPRs.size(); i != e; ++i) { + unsigned Reg = UnspilledCS1GPRs[i]; + // Don't spiil high register if the function is thumb + if (!AFI->isThumbFunction() || + isARMLowRegister(Reg) || Reg == ARM::LR) { + MF.getRegInfo().setPhysRegUsed(Reg); + AFI->setCSRegisterIsSpilled(Reg); + if (!isReservedReg(MF, Reg)) + ExtraCSSpill = true; + break; + } + } + } else if (!UnspilledCS2GPRs.empty() && + !AFI->isThumbFunction()) { + unsigned Reg = UnspilledCS2GPRs.front(); + MF.getRegInfo().setPhysRegUsed(Reg); + AFI->setCSRegisterIsSpilled(Reg); + if (!isReservedReg(MF, Reg)) + ExtraCSSpill = true; + } + } + + // Estimate if we might need to scavenge a register at some point in order + // to materialize a stack offset. If so, either spill one additional + // callee-saved register or reserve a special spill slot to facilitate + // register scavenging. + if (RS && !ExtraCSSpill && !AFI->isThumbFunction()) { + MachineFrameInfo *MFI = MF.getFrameInfo(); + unsigned Size = estimateStackSize(MF, MFI); + unsigned Limit = (1 << 12) - 1; + for (MachineFunction::iterator BB = MF.begin(),E = MF.end();BB != E; ++BB) + for (MachineBasicBlock::iterator I= BB->begin(); I != BB->end(); ++I) { + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) + if (I->getOperand(i).isFI()) { + unsigned Opcode = I->getOpcode(); + const TargetInstrDesc &Desc = TII.get(Opcode); + unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask); + if (AddrMode == ARMII::AddrMode3) { + Limit = (1 << 8) - 1; + goto DoneEstimating; + } else if (AddrMode == ARMII::AddrMode5) { + unsigned ThisLimit = ((1 << 8) - 1) * 4; + if (ThisLimit < Limit) + Limit = ThisLimit; + } + } + } + DoneEstimating: + if (Size >= Limit) { + // If any non-reserved CS register isn't spilled, just spill one or two + // extra. That should take care of it! + unsigned NumExtras = TargetAlign / 4; + SmallVector Extras; + while (NumExtras && !UnspilledCS1GPRs.empty()) { + unsigned Reg = UnspilledCS1GPRs.back(); + UnspilledCS1GPRs.pop_back(); + if (!isReservedReg(MF, Reg)) { + Extras.push_back(Reg); + NumExtras--; + } + } + while (NumExtras && !UnspilledCS2GPRs.empty()) { + unsigned Reg = UnspilledCS2GPRs.back(); + UnspilledCS2GPRs.pop_back(); + if (!isReservedReg(MF, Reg)) { + Extras.push_back(Reg); + NumExtras--; + } + } + if (Extras.size() && NumExtras == 0) { + for (unsigned i = 0, e = Extras.size(); i != e; ++i) { + MF.getRegInfo().setPhysRegUsed(Extras[i]); + AFI->setCSRegisterIsSpilled(Extras[i]); + } + } else { + // Reserve a slot closest to SP or frame pointer. + const TargetRegisterClass *RC = &ARM::GPRRegClass; + RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize(), + RC->getAlignment())); + } + } + } + } + + if (ForceLRSpill) { + MF.getRegInfo().setPhysRegUsed(ARM::LR); + AFI->setCSRegisterIsSpilled(ARM::LR); + AFI->setLRIsSpilledForFarJump(true); + } +} + +unsigned ARMBaseRegisterInfo::getRARegister() const { + return ARM::LR; +} + +unsigned ARMBaseRegisterInfo::getFrameRegister(MachineFunction &MF) const { + if (STI.isTargetDarwin() || hasFP(MF)) + return FramePtr; + return ARM::SP; +} + +unsigned ARMBaseRegisterInfo::getEHExceptionRegister() const { + assert(0 && "What is the exception register"); + return 0; +} + +unsigned ARMBaseRegisterInfo::getEHHandlerRegister() const { + assert(0 && "What is the exception handler register"); + return 0; +} + +int ARMBaseRegisterInfo::getDwarfRegNum(unsigned RegNum, bool isEH) const { + return ARMGenRegisterInfo::getDwarfRegNumFull(RegNum, 0); +} + +unsigned ARMBaseRegisterInfo::getRegisterPairEven(unsigned Reg, + const MachineFunction &MF) const { + switch (Reg) { + default: break; + // Return 0 if either register of the pair is a special register. + // So no R12, etc. + case ARM::R1: + return ARM::R0; + case ARM::R3: + // FIXME! + return STI.isThumb() ? 0 : ARM::R2; + case ARM::R5: + return ARM::R4; + case ARM::R7: + return isReservedReg(MF, ARM::R7) ? 0 : ARM::R6; + case ARM::R9: + return isReservedReg(MF, ARM::R9) ? 0 :ARM::R8; + case ARM::R11: + return isReservedReg(MF, ARM::R11) ? 0 : ARM::R10; + + case ARM::S1: + return ARM::S0; + case ARM::S3: + return ARM::S2; + case ARM::S5: + return ARM::S4; + case ARM::S7: + return ARM::S6; + case ARM::S9: + return ARM::S8; + case ARM::S11: + return ARM::S10; + case ARM::S13: + return ARM::S12; + case ARM::S15: + return ARM::S14; + case ARM::S17: + return ARM::S16; + case ARM::S19: + return ARM::S18; + case ARM::S21: + return ARM::S20; + case ARM::S23: + return ARM::S22; + case ARM::S25: + return ARM::S24; + case ARM::S27: + return ARM::S26; + case ARM::S29: + return ARM::S28; + case ARM::S31: + return ARM::S30; + + case ARM::D1: + return ARM::D0; + case ARM::D3: + return ARM::D2; + case ARM::D5: + return ARM::D4; + case ARM::D7: + return ARM::D6; + case ARM::D9: + return ARM::D8; + case ARM::D11: + return ARM::D10; + case ARM::D13: + return ARM::D12; + case ARM::D15: + return ARM::D14; + } + + return 0; +} + +unsigned ARMBaseRegisterInfo::getRegisterPairOdd(unsigned Reg, + const MachineFunction &MF) const { + switch (Reg) { + default: break; + // Return 0 if either register of the pair is a special register. + // So no R12, etc. + case ARM::R0: + return ARM::R1; + case ARM::R2: + // FIXME! + return STI.isThumb() ? 0 : ARM::R3; + case ARM::R4: + return ARM::R5; + case ARM::R6: + return isReservedReg(MF, ARM::R7) ? 0 : ARM::R7; + case ARM::R8: + return isReservedReg(MF, ARM::R9) ? 0 :ARM::R9; + case ARM::R10: + return isReservedReg(MF, ARM::R11) ? 0 : ARM::R11; + + case ARM::S0: + return ARM::S1; + case ARM::S2: + return ARM::S3; + case ARM::S4: + return ARM::S5; + case ARM::S6: + return ARM::S7; + case ARM::S8: + return ARM::S9; + case ARM::S10: + return ARM::S11; + case ARM::S12: + return ARM::S13; + case ARM::S14: + return ARM::S15; + case ARM::S16: + return ARM::S17; + case ARM::S18: + return ARM::S19; + case ARM::S20: + return ARM::S21; + case ARM::S22: + return ARM::S23; + case ARM::S24: + return ARM::S25; + case ARM::S26: + return ARM::S27; + case ARM::S28: + return ARM::S29; + case ARM::S30: + return ARM::S31; + + case ARM::D0: + return ARM::D1; + case ARM::D2: + return ARM::D3; + case ARM::D4: + return ARM::D5; + case ARM::D6: + return ARM::D7; + case ARM::D8: + return ARM::D9; + case ARM::D10: + return ARM::D11; + case ARM::D12: + return ARM::D13; + case ARM::D14: + return ARM::D15; + } + + return 0; +} + +#include "ARMGenRegisterInfo.inc" Added: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h?rev=75016&view=auto ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h (added) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Wed Jul 8 12:28:55 2009 @@ -0,0 +1,113 @@ +//===- ARMBaseRegisterInfo.h - ARM Register Information Impl --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the base ARM implementation of TargetRegisterInfo class. +// +//===----------------------------------------------------------------------===// + +#ifndef ARMBASEREGISTERINFO_H +#define ARMBASEREGISTERINFO_H + +#include "ARM.h" +#include "llvm/Target/TargetRegisterInfo.h" +#include "ARMGenRegisterInfo.h.inc" + +namespace llvm { + class ARMSubtarget; + class TargetInstrInfo; + class Type; + +/// Register allocation hints. +namespace ARMRI { + enum { + RegPairOdd = 1, + RegPairEven = 2 + }; +} + +/// isARMLowRegister - Returns true if the register is low register r0-r7. +/// +static inline bool isARMLowRegister(unsigned Reg) { + using namespace ARM; + switch (Reg) { + case R0: case R1: case R2: case R3: + case R4: case R5: case R6: case R7: + return true; + default: + return false; + } +} + +struct ARMBaseRegisterInfo : public ARMGenRegisterInfo { +protected: + const TargetInstrInfo &TII; + const ARMSubtarget &STI; + + /// FramePtr - ARM physical register used as frame ptr. + unsigned FramePtr; +public: + ARMBaseRegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI); + + /// getRegisterNumbering - Given the enum value for some register, e.g. + /// ARM::LR, return the number that it corresponds to (e.g. 14). + static unsigned getRegisterNumbering(unsigned RegEnum); + + /// Same as previous getRegisterNumbering except it returns true in isSPVFP + /// if the register is a single precision VFP register. + static unsigned getRegisterNumbering(unsigned RegEnum, bool &isSPVFP); + + /// Code Generation virtual methods... + const unsigned *getCalleeSavedRegs(const MachineFunction *MF = 0) const; + + const TargetRegisterClass* const* + getCalleeSavedRegClasses(const MachineFunction *MF = 0) const; + + BitVector getReservedRegs(const MachineFunction &MF) const; + + bool isReservedReg(const MachineFunction &MF, unsigned Reg) const; + + const TargetRegisterClass *getPointerRegClass() const; + + std::pair + getAllocationOrder(const TargetRegisterClass *RC, + unsigned HintType, unsigned HintReg, + const MachineFunction &MF) const; + + unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg, + const MachineFunction &MF) const; + + void UpdateRegAllocHint(unsigned Reg, unsigned NewReg, + MachineFunction &MF) const; + + bool hasFP(const MachineFunction &MF) const; + + void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, + RegScavenger *RS = NULL) const; + + // Debug information queries. + unsigned getRARegister() const; + unsigned getFrameRegister(MachineFunction &MF) const; + + // Exception handling queries. + unsigned getEHExceptionRegister() const; + unsigned getEHHandlerRegister() const; + + int getDwarfRegNum(unsigned RegNum, bool isEH) const; + + bool isLowRegister(unsigned Reg) const; + +private: + unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const; + + unsigned getRegisterPairOdd(unsigned Reg, const MachineFunction &MF) const; +}; + +} // end namespace llvm + +#endif Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp?rev=75016&r1=75015&r2=75016&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Wed Jul 8 12:28:55 2009 @@ -33,128 +33,6 @@ #include "llvm/ADT/SmallVector.h" using namespace llvm; -unsigned ARMBaseRegisterInfo::getRegisterNumbering(unsigned RegEnum) { - using namespace ARM; - switch (RegEnum) { - case R0: case S0: case D0: return 0; - case R1: case S1: case D1: return 1; - case R2: case S2: case D2: return 2; - case R3: case S3: case D3: return 3; - case R4: case S4: case D4: return 4; - case R5: case S5: case D5: return 5; - case R6: case S6: case D6: return 6; - case R7: case S7: case D7: return 7; - case R8: case S8: case D8: return 8; - case R9: case S9: case D9: return 9; - case R10: case S10: case D10: return 10; - case R11: case S11: case D11: return 11; - case R12: case S12: case D12: return 12; - case SP: case S13: case D13: return 13; - case LR: case S14: case D14: return 14; - case PC: case S15: case D15: return 15; - case S16: return 16; - case S17: return 17; - case S18: return 18; - case S19: return 19; - case S20: return 20; - case S21: return 21; - case S22: return 22; - case S23: return 23; - case S24: return 24; - case S25: return 25; - case S26: return 26; - case S27: return 27; - case S28: return 28; - case S29: return 29; - case S30: return 30; - case S31: return 31; - default: - assert(0 && "Unknown ARM register!"); - abort(); - } -} - -unsigned ARMBaseRegisterInfo::getRegisterNumbering(unsigned RegEnum, - bool &isSPVFP) { - isSPVFP = false; - - using namespace ARM; - switch (RegEnum) { - default: - assert(0 && "Unknown ARM register!"); - abort(); - case R0: case D0: return 0; - case R1: case D1: return 1; - case R2: case D2: return 2; - case R3: case D3: return 3; - case R4: case D4: return 4; - case R5: case D5: return 5; - case R6: case D6: return 6; - case R7: case D7: return 7; - case R8: case D8: return 8; - case R9: case D9: return 9; - case R10: case D10: return 10; - case R11: case D11: return 11; - case R12: case D12: return 12; - case SP: case D13: return 13; - case LR: case D14: return 14; - case PC: case D15: return 15; - - case S0: case S1: case S2: case S3: - case S4: case S5: case S6: case S7: - case S8: case S9: case S10: case S11: - case S12: case S13: case S14: case S15: - case S16: case S17: case S18: case S19: - case S20: case S21: case S22: case S23: - case S24: case S25: case S26: case S27: - case S28: case S29: case S30: case S31: { - isSPVFP = true; - switch (RegEnum) { - default: return 0; // Avoid compile time warning. - case S0: return 0; - case S1: return 1; - case S2: return 2; - case S3: return 3; - case S4: return 4; - case S5: return 5; - case S6: return 6; - case S7: return 7; - case S8: return 8; - case S9: return 9; - case S10: return 10; - case S11: return 11; - case S12: return 12; - case S13: return 13; - case S14: return 14; - case S15: return 15; - case S16: return 16; - case S17: return 17; - case S18: return 18; - case S19: return 19; - case S20: return 20; - case S21: return 21; - case S22: return 22; - case S23: return 23; - case S24: return 24; - case S25: return 25; - case S26: return 26; - case S27: return 27; - case S28: return 28; - case S29: return 29; - case S30: return 30; - case S31: return 31; - } - } - } -} - -ARMBaseRegisterInfo::ARMBaseRegisterInfo(const TargetInstrInfo &tii, - const ARMSubtarget &sti) - : ARMGenRegisterInfo(ARM::ADJCALLSTACKDOWN, ARM::ADJCALLSTACKUP), - TII(tii), STI(sti), - FramePtr((STI.isTargetDarwin() || STI.isThumb()) ? ARM::R7 : ARM::R11) { -} - ARMRegisterInfo::ARMRegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &sti) : ARMBaseRegisterInfo(tii, sti) { @@ -188,313 +66,11 @@ .addReg(0).addImm(0).addImm(Pred).addReg(PredReg); } -const unsigned* -ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { - static const unsigned CalleeSavedRegs[] = { - ARM::LR, ARM::R11, ARM::R10, ARM::R9, ARM::R8, - ARM::R7, ARM::R6, ARM::R5, ARM::R4, - - ARM::D15, ARM::D14, ARM::D13, ARM::D12, - ARM::D11, ARM::D10, ARM::D9, ARM::D8, - 0 - }; - - static const unsigned DarwinCalleeSavedRegs[] = { - // Darwin ABI deviates from ARM standard ABI. R9 is not a callee-saved - // register. - ARM::LR, ARM::R7, ARM::R6, ARM::R5, ARM::R4, - ARM::R11, ARM::R10, ARM::R8, - - ARM::D15, ARM::D14, ARM::D13, ARM::D12, - ARM::D11, ARM::D10, ARM::D9, ARM::D8, - 0 - }; - return STI.isTargetDarwin() ? DarwinCalleeSavedRegs : CalleeSavedRegs; -} - -const TargetRegisterClass* const * -ARMBaseRegisterInfo::getCalleeSavedRegClasses(const MachineFunction *MF) const { - static const TargetRegisterClass * const CalleeSavedRegClasses[] = { - &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, - &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, - &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, - - &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, - &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, - 0 - }; - - static const TargetRegisterClass * const ThumbCalleeSavedRegClasses[] = { - &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, - &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::tGPRRegClass, - &ARM::tGPRRegClass,&ARM::tGPRRegClass,&ARM::tGPRRegClass, - - &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, - &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, - 0 - }; - - static const TargetRegisterClass * const DarwinCalleeSavedRegClasses[] = { - &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, - &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass, - &ARM::GPRRegClass, &ARM::GPRRegClass, - - &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, - &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, - 0 - }; - - static const TargetRegisterClass * const DarwinThumbCalleeSavedRegClasses[] ={ - &ARM::GPRRegClass, &ARM::tGPRRegClass, &ARM::tGPRRegClass, - &ARM::tGPRRegClass, &ARM::tGPRRegClass, &ARM::GPRRegClass, - &ARM::GPRRegClass, &ARM::GPRRegClass, - - &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, - &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, - 0 - }; - - if (STI.isThumb()) { - return STI.isTargetDarwin() - ? DarwinThumbCalleeSavedRegClasses : ThumbCalleeSavedRegClasses; - } - return STI.isTargetDarwin() - ? DarwinCalleeSavedRegClasses : CalleeSavedRegClasses; -} - -BitVector ARMBaseRegisterInfo::getReservedRegs(const MachineFunction &MF) const { - // FIXME: avoid re-calculating this everytime. - BitVector Reserved(getNumRegs()); - Reserved.set(ARM::SP); - Reserved.set(ARM::PC); - if (STI.isTargetDarwin() || hasFP(MF)) - Reserved.set(FramePtr); - // Some targets reserve R9. - if (STI.isR9Reserved()) - Reserved.set(ARM::R9); - return Reserved; -} - -bool -ARMBaseRegisterInfo::isReservedReg(const MachineFunction &MF, unsigned Reg) const { - switch (Reg) { - default: break; - case ARM::SP: - case ARM::PC: - return true; - case ARM::R7: - case ARM::R11: - if (FramePtr == Reg && (STI.isTargetDarwin() || hasFP(MF))) - return true; - break; - case ARM::R9: - return STI.isR9Reserved(); - } - - return false; -} - -const TargetRegisterClass *ARMBaseRegisterInfo::getPointerRegClass() const { - return &ARM::GPRRegClass; -} - -/// getAllocationOrder - Returns the register allocation order for a specified -/// register class in the form of a pair of TargetRegisterClass iterators. -std::pair -ARMBaseRegisterInfo::getAllocationOrder(const TargetRegisterClass *RC, - unsigned HintType, unsigned HintReg, - const MachineFunction &MF) const { - // Alternative register allocation orders when favoring even / odd registers - // of register pairs. - - // No FP, R9 is available. - static const unsigned GPREven1[] = { - ARM::R0, ARM::R2, ARM::R4, ARM::R6, ARM::R8, ARM::R10, - ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R7, - ARM::R9, ARM::R11 - }; - static const unsigned GPROdd1[] = { - ARM::R1, ARM::R3, ARM::R5, ARM::R7, ARM::R9, ARM::R11, - ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, - ARM::R8, ARM::R10 - }; - - // FP is R7, R9 is available. - static const unsigned GPREven2[] = { - ARM::R0, ARM::R2, ARM::R4, ARM::R8, ARM::R10, - ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R6, - ARM::R9, ARM::R11 - }; - static const unsigned GPROdd2[] = { - ARM::R1, ARM::R3, ARM::R5, ARM::R9, ARM::R11, - ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, - ARM::R8, ARM::R10 - }; - - // FP is R11, R9 is available. - static const unsigned GPREven3[] = { - ARM::R0, ARM::R2, ARM::R4, ARM::R6, ARM::R8, - ARM::R1, ARM::R3, ARM::R10,ARM::R12,ARM::LR, ARM::R5, ARM::R7, - ARM::R9 - }; - static const unsigned GPROdd3[] = { - ARM::R1, ARM::R3, ARM::R5, ARM::R6, ARM::R9, - ARM::R0, ARM::R2, ARM::R10,ARM::R12,ARM::LR, ARM::R4, ARM::R7, - ARM::R8 - }; - - // No FP, R9 is not available. - static const unsigned GPREven4[] = { - ARM::R0, ARM::R2, ARM::R4, ARM::R6, ARM::R10, - ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R7, ARM::R8, - ARM::R11 - }; - static const unsigned GPROdd4[] = { - ARM::R1, ARM::R3, ARM::R5, ARM::R7, ARM::R11, - ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8, - ARM::R10 - }; - - // FP is R7, R9 is not available. - static const unsigned GPREven5[] = { - ARM::R0, ARM::R2, ARM::R4, ARM::R10, - ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R6, ARM::R8, - ARM::R11 - }; - static const unsigned GPROdd5[] = { - ARM::R1, ARM::R3, ARM::R5, ARM::R11, - ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8, - ARM::R10 - }; - - // FP is R11, R9 is not available. - static const unsigned GPREven6[] = { - ARM::R0, ARM::R2, ARM::R4, ARM::R6, - ARM::R1, ARM::R3, ARM::R10,ARM::R12,ARM::LR, ARM::R5, ARM::R7, ARM::R8 - }; - static const unsigned GPROdd6[] = { - ARM::R1, ARM::R3, ARM::R5, ARM::R7, - ARM::R0, ARM::R2, ARM::R10,ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8 - }; - - - if (HintType == ARMRI::RegPairEven) { - if (isPhysicalRegister(HintReg) && getRegisterPairEven(HintReg, MF) == 0) - // It's no longer possible to fulfill this hint. Return the default - // allocation order. - return std::make_pair(RC->allocation_order_begin(MF), - RC->allocation_order_end(MF)); - - if (!STI.isTargetDarwin() && !hasFP(MF)) { - if (!STI.isR9Reserved()) - return std::make_pair(GPREven1, - GPREven1 + (sizeof(GPREven1)/sizeof(unsigned))); - else - return std::make_pair(GPREven4, - GPREven4 + (sizeof(GPREven4)/sizeof(unsigned))); - } else if (FramePtr == ARM::R7) { - if (!STI.isR9Reserved()) - return std::make_pair(GPREven2, - GPREven2 + (sizeof(GPREven2)/sizeof(unsigned))); - else - return std::make_pair(GPREven5, - GPREven5 + (sizeof(GPREven5)/sizeof(unsigned))); - } else { // FramePtr == ARM::R11 - if (!STI.isR9Reserved()) - return std::make_pair(GPREven3, - GPREven3 + (sizeof(GPREven3)/sizeof(unsigned))); - else - return std::make_pair(GPREven6, - GPREven6 + (sizeof(GPREven6)/sizeof(unsigned))); - } - } else if (HintType == ARMRI::RegPairOdd) { - if (isPhysicalRegister(HintReg) && getRegisterPairOdd(HintReg, MF) == 0) - // It's no longer possible to fulfill this hint. Return the default - // allocation order. - return std::make_pair(RC->allocation_order_begin(MF), - RC->allocation_order_end(MF)); - - if (!STI.isTargetDarwin() && !hasFP(MF)) { - if (!STI.isR9Reserved()) - return std::make_pair(GPROdd1, - GPROdd1 + (sizeof(GPROdd1)/sizeof(unsigned))); - else - return std::make_pair(GPROdd4, - GPROdd4 + (sizeof(GPROdd4)/sizeof(unsigned))); - } else if (FramePtr == ARM::R7) { - if (!STI.isR9Reserved()) - return std::make_pair(GPROdd2, - GPROdd2 + (sizeof(GPROdd2)/sizeof(unsigned))); - else - return std::make_pair(GPROdd5, - GPROdd5 + (sizeof(GPROdd5)/sizeof(unsigned))); - } else { // FramePtr == ARM::R11 - if (!STI.isR9Reserved()) - return std::make_pair(GPROdd3, - GPROdd3 + (sizeof(GPROdd3)/sizeof(unsigned))); - else - return std::make_pair(GPROdd6, - GPROdd6 + (sizeof(GPROdd6)/sizeof(unsigned))); - } - } - return std::make_pair(RC->allocation_order_begin(MF), - RC->allocation_order_end(MF)); -} - -/// ResolveRegAllocHint - Resolves the specified register allocation hint -/// to a physical register. Returns the physical register if it is successful. -unsigned -ARMBaseRegisterInfo::ResolveRegAllocHint(unsigned Type, unsigned Reg, - const MachineFunction &MF) const { - if (Reg == 0 || !isPhysicalRegister(Reg)) - return 0; - if (Type == 0) - return Reg; - else if (Type == (unsigned)ARMRI::RegPairOdd) - // Odd register. - return getRegisterPairOdd(Reg, MF); - else if (Type == (unsigned)ARMRI::RegPairEven) - // Even register. - return getRegisterPairEven(Reg, MF); - return 0; -} - -void -ARMBaseRegisterInfo::UpdateRegAllocHint(unsigned Reg, unsigned NewReg, - MachineFunction &MF) const { - MachineRegisterInfo *MRI = &MF.getRegInfo(); - std::pair Hint = MRI->getRegAllocationHint(Reg); - if ((Hint.first == (unsigned)ARMRI::RegPairOdd || - Hint.first == (unsigned)ARMRI::RegPairEven) && - Hint.second && TargetRegisterInfo::isVirtualRegister(Hint.second)) { - // If 'Reg' is one of the even / odd register pair and it's now changed - // (e.g. coalesced) into a different register. The other register of the - // pair allocation hint must be updated to reflect the relationship - // change. - unsigned OtherReg = Hint.second; - Hint = MRI->getRegAllocationHint(OtherReg); - if (Hint.second == Reg) - // Make sure the pair has not already divorced. - MRI->setRegAllocationHint(OtherReg, Hint.first, NewReg); - } -} - bool ARMRegisterInfo::requiresRegisterScavenging(const MachineFunction &MF) const { return true; } -/// hasFP - Return true if the specified function should have a dedicated frame -/// pointer register. This is true if the function has variable sized allocas -/// or if frame pointer elimination is disabled. -/// -bool ARMBaseRegisterInfo::hasFP(const MachineFunction &MF) const { - const MachineFrameInfo *MFI = MF.getFrameInfo(); - return (NoFramePointerElim || - MFI->hasVarSizedObjects() || - MFI->isFrameAddressTaken()); -} - // hasReservedCallFrame - Under normal circumstances, when a frame pointer is // not required, we reserve argument space for call sites in the function // immediately on entry to the current function. This eliminates the need for @@ -769,239 +345,6 @@ MI.getOperand(i).ChangeToRegister(ScratchReg, false, false, true); } -static unsigned estimateStackSize(MachineFunction &MF, MachineFrameInfo *MFI) { - const MachineFrameInfo *FFI = MF.getFrameInfo(); - int Offset = 0; - for (int i = FFI->getObjectIndexBegin(); i != 0; ++i) { - int FixedOff = -FFI->getObjectOffset(i); - if (FixedOff > Offset) Offset = FixedOff; - } - for (unsigned i = 0, e = FFI->getObjectIndexEnd(); i != e; ++i) { - if (FFI->isDeadObjectIndex(i)) - continue; - Offset += FFI->getObjectSize(i); - unsigned Align = FFI->getObjectAlignment(i); - // Adjust to alignment boundary - Offset = (Offset+Align-1)/Align*Align; - } - return (unsigned)Offset; -} - -void -ARMBaseRegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF, - RegScavenger *RS) const { - // This tells PEI to spill the FP as if it is any other callee-save register - // to take advantage the eliminateFrameIndex machinery. This also ensures it - // is spilled in the order specified by getCalleeSavedRegs() to make it easier - // to combine multiple loads / stores. - bool CanEliminateFrame = true; - bool CS1Spilled = false; - bool LRSpilled = false; - unsigned NumGPRSpills = 0; - SmallVector UnspilledCS1GPRs; - SmallVector UnspilledCS2GPRs; - ARMFunctionInfo *AFI = MF.getInfo(); - - // Don't spill FP if the frame can be eliminated. This is determined - // by scanning the callee-save registers to see if any is used. - const unsigned *CSRegs = getCalleeSavedRegs(); - const TargetRegisterClass* const *CSRegClasses = getCalleeSavedRegClasses(); - for (unsigned i = 0; CSRegs[i]; ++i) { - unsigned Reg = CSRegs[i]; - bool Spilled = false; - if (MF.getRegInfo().isPhysRegUsed(Reg)) { - AFI->setCSRegisterIsSpilled(Reg); - Spilled = true; - CanEliminateFrame = false; - } else { - // Check alias registers too. - for (const unsigned *Aliases = getAliasSet(Reg); *Aliases; ++Aliases) { - if (MF.getRegInfo().isPhysRegUsed(*Aliases)) { - Spilled = true; - CanEliminateFrame = false; - } - } - } - - if (CSRegClasses[i] == &ARM::GPRRegClass) { - if (Spilled) { - NumGPRSpills++; - - if (!STI.isTargetDarwin()) { - if (Reg == ARM::LR) - LRSpilled = true; - CS1Spilled = true; - continue; - } - - // Keep track if LR and any of R4, R5, R6, and R7 is spilled. - switch (Reg) { - case ARM::LR: - LRSpilled = true; - // Fallthrough - case ARM::R4: - case ARM::R5: - case ARM::R6: - case ARM::R7: - CS1Spilled = true; - break; - default: - break; - } - } else { - if (!STI.isTargetDarwin()) { - UnspilledCS1GPRs.push_back(Reg); - continue; - } - - switch (Reg) { - case ARM::R4: - case ARM::R5: - case ARM::R6: - case ARM::R7: - case ARM::LR: - UnspilledCS1GPRs.push_back(Reg); - break; - default: - UnspilledCS2GPRs.push_back(Reg); - break; - } - } - } - } - - bool ForceLRSpill = false; - if (!LRSpilled && AFI->isThumbFunction()) { - unsigned FnSize = TII.GetFunctionSizeInBytes(MF); - // Force LR to be spilled if the Thumb function size is > 2048. This enables - // use of BL to implement far jump. If it turns out that it's not needed - // then the branch fix up path will undo it. - if (FnSize >= (1 << 11)) { - CanEliminateFrame = false; - ForceLRSpill = true; - } - } - - bool ExtraCSSpill = false; - if (!CanEliminateFrame || hasFP(MF)) { - AFI->setHasStackFrame(true); - - // If LR is not spilled, but at least one of R4, R5, R6, and R7 is spilled. - // Spill LR as well so we can fold BX_RET to the registers restore (LDM). - if (!LRSpilled && CS1Spilled) { - MF.getRegInfo().setPhysRegUsed(ARM::LR); - AFI->setCSRegisterIsSpilled(ARM::LR); - NumGPRSpills++; - UnspilledCS1GPRs.erase(std::find(UnspilledCS1GPRs.begin(), - UnspilledCS1GPRs.end(), (unsigned)ARM::LR)); - ForceLRSpill = false; - ExtraCSSpill = true; - } - - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - if (STI.isTargetDarwin() || hasFP(MF)) { - MF.getRegInfo().setPhysRegUsed(FramePtr); - NumGPRSpills++; - } - - // If stack and double are 8-byte aligned and we are spilling an odd number - // of GPRs. Spill one extra callee save GPR so we won't have to pad between - // the integer and double callee save areas. - unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); - if (TargetAlign == 8 && (NumGPRSpills & 1)) { - if (CS1Spilled && !UnspilledCS1GPRs.empty()) { - for (unsigned i = 0, e = UnspilledCS1GPRs.size(); i != e; ++i) { - unsigned Reg = UnspilledCS1GPRs[i]; - // Don't spiil high register if the function is thumb - if (!AFI->isThumbFunction() || - isARMLowRegister(Reg) || Reg == ARM::LR) { - MF.getRegInfo().setPhysRegUsed(Reg); - AFI->setCSRegisterIsSpilled(Reg); - if (!isReservedReg(MF, Reg)) - ExtraCSSpill = true; - break; - } - } - } else if (!UnspilledCS2GPRs.empty() && - !AFI->isThumbFunction()) { - unsigned Reg = UnspilledCS2GPRs.front(); - MF.getRegInfo().setPhysRegUsed(Reg); - AFI->setCSRegisterIsSpilled(Reg); - if (!isReservedReg(MF, Reg)) - ExtraCSSpill = true; - } - } - - // Estimate if we might need to scavenge a register at some point in order - // to materialize a stack offset. If so, either spill one additional - // callee-saved register or reserve a special spill slot to facilitate - // register scavenging. - if (RS && !ExtraCSSpill && !AFI->isThumbFunction()) { - MachineFrameInfo *MFI = MF.getFrameInfo(); - unsigned Size = estimateStackSize(MF, MFI); - unsigned Limit = (1 << 12) - 1; - for (MachineFunction::iterator BB = MF.begin(),E = MF.end();BB != E; ++BB) - for (MachineBasicBlock::iterator I= BB->begin(); I != BB->end(); ++I) { - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - if (I->getOperand(i).isFI()) { - unsigned Opcode = I->getOpcode(); - const TargetInstrDesc &Desc = TII.get(Opcode); - unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask); - if (AddrMode == ARMII::AddrMode3) { - Limit = (1 << 8) - 1; - goto DoneEstimating; - } else if (AddrMode == ARMII::AddrMode5) { - unsigned ThisLimit = ((1 << 8) - 1) * 4; - if (ThisLimit < Limit) - Limit = ThisLimit; - } - } - } - DoneEstimating: - if (Size >= Limit) { - // If any non-reserved CS register isn't spilled, just spill one or two - // extra. That should take care of it! - unsigned NumExtras = TargetAlign / 4; - SmallVector Extras; - while (NumExtras && !UnspilledCS1GPRs.empty()) { - unsigned Reg = UnspilledCS1GPRs.back(); - UnspilledCS1GPRs.pop_back(); - if (!isReservedReg(MF, Reg)) { - Extras.push_back(Reg); - NumExtras--; - } - } - while (NumExtras && !UnspilledCS2GPRs.empty()) { - unsigned Reg = UnspilledCS2GPRs.back(); - UnspilledCS2GPRs.pop_back(); - if (!isReservedReg(MF, Reg)) { - Extras.push_back(Reg); - NumExtras--; - } - } - if (Extras.size() && NumExtras == 0) { - for (unsigned i = 0, e = Extras.size(); i != e; ++i) { - MF.getRegInfo().setPhysRegUsed(Extras[i]); - AFI->setCSRegisterIsSpilled(Extras[i]); - } - } else { - // Reserve a slot closest to SP or frame pointer. - const TargetRegisterClass *RC = &ARM::GPRRegClass; - RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize(), - RC->getAlignment())); - } - } - } - } - - if (ForceLRSpill) { - MF.getRegInfo().setPhysRegUsed(ARM::LR); - AFI->setCSRegisterIsSpilled(ARM::LR); - AFI->setLRIsSpilledForFarJump(true); - } -} - /// Move iterator pass the next bunch of callee save load / store ops for /// the particular spill area (1: integer area 1, 2: integer area 2, /// 3: fp area, 0: don't care). @@ -1227,176 +570,3 @@ } -unsigned ARMBaseRegisterInfo::getRARegister() const { - return ARM::LR; -} - -unsigned ARMBaseRegisterInfo::getFrameRegister(MachineFunction &MF) const { - if (STI.isTargetDarwin() || hasFP(MF)) - return FramePtr; - return ARM::SP; -} - -unsigned ARMBaseRegisterInfo::getEHExceptionRegister() const { - assert(0 && "What is the exception register"); - return 0; -} - -unsigned ARMBaseRegisterInfo::getEHHandlerRegister() const { - assert(0 && "What is the exception handler register"); - return 0; -} - -int ARMBaseRegisterInfo::getDwarfRegNum(unsigned RegNum, bool isEH) const { - return ARMGenRegisterInfo::getDwarfRegNumFull(RegNum, 0); -} - -unsigned ARMBaseRegisterInfo::getRegisterPairEven(unsigned Reg, - const MachineFunction &MF) const { - switch (Reg) { - default: break; - // Return 0 if either register of the pair is a special register. - // So no R12, etc. - case ARM::R1: - return ARM::R0; - case ARM::R3: - // FIXME! - return STI.isThumb() ? 0 : ARM::R2; - case ARM::R5: - return ARM::R4; - case ARM::R7: - return isReservedReg(MF, ARM::R7) ? 0 : ARM::R6; - case ARM::R9: - return isReservedReg(MF, ARM::R9) ? 0 :ARM::R8; - case ARM::R11: - return isReservedReg(MF, ARM::R11) ? 0 : ARM::R10; - - case ARM::S1: - return ARM::S0; - case ARM::S3: - return ARM::S2; - case ARM::S5: - return ARM::S4; - case ARM::S7: - return ARM::S6; - case ARM::S9: - return ARM::S8; - case ARM::S11: - return ARM::S10; - case ARM::S13: - return ARM::S12; - case ARM::S15: - return ARM::S14; - case ARM::S17: - return ARM::S16; - case ARM::S19: - return ARM::S18; - case ARM::S21: - return ARM::S20; - case ARM::S23: - return ARM::S22; - case ARM::S25: - return ARM::S24; - case ARM::S27: - return ARM::S26; - case ARM::S29: - return ARM::S28; - case ARM::S31: - return ARM::S30; - - case ARM::D1: - return ARM::D0; - case ARM::D3: - return ARM::D2; - case ARM::D5: - return ARM::D4; - case ARM::D7: - return ARM::D6; - case ARM::D9: - return ARM::D8; - case ARM::D11: - return ARM::D10; - case ARM::D13: - return ARM::D12; - case ARM::D15: - return ARM::D14; - } - - return 0; -} - -unsigned ARMBaseRegisterInfo::getRegisterPairOdd(unsigned Reg, - const MachineFunction &MF) const { - switch (Reg) { - default: break; - // Return 0 if either register of the pair is a special register. - // So no R12, etc. - case ARM::R0: - return ARM::R1; - case ARM::R2: - // FIXME! - return STI.isThumb() ? 0 : ARM::R3; - case ARM::R4: - return ARM::R5; - case ARM::R6: - return isReservedReg(MF, ARM::R7) ? 0 : ARM::R7; - case ARM::R8: - return isReservedReg(MF, ARM::R9) ? 0 :ARM::R9; - case ARM::R10: - return isReservedReg(MF, ARM::R11) ? 0 : ARM::R11; - - case ARM::S0: - return ARM::S1; - case ARM::S2: - return ARM::S3; - case ARM::S4: - return ARM::S5; - case ARM::S6: - return ARM::S7; - case ARM::S8: - return ARM::S9; - case ARM::S10: - return ARM::S11; - case ARM::S12: - return ARM::S13; - case ARM::S14: - return ARM::S15; - case ARM::S16: - return ARM::S17; - case ARM::S18: - return ARM::S19; - case ARM::S20: - return ARM::S21; - case ARM::S22: - return ARM::S23; - case ARM::S24: - return ARM::S25; - case ARM::S26: - return ARM::S27; - case ARM::S28: - return ARM::S29; - case ARM::S30: - return ARM::S31; - - case ARM::D0: - return ARM::D1; - case ARM::D2: - return ARM::D3; - case ARM::D4: - return ARM::D5; - case ARM::D6: - return ARM::D7; - case ARM::D8: - return ARM::D9; - case ARM::D10: - return ARM::D11; - case ARM::D12: - return ARM::D13; - case ARM::D14: - return ARM::D15; - } - - return 0; -} - -#include "ARMGenRegisterInfo.inc" Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h?rev=75016&r1=75015&r2=75016&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h Wed Jul 8 12:28:55 2009 @@ -16,98 +16,13 @@ #include "ARM.h" #include "llvm/Target/TargetRegisterInfo.h" -#include "ARMGenRegisterInfo.h.inc" +#include "ARMBaseRegisterInfo.h" namespace llvm { class ARMSubtarget; class TargetInstrInfo; class Type; -/// Register allocation hints. -namespace ARMRI { - enum { - RegPairOdd = 1, - RegPairEven = 2 - }; -} - -/// isARMLowRegister - Returns true if the register is low register r0-r7. -/// -static inline bool isARMLowRegister(unsigned Reg) { - using namespace ARM; - switch (Reg) { - case R0: case R1: case R2: case R3: - case R4: case R5: case R6: case R7: - return true; - default: - return false; - } -} - -struct ARMBaseRegisterInfo : public ARMGenRegisterInfo { -protected: - const TargetInstrInfo &TII; - const ARMSubtarget &STI; - - /// FramePtr - ARM physical register used as frame ptr. - unsigned FramePtr; -public: - ARMBaseRegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI); - - /// getRegisterNumbering - Given the enum value for some register, e.g. - /// ARM::LR, return the number that it corresponds to (e.g. 14). - static unsigned getRegisterNumbering(unsigned RegEnum); - - /// Same as previous getRegisterNumbering except it returns true in isSPVFP - /// if the register is a single precision VFP register. - static unsigned getRegisterNumbering(unsigned RegEnum, bool &isSPVFP); - - /// Code Generation virtual methods... - const unsigned *getCalleeSavedRegs(const MachineFunction *MF = 0) const; - - const TargetRegisterClass* const* - getCalleeSavedRegClasses(const MachineFunction *MF = 0) const; - - BitVector getReservedRegs(const MachineFunction &MF) const; - - bool isReservedReg(const MachineFunction &MF, unsigned Reg) const; - - const TargetRegisterClass *getPointerRegClass() const; - - std::pair - getAllocationOrder(const TargetRegisterClass *RC, - unsigned HintType, unsigned HintReg, - const MachineFunction &MF) const; - - unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg, - const MachineFunction &MF) const; - - void UpdateRegAllocHint(unsigned Reg, unsigned NewReg, - MachineFunction &MF) const; - - bool hasFP(const MachineFunction &MF) const; - - void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, - RegScavenger *RS = NULL) const; - - // Debug information queries. - unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; - - // Exception handling queries. - unsigned getEHExceptionRegister() const; - unsigned getEHHandlerRegister() const; - - int getDwarfRegNum(unsigned RegNum, bool isEH) const; - - bool isLowRegister(unsigned Reg) const; - -private: - unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const; - - unsigned getRegisterPairOdd(unsigned Reg, const MachineFunction &MF) const; -}; - struct ARMRegisterInfo : public ARMBaseRegisterInfo { public: ARMRegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI); From david_goodwin at apple.com Wed Jul 8 12:56:02 2009 From: david_goodwin at apple.com (David Goodwin) Date: Wed, 08 Jul 2009 17:56:02 -0000 Subject: [llvm-commits] [llvm] r75017 - /llvm/trunk/CREDITS.TXT Message-ID: <200907081756.n68Hu77t019514@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Jul 8 12:55:48 2009 New Revision: 75017 URL: http://llvm.org/viewvc/llvm-project?rev=75017&view=rev Log: Conform... Modified: llvm/trunk/CREDITS.TXT Modified: llvm/trunk/CREDITS.TXT URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CREDITS.TXT?rev=75017&r1=75016&r2=75017&view=diff ============================================================================== --- llvm/trunk/CREDITS.TXT (original) +++ llvm/trunk/CREDITS.TXT Wed Jul 8 12:55:48 2009 @@ -117,6 +117,10 @@ E: gohman at apple.com D: Miscellaneous bug fixes +N: David Goodwin +E: david at goodwinz.net +D: Thumb-2 code generator + N: David Greene E: greened at obbligato.org D: Miscellaneous bug fixes @@ -306,7 +310,3 @@ N: Bob Wilson E: bob.wilson at acm.org D: Advanced SIMD (NEON) support in the ARM backend - -N: David Goodwin -E: david at goodwinz.net -D: Thumb-2 code generator From edwintorok at gmail.com Wed Jul 8 13:01:53 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Wed, 08 Jul 2009 18:01:53 -0000 Subject: [llvm-commits] [llvm] r75018 - in /llvm/trunk: include/llvm/Support/ lib/Target/ARM/ lib/Target/X86/ lib/Target/X86/AsmPrinter/ lib/VMCore/ Message-ID: <200907081802.n68I22Pc019833@zion.cs.uiuc.edu> Author: edwin Date: Wed Jul 8 13:01:40 2009 New Revision: 75018 URL: http://llvm.org/viewvc/llvm-project?rev=75018&view=rev Log: Start converting to new error handling API. cerr+abort -> llvm_report_error assert(0)+abort -> LLVM_UNREACHABLE (assert(0)+llvm_unreachable-> abort() included) Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86JITInfo.cpp llvm/trunk/lib/VMCore/AsmWriter.cpp llvm/trunk/lib/VMCore/Globals.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/lib/VMCore/PassManager.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/lib/VMCore/Value.cpp llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ErrorHandling.h (original) +++ llvm/trunk/include/llvm/Support/ErrorHandling.h Wed Jul 8 13:01:40 2009 @@ -49,5 +49,7 @@ void llvm_unreachable(void) NORETURN; } +#define LLVM_UNREACHABLE(msg) do { assert(0 && msg); llvm_unreachable(); } while(0); + #endif Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Jul 8 13:01:40 2009 @@ -26,6 +26,7 @@ #include "llvm/CodeGen/MachineLocation.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/RegisterScavenging.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" @@ -69,8 +70,7 @@ case S30: return 30; case S31: return 31; default: - assert(0 && "Unknown ARM register!"); - abort(); + LLVM_UNREACHABLE("Unknown ARM register!"); } } @@ -81,8 +81,7 @@ using namespace ARM; switch (RegEnum) { default: - assert(0 && "Unknown ARM register!"); - abort(); + LLVM_UNREACHABLE("Unknown ARM register!"); case R0: case D0: return 0; case R1: case D1: return 1; case R2: case D2: return 2; Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Wed Jul 8 13:01:40 2009 @@ -35,6 +35,8 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #ifndef NDEBUG #include #endif @@ -221,7 +223,7 @@ template unsigned Emitter::getShiftOp(unsigned Imm) const { switch (ARM_AM::getAM2ShiftOpc(Imm)) { - default: assert(0 && "Unknown shift opc!"); + default: LLVM_UNREACHABLE("Unknown shift opc!"); case ARM_AM::asr: return 2; case ARM_AM::lsl: return 0; case ARM_AM::lsr: return 1; @@ -255,8 +257,10 @@ else if (MO.isMBB()) emitMachineBasicBlock(MO.getMBB(), ARM::reloc_arm_branch); else { - cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "ERROR: Unknown type of MachineOperand: " << MO; + llvm_report_error(Msg.str()); } return 0; } @@ -336,7 +340,7 @@ NumEmitted++; // Keep track of the # of mi's emitted switch (MI.getDesc().TSFlags & ARMII::FormMask) { default: { - assert(0 && "Unhandled instruction encoding format!"); + LLVM_UNREACHABLE("Unhandled instruction encoding format!"); break; } case ARMII::Pseudo: @@ -454,12 +458,10 @@ else if (CFP->getType() == Type::DoubleTy) emitDWordLE(CFP->getValueAPF().bitcastToAPInt().getZExtValue()); else { - assert(0 && "Unable to handle this constantpool entry!"); - abort(); + LLVM_UNREACHABLE("Unable to handle this constantpool entry!"); } } else { - assert(0 && "Unable to handle this constantpool entry!"); - abort(); + LLVM_UNREACHABLE("Unable to handle this constantpool entry!"); } } } @@ -586,13 +588,12 @@ unsigned Opcode = MI.getDesc().Opcode; switch (Opcode) { default: - abort(); // FIXME: + llvm_report_error("ARMCodeEmitter::emitPseudoInstruction");//FIXME: case TargetInstrInfo::INLINEASM: { // We allow inline assembler nodes with empty bodies - they can // implicitly define registers, which is ok for JIT. if (MI.getOperand(0).getSymbolName()[0]) { - assert(0 && "JIT does not support inline asm!\n"); - abort(); + llvm_report_error("JIT does not support inline asm!\n"); } break; } @@ -674,7 +675,7 @@ // ROR - 0111 // RRX - 0110 and bit[11:8] clear. switch (SOpc) { - default: assert(0 && "Unknown shift opc!"); + default: LLVM_UNREACHABLE("Unknown shift opc!"); case ARM_AM::lsl: SBits = 0x1; break; case ARM_AM::lsr: SBits = 0x3; break; case ARM_AM::asr: SBits = 0x5; break; @@ -688,7 +689,7 @@ // ASR - 100 // ROR - 110 switch (SOpc) { - default: assert(0 && "Unknown shift opc!"); + default: LLVM_UNREACHABLE("Unknown shift opc!"); case ARM_AM::lsl: SBits = 0x0; break; case ARM_AM::lsr: SBits = 0x2; break; case ARM_AM::asr: SBits = 0x4; break; @@ -741,8 +742,7 @@ const TargetInstrDesc &TID = MI.getDesc(); if (TID.Opcode == ARM::BFC) { - cerr << "ERROR: ARMv6t2 JIT is not yet supported.\n"; - abort(); + llvm_report_error("ERROR: ARMv6t2 JIT is not yet supported."); } // Part of binary is determined by TableGn. @@ -956,7 +956,7 @@ // DA - Decrement after - bit U = 0 and bit P = 0 // DB - Decrement before - bit U = 0 and bit P = 1 switch (Mode) { - default: assert(0 && "Unknown addressing sub-mode!"); + default: LLVM_UNREACHABLE("Unknown addressing sub-mode!"); case ARM_AM::da: break; case ARM_AM::db: Binary |= 0x1 << ARMII::P_BitShift; break; case ARM_AM::ia: Binary |= 0x1 << ARMII::U_BitShift; break; @@ -1120,7 +1120,7 @@ const TargetInstrDesc &TID = MI.getDesc(); if (TID.Opcode == ARM::TPsoft) - abort(); // FIXME + llvm_report_error("ARM::TPsoft FIXME"); // FIXME // Part of binary is determined by TableGn. unsigned Binary = getBinaryCodeForInstr(MI); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Jul 8 13:01:40 2009 @@ -36,6 +36,7 @@ #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Target/TargetOptions.h" #include "llvm/ADT/VectorExtras.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" using namespace llvm; @@ -2258,7 +2259,7 @@ SDValue ARMTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) { switch (Op.getOpcode()) { - default: assert(0 && "Don't know how to custom lower this!"); abort(); + default: LLVM_UNREACHABLE("Don't know how to custom lower this!"); case ISD::ConstantPool: return LowerConstantPool(Op, DAG); case ISD::GlobalAddress: return Subtarget->isTargetDarwin() ? LowerGlobalAddressDarwin(Op, DAG) : @@ -2593,8 +2594,7 @@ case Intrinsic::arm_neon_vshiftlu: if (isVShiftLImm(N->getOperand(2), VT, true, Cnt)) break; - assert(0 && "invalid shift count for vshll intrinsic"); - abort(); + LLVM_UNREACHABLE("invalid shift count for vshll intrinsic"); case Intrinsic::arm_neon_vrshifts: case Intrinsic::arm_neon_vrshiftu: @@ -2611,8 +2611,7 @@ case Intrinsic::arm_neon_vqshiftsu: if (isVShiftLImm(N->getOperand(2), VT, false, Cnt)) break; - assert(0 && "invalid shift count for vqshlu intrinsic"); - abort(); + LLVM_UNREACHABLE("invalid shift count for vqshlu intrinsic"); case Intrinsic::arm_neon_vshiftn: case Intrinsic::arm_neon_vrshiftn: @@ -2625,8 +2624,7 @@ // Narrowing shifts require an immediate right shift. if (isVShiftRImm(N->getOperand(2), VT, true, true, Cnt)) break; - assert(0 && "invalid shift count for narrowing vector shift intrinsic"); - abort(); + LLVM_UNREACHABLE("invalid shift count for narrowing vector shift intrinsic"); default: assert(0 && "unhandled vector shift"); @@ -2687,8 +2685,7 @@ else if (isVShiftRImm(N->getOperand(3), VT, false, true, Cnt)) VShiftOpc = ARMISD::VSRI; else { - assert(0 && "invalid shift count for vsli/vsri intrinsic"); - abort(); + LLVM_UNREACHABLE("invalid shift count for vsli/vsri intrinsic"); } return DAG.getNode(VShiftOpc, N->getDebugLoc(), N->getValueType(0), Modified: llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp Wed Jul 8 13:01:40 2009 @@ -21,13 +21,14 @@ #include "llvm/CodeGen/JITCodeEmitter.h" #include "llvm/Config/alloca.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Streams.h" #include "llvm/System/Memory.h" #include using namespace llvm; void ARMJITInfo::replaceMachineCodeForFunction(void *Old, void *New) { - abort(); + llvm_report_error("ARMJITInfo::replaceMachineCodeForFunction"); } /// JITCompilerFunction - This contains the address of the JIT function used to @@ -103,8 +104,7 @@ ); #else // Not an ARM host void ARMCompilationCallback() { - assert(0 && "Cannot call ARMCompilationCallback() on a non-ARM arch!\n"); - abort(); + LLVM_UNREACHABLE("Cannot call ARMCompilationCallback() on a non-ARM arch!\n"); } #endif } @@ -123,14 +123,12 @@ // ldr pc, [pc,#-4] // if (!sys::Memory::setRangeWritable((void*)StubAddr, 8)) { - cerr << "ERROR: Unable to mark stub writable\n"; - abort(); + llvm_report_error("ERROR: Unable to mark stub writable"); } *(intptr_t *)StubAddr = 0xe51ff004; // ldr pc, [pc, #-4] *(intptr_t *)(StubAddr+4) = NewVal; if (!sys::Memory::setRangeExecutable((void*)StubAddr, 8)) { - cerr << "ERROR: Unable to mark stub executable\n"; - abort(); + llvm_report_error("ERROR: Unable to mark stub executable"); } } Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Wed Jul 8 13:01:40 2009 @@ -29,6 +29,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" @@ -119,7 +120,7 @@ case ARM::FSTD: NumFSTMGened++; return ARM::FSTMD; - default: abort(); + default: llvm_report_error("Unhandled opcode!"); } return 0; } @@ -441,7 +442,7 @@ case ARM::FLDD: return ARM::FLDMD; case ARM::FSTS: return ARM::FSTMS; case ARM::FSTD: return ARM::FSTMD; - default: abort(); + default: llvm_report_error("Unhandled opcode!"); } return 0; } @@ -454,7 +455,7 @@ case ARM::FLDD: return ARM::FLDMD; case ARM::FSTS: return ARM::FSTMS; case ARM::FSTD: return ARM::FSTMD; - default: abort(); + default: llvm_report_error("Unhandled opcode!"); } return 0; } Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Wed Jul 8 13:01:40 2009 @@ -26,6 +26,7 @@ #include "llvm/CodeGen/MachineLocation.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/RegisterScavenging.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" @@ -290,8 +291,7 @@ break; } default: - assert(0 && "Unsupported addressing mode!"); - abort(); + LLVM_UNREACHABLE("Unsupported addressing mode!"); break; } Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Wed Jul 8 13:01:40 2009 @@ -30,6 +30,7 @@ #include "llvm/ADT/BitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" using namespace llvm; static cl::opt @@ -452,8 +453,7 @@ break; } default: - assert(0 && "Unsupported addressing mode!"); - abort(); + LLVM_UNREACHABLE("Unsupported addressing mode!"); break; } Modified: llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp Wed Jul 8 13:01:40 2009 @@ -30,6 +30,7 @@ #include "llvm/ADT/BitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" using namespace llvm; static cl::opt @@ -452,8 +453,7 @@ break; } default: - assert(0 && "Unsupported addressing mode!"); - abort(); + llvm_report_error("Unsupported addressing mode!"); break; } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Wed Jul 8 13:01:40 2009 @@ -16,6 +16,7 @@ #include "llvm/MC/MCInst.h" #include "X86ATTAsmPrinter.h" #include "llvm/Target/TargetAsmInfo.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -103,7 +104,7 @@ if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) O << DispVal; } else { - abort(); + llvm_report_error("non-immediate displacement for LEA?"); //assert(DispSpec.isGlobal() || DispSpec.isCPI() || // DispSpec.isJTI() || DispSpec.isSymbol()); //printOperand(MI, Op+3, "mem"); Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Wed Jul 8 13:01:40 2009 @@ -31,6 +31,8 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetOptions.h" using namespace llvm; @@ -556,8 +558,7 @@ // We allow inline assembler nodes with empty bodies - they can // implicitly define registers, which is ok for JIT. if (MI.getOperand(0).getSymbolName()[0]) { - assert(0 && "JIT does not support inline asm!\n"); - abort(); + llvm_report_error("JIT does not support inline asm!"); } break; } @@ -805,10 +806,10 @@ } if (!Desc->isVariadic() && CurOp != NumOps) { - cerr << "Cannot encode: "; - MI.dump(); - cerr << '\n'; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "Cannot encode: " << MI; + llvm_report_error(Msg.str()); } } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul 8 13:01:40 2009 @@ -33,6 +33,7 @@ #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Target/TargetOptions.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" @@ -6054,8 +6055,7 @@ SDValue SrcPtr = Op.getOperand(1); SDValue SrcSV = Op.getOperand(2); - assert(0 && "VAArgInst is not yet implemented for x86-64!"); - abort(); + LLVM_UNREACHABLE("VAArgInst is not yet implemented for x86-64!"); return SDValue(); } @@ -6256,7 +6256,7 @@ case Intrinsic::x86_mmx_psrai_d: NewIntNo = Intrinsic::x86_mmx_psra_d; break; - default: abort(); // Can't reach here. + default: LLVM_UNREACHABLE("Impossible intrinsic"); // Can't reach here. } break; } @@ -6428,8 +6428,7 @@ InRegCount += (TD->getTypeSizeInBits(*I) + 31) / 32; if (InRegCount > 2) { - cerr << "Nest register in use - reduce number of inreg parameters!\n"; - abort(); + llvm_report_error("Nest register in use - reduce number of inreg parameters!"); } } break; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Jul 8 13:01:40 2009 @@ -27,6 +27,8 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/LiveVariables.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetAsmInfo.h" using namespace llvm; @@ -1889,8 +1891,7 @@ } else if (RC == &X86::VR64RegClass) { Opc = X86::MMX_MOVQ64mr; } else { - assert(0 && "Unknown regclass"); - abort(); + LLVM_UNREACHABLE("Unknown regclass"); } return Opc; @@ -1982,8 +1983,7 @@ } else if (RC == &X86::VR64RegClass) { Opc = X86::MMX_MOVQ64rm; } else { - assert(0 && "Unknown regclass"); - abort(); + LLVM_UNREACHABLE("Unknown regclass"); } return Opc; @@ -3196,10 +3196,10 @@ } if (!Desc->isVariadic() && CurOp != NumOps) { - cerr << "Cannot determine size: "; - MI.dump(); - cerr << '\n'; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "Cannot determine size: " << MI; + llvm_report_error(Msg.str()); } Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Wed Jul 8 13:01:40 2009 @@ -18,6 +18,7 @@ #include "llvm/Function.h" #include "llvm/Config/alloca.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" #include #include using namespace llvm; @@ -321,8 +322,7 @@ #else // Not an i386 host void X86CompilationCallback() { - assert(0 && "Cannot call X86CompilationCallback() on a non-x86 arch!\n"); - abort(); + LLVM_UNREACHABLE("Cannot call X86CompilationCallback() on a non-x86 arch!\n"); } #endif } Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Wed Jul 8 13:01:40 2009 @@ -31,6 +31,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/CFG.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include @@ -1234,8 +1235,7 @@ case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; case GlobalValue::ExternalLinkage: break; case GlobalValue::GhostLinkage: - Out << "GhostLinkage not allowed in AsmWriter!\n"; - abort(); + llvm_report_error("GhostLinkage not allowed in AsmWriter!"); } } Modified: llvm/trunk/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Globals.cpp (original) +++ llvm/trunk/lib/VMCore/Globals.cpp Wed Jul 8 13:01:40 2009 @@ -19,6 +19,7 @@ #include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/LeakDetector.h" using namespace llvm; @@ -77,8 +78,7 @@ /// Override destroyConstant to make sure it doesn't get called on /// GlobalValue's because they shouldn't be treated like other constants. void GlobalValue::destroyConstant() { - assert(0 && "You can't GV->destroyConstant()!"); - abort(); + LLVM_UNREACHABLE("You can't GV->destroyConstant()!"); } /// copyAttributesFrom - copy all additional attributes (those not needed to @@ -247,7 +247,7 @@ CE->getOpcode() == Instruction::GetElementPtr)) return dyn_cast(CE->getOperand(0)); else - assert(0 && "Unsupported aliasee"); + LLVM_UNREACHABLE("Unsupported aliasee"); } } return 0; Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Wed Jul 8 13:01:40 2009 @@ -16,6 +16,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/Instructions.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/MathExtras.h" @@ -534,12 +535,11 @@ /// 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::setSuccessorV(unsigned idx, BasicBlock *NewSucc) { - assert(0 && "ReturnInst has no successors!"); + LLVM_UNREACHABLE("ReturnInst has no successors!"); } BasicBlock *ReturnInst::getSuccessorV(unsigned idx) const { - assert(0 && "ReturnInst has no successors!"); - abort(); + LLVM_UNREACHABLE("ReturnInst has no successors!"); return 0; } @@ -563,12 +563,11 @@ } void UnwindInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) { - assert(0 && "UnwindInst has no successors!"); + LLVM_UNREACHABLE("UnwindInst has no successors!"); } BasicBlock *UnwindInst::getSuccessorV(unsigned idx) const { - assert(0 && "UnwindInst has no successors!"); - abort(); + LLVM_UNREACHABLE("UnwindInst has no successors!"); return 0; } @@ -588,12 +587,11 @@ } void UnreachableInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) { - assert(0 && "UnwindInst has no successors!"); + LLVM_UNREACHABLE("UnwindInst has no successors!"); } BasicBlock *UnreachableInst::getSuccessorV(unsigned idx) const { - assert(0 && "UnwindInst has no successors!"); - abort(); + LLVM_UNREACHABLE("UnwindInst has no successors!"); return 0; } @@ -2295,7 +2293,7 @@ PTy = NULL; return BitCast; // same size, no-op cast } else { - assert(0 && "Casting pointer or non-first class to float"); + LLVM_UNREACHABLE("Casting pointer or non-first class to float"); } } else if (const VectorType *DestPTy = dyn_cast(DestTy)) { if (const VectorType *SrcPTy = dyn_cast(SrcTy)) { Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Wed Jul 8 13:01:40 2009 @@ -17,6 +17,7 @@ #include "llvm/Support/Timer.h" #include "llvm/Module.h" #include "llvm/ModuleProvider.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Streams.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" @@ -1248,8 +1249,7 @@ bool FunctionPassManager::run(Function &F) { std::string errstr; if (MP->materializeFunction(&F, &errstr)) { - cerr << "Error reading bitcode file: " << errstr << "\n"; - abort(); + llvm_report_error("Error reading bitcode file: " + errstr); } return FPM->run(F); } Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Wed Jul 8 13:01:40 2009 @@ -20,6 +20,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" @@ -264,10 +265,10 @@ } void Type::refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { - abort(); + llvm_report_error("Attempting to refine a derived type!"); } void Type::typeBecameConcrete(const DerivedType *AbsTy) { - abort(); + llvm_report_error("DerivedType is already a concrete type!"); } Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Wed Jul 8 13:01:40 2009 @@ -19,6 +19,7 @@ #include "llvm/Module.h" #include "llvm/ValueSymbolTable.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ValueHandle.h" @@ -514,8 +515,8 @@ cerr << "While deleting: " << *V->getType() << " %" << V->getNameStr() << "\n"; #endif - cerr << "An asserting value handle still pointed to this value!\n"; - abort(); + llvm_report_error("An asserting value handle still pointed to this" + "value!"); case Weak: // Weak just goes to null, which will unlink it from the list. ThisNode->operator=(0); Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=75018&r1=75017&r2=75018&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Jul 8 13:01:40 2009 @@ -62,6 +62,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -93,7 +94,7 @@ } if (Broken) - abort(); + llvm_report_error("Broken module, no Basic Block terminator!"); return false; } @@ -210,8 +211,7 @@ default: assert(0 && "Unknown action"); case AbortProcessAction: msgs << "compilation aborted!\n"; - cerr << msgs.str(); - abort(); + llvm_report_error(msgs.str()); case PrintMessageAction: msgs << "verification continues.\n"; cerr << msgs.str(); From evan.cheng at apple.com Wed Jul 8 13:02:06 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 8 Jul 2009 11:02:06 -0700 Subject: [llvm-commits] [llvm] r75017 - /llvm/trunk/CREDITS.TXT In-Reply-To: <200907081756.n68Hu77t019514@zion.cs.uiuc.edu> References: <200907081756.n68Hu77t019514@zion.cs.uiuc.edu> Message-ID: <0D7C9581-4A1A-4CE0-ACBF-65E27B9DC6A0@apple.com> Wait, it's not conforming enough. Is it Thumb-2 or Thumb2? How come the email doesn't match llvm-commit email? Just kidding... Evan On Jul 8, 2009, at 10:56 AM, David Goodwin wrote: > Author: david_goodwin > Date: Wed Jul 8 12:55:48 2009 > New Revision: 75017 > > URL: http://llvm.org/viewvc/llvm-project?rev=75017&view=rev > Log: > Conform... > > Modified: > llvm/trunk/CREDITS.TXT > > Modified: llvm/trunk/CREDITS.TXT > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CREDITS.TXT?rev=75017&r1=75016&r2=75017&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/CREDITS.TXT (original) > +++ llvm/trunk/CREDITS.TXT Wed Jul 8 12:55:48 2009 > @@ -117,6 +117,10 @@ > E: gohman at apple.com > D: Miscellaneous bug fixes > > +N: David Goodwin > +E: david at goodwinz.net > +D: Thumb-2 code generator > + > N: David Greene > E: greened at obbligato.org > D: Miscellaneous bug fixes > @@ -306,7 +310,3 @@ > N: Bob Wilson > E: bob.wilson at acm.org > D: Advanced SIMD (NEON) support in the ARM backend > - > -N: David Goodwin > -E: david at goodwinz.net > -D: Thumb-2 code generator > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bob.wilson at apple.com Wed Jul 8 13:12:01 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 08 Jul 2009 18:12:01 -0000 Subject: [llvm-commits] [llvm] r75019 - in /llvm/trunk: lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrNEON.td lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/vld1.ll Message-ID: <200907081812.n68IC6pd020173@zion.cs.uiuc.edu> Author: bwilson Date: Wed Jul 8 13:11:30 2009 New Revision: 75019 URL: http://llvm.org/viewvc/llvm-project?rev=75019&view=rev Log: Implement NEON vld1 instructions. Added: llvm/trunk/test/CodeGen/ARM/vld1.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=75019&r1=75018&r2=75019&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Wed Jul 8 13:11:30 2009 @@ -1035,6 +1035,11 @@ : NeonI { } +class NLdSt pattern> + : NeonI { + let Inst{31-24} = 0b11110100; +} + class NDataI pattern> : NeonI { let Inst{31-25} = 0b1111001; Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=75019&r1=75018&r2=75019&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Wed Jul 8 13:11:30 2009 @@ -111,6 +111,29 @@ [(store (v2f64 QPR:$src), GPR:$addr)]>; +// VLD1 : Vector Load (multiple single elements) +class VLD1D + : NLdSt<(outs DPR:$dst), (ins addrmode6:$addr), + !strconcat(OpcodeStr, "\t${dst:dregsingle}, $addr"), + [(set DPR:$dst, (Ty (IntOp addrmode6:$addr, 1)))]>; +class VLD1Q + : NLdSt<(outs QPR:$dst), (ins addrmode6:$addr), + !strconcat(OpcodeStr, "\t${dst:dregpair}, $addr"), + [(set QPR:$dst, (Ty (IntOp addrmode6:$addr, 1)))]>; + +def VLD1d8 : VLD1D<"vld1.8", v8i8, int_arm_neon_vldi>; +def VLD1d16 : VLD1D<"vld1.16", v4i16, int_arm_neon_vldi>; +def VLD1d32 : VLD1D<"vld1.32", v2i32, int_arm_neon_vldi>; +def VLD1df : VLD1D<"vld1.32", v2f32, int_arm_neon_vldf>; +def VLD1d64 : VLD1D<"vld1.64", v1i64, int_arm_neon_vldi>; + +def VLD1q8 : VLD1Q<"vld1.8", v16i8, int_arm_neon_vldi>; +def VLD1q16 : VLD1Q<"vld1.16", v8i16, int_arm_neon_vldi>; +def VLD1q32 : VLD1Q<"vld1.32", v4i32, int_arm_neon_vldi>; +def VLD1qf : VLD1Q<"vld1.32", v4f32, int_arm_neon_vldf>; +def VLD1q64 : VLD1Q<"vld1.64", v2i64, int_arm_neon_vldi>; + + //===----------------------------------------------------------------------===// // NEON pattern fragments //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=75019&r1=75018&r2=75019&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jul 8 13:11:30 2009 @@ -298,8 +298,10 @@ unsigned DRegLo = TRI->getSubReg(Reg, 5); // arm_dsubreg_0 unsigned DRegHi = TRI->getSubReg(Reg, 6); // arm_dsubreg_1 O << '{' - << TRI->getAsmName(DRegLo) << "-" << TRI->getAsmName(DRegHi) + << TRI->getAsmName(DRegLo) << ',' << TRI->getAsmName(DRegHi) << '}'; + } else if (Modifier && strcmp(Modifier, "dregsingle") == 0) { + O << '{' << TRI->getAsmName(Reg) << '}'; } else { O << TRI->getAsmName(Reg); } Added: llvm/trunk/test/CodeGen/ARM/vld1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vld1.ll?rev=75019&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vld1.ll (added) +++ llvm/trunk/test/CodeGen/ARM/vld1.ll Wed Jul 8 13:11:30 2009 @@ -0,0 +1,67 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon > %t +; RUN: grep {vld1\\.8} %t | count 2 +; RUN: grep {vld1\\.16} %t | count 2 +; RUN: grep {vld1\\.32} %t | count 4 +; RUN: grep {vld1\\.64} %t | count 2 + +define <8 x i8> @vld1i8(i8* %A) nounwind { + %tmp1 = call <8 x i8> @llvm.arm.neon.vldi.v8i8(i8* %A, i32 1) + ret <8 x i8> %tmp1 +} + +define <4 x i16> @vld1i16(i16* %A) nounwind { + %tmp1 = call <4 x i16> @llvm.arm.neon.vldi.v4i16(i16* %A, i32 1) + ret <4 x i16> %tmp1 +} + +define <2 x i32> @vld1i32(i32* %A) nounwind { + %tmp1 = call <2 x i32> @llvm.arm.neon.vldi.v2i32(i32* %A, i32 1) + ret <2 x i32> %tmp1 +} + +define <2 x float> @vld1f(float* %A) nounwind { + %tmp1 = call <2 x float> @llvm.arm.neon.vldf.v2f32(float* %A, i32 1) + ret <2 x float> %tmp1 +} + +define <1 x i64> @vld1i64(i64* %A) nounwind { + %tmp1 = call <1 x i64> @llvm.arm.neon.vldi.v1i64(i64* %A, i32 1) + ret <1 x i64> %tmp1 +} + +define <16 x i8> @vld1Qi8(i8* %A) nounwind { + %tmp1 = call <16 x i8> @llvm.arm.neon.vldi.v16i8(i8* %A, i32 1) + ret <16 x i8> %tmp1 +} + +define <8 x i16> @vld1Qi16(i16* %A) nounwind { + %tmp1 = call <8 x i16> @llvm.arm.neon.vldi.v8i16(i16* %A, i32 1) + ret <8 x i16> %tmp1 +} + +define <4 x i32> @vld1Qi32(i32* %A) nounwind { + %tmp1 = call <4 x i32> @llvm.arm.neon.vldi.v4i32(i32* %A, i32 1) + ret <4 x i32> %tmp1 +} + +define <4 x float> @vld1Qf(float* %A) nounwind { + %tmp1 = call <4 x float> @llvm.arm.neon.vldf.v4f32(float* %A, i32 1) + ret <4 x float> %tmp1 +} + +define <2 x i64> @vld1Qi64(i64* %A) nounwind { + %tmp1 = call <2 x i64> @llvm.arm.neon.vldi.v2i64(i64* %A, i32 1) + ret <2 x i64> %tmp1 +} + +declare <8 x i8> @llvm.arm.neon.vldi.v8i8(i8*, i32) nounwind readnone +declare <4 x i16> @llvm.arm.neon.vldi.v4i16(i16*, i32) nounwind readnone +declare <2 x i32> @llvm.arm.neon.vldi.v2i32(i32*, i32) nounwind readnone +declare <2 x float> @llvm.arm.neon.vldf.v2f32(float*, i32) nounwind readnone +declare <1 x i64> @llvm.arm.neon.vldi.v1i64(i64*, i32) nounwind readnone + +declare <16 x i8> @llvm.arm.neon.vldi.v16i8(i8*, i32) nounwind readnone +declare <8 x i16> @llvm.arm.neon.vldi.v8i16(i16*, i32) nounwind readnone +declare <4 x i32> @llvm.arm.neon.vldi.v4i32(i32*, i32) nounwind readnone +declare <4 x float> @llvm.arm.neon.vldf.v4f32(float*, i32) nounwind readnone +declare <2 x i64> @llvm.arm.neon.vldi.v2i64(i64*, i32) nounwind readnone From isanbard at gmail.com Wed Jul 8 13:22:54 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 8 Jul 2009 11:22:54 -0700 Subject: [llvm-commits] [llvm] r75017 - /llvm/trunk/CREDITS.TXT In-Reply-To: <200907081756.n68Hu77t019514@zion.cs.uiuc.edu> References: <200907081756.n68Hu77t019514@zion.cs.uiuc.edu> Message-ID: <16e5fdf90907081122l44d1269an3d295fe9eaa73fa9@mail.gmail.com> On Wed, Jul 8, 2009 at 10:56 AM, David Goodwin wrote: > Author: david_goodwin > Date: Wed Jul ?8 12:55:48 2009 > New Revision: 75017 > > URL: http://llvm.org/viewvc/llvm-project?rev=75017&view=rev > Log: > Conform... > Resistance is futile. :-P Thanks! -bw From david_goodwin at apple.com Wed Jul 8 13:31:58 2009 From: david_goodwin at apple.com (David Goodwin) Date: Wed, 08 Jul 2009 18:31:58 -0000 Subject: [llvm-commits] [llvm] r75020 - in /llvm/trunk/lib/Target/ARM: ARMBaseRegisterInfo.cpp ARMBaseRegisterInfo.h ARMRegisterInfo.cpp ARMRegisterInfo.h Thumb1RegisterInfo.cpp Thumb1RegisterInfo.h Thumb2RegisterInfo.cpp Thumb2RegisterInfo.h Message-ID: <200907081832.n68IW5xD020817@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Jul 8 13:31:39 2009 New Revision: 75020 URL: http://llvm.org/viewvc/llvm-project?rev=75020&view=rev Log: Push methods into base class in preparation for sharing. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=75020&r1=75019&r2=75020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Jul 8 13:31:39 2009 @@ -13,6 +13,7 @@ #include "ARM.h" #include "ARMAddressingModes.h" +#include "ARMBaseInstrInfo.h" #include "ARMBaseRegisterInfo.h" #include "ARMInstrInfo.h" #include "ARMMachineFunctionInfo.h" @@ -147,7 +148,7 @@ } } -ARMBaseRegisterInfo::ARMBaseRegisterInfo(const TargetInstrInfo &tii, +ARMBaseRegisterInfo::ARMBaseRegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &sti) : ARMGenRegisterInfo(ARM::ADJCALLSTACKDOWN, ARM::ADJCALLSTACKUP), TII(tii), STI(sti), @@ -861,4 +862,541 @@ return 0; } + +static inline +const MachineInstrBuilder &AddDefaultPred(const MachineInstrBuilder &MIB) { + return MIB.addImm((int64_t)ARMCC::AL).addReg(0); +} + +static inline +const MachineInstrBuilder &AddDefaultCC(const MachineInstrBuilder &MIB) { + return MIB.addReg(0); +} + +/// emitLoadConstPool - Emits a load from constpool to materialize the +/// specified immediate. +void ARMBaseRegisterInfo:: +emitLoadConstPool(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MBBI, + const TargetInstrInfo *TII, DebugLoc dl, + unsigned DestReg, int Val, + ARMCC::CondCodes Pred, + unsigned PredReg) const { + MachineFunction &MF = *MBB.getParent(); + MachineConstantPool *ConstantPool = MF.getConstantPool(); + Constant *C = ConstantInt::get(Type::Int32Ty, Val); + unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4); + + BuildMI(MBB, MBBI, dl, TII->get(ARM::LDRcp), DestReg) + .addConstantPoolIndex(Idx) + .addReg(0).addImm(0).addImm(Pred).addReg(PredReg); +} + +bool ARMBaseRegisterInfo:: +requiresRegisterScavenging(const MachineFunction &MF) const { + return true; +} + +// hasReservedCallFrame - Under normal circumstances, when a frame pointer is +// not required, we reserve argument space for call sites in the function +// immediately on entry to the current function. This eliminates the need for +// add/sub sp brackets around call sites. Returns true if the call frame is +// included as part of the stack frame. +bool ARMBaseRegisterInfo:: +hasReservedCallFrame(MachineFunction &MF) const { + const MachineFrameInfo *FFI = MF.getFrameInfo(); + unsigned CFSize = FFI->getMaxCallFrameSize(); + // It's not always a good idea to include the call frame as part of the + // stack frame. ARM (especially Thumb) has small immediate offset to + // address the stack frame. So a large call frame can cause poor codegen + // and may even makes it impossible to scavenge a register. + if (CFSize >= ((1 << 12) - 1) / 2) // Half of imm12 + return false; + + return !MF.getFrameInfo()->hasVarSizedObjects(); +} + +/// emitARMRegPlusImmediate - Emits a series of instructions to materialize +/// a destreg = basereg + immediate in ARM code. +static +void emitARMRegPlusImmediate(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MBBI, + unsigned DestReg, unsigned BaseReg, int NumBytes, + ARMCC::CondCodes Pred, unsigned PredReg, + const TargetInstrInfo &TII, + DebugLoc dl) { + bool isSub = NumBytes < 0; + if (isSub) NumBytes = -NumBytes; + + while (NumBytes) { + unsigned RotAmt = ARM_AM::getSOImmValRotate(NumBytes); + unsigned ThisVal = NumBytes & ARM_AM::rotr32(0xFF, RotAmt); + assert(ThisVal && "Didn't extract field correctly"); + + // We will handle these bits from offset, clear them. + NumBytes &= ~ThisVal; + + // Get the properly encoded SOImmVal field. + int SOImmVal = ARM_AM::getSOImmVal(ThisVal); + assert(SOImmVal != -1 && "Bit extraction didn't work?"); + + // Build the new ADD / SUB. + BuildMI(MBB, MBBI, dl, TII.get(isSub ? ARM::SUBri : ARM::ADDri), DestReg) + .addReg(BaseReg, RegState::Kill).addImm(SOImmVal) + .addImm((unsigned)Pred).addReg(PredReg).addReg(0); + BaseReg = DestReg; + } +} + +static void +emitSPUpdate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, + const TargetInstrInfo &TII, DebugLoc dl, + int NumBytes, + ARMCC::CondCodes Pred = ARMCC::AL, unsigned PredReg = 0) { + emitARMRegPlusImmediate(MBB, MBBI, ARM::SP, ARM::SP, NumBytes, + Pred, PredReg, TII, dl); +} + +void ARMBaseRegisterInfo:: +eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, + MachineBasicBlock::iterator I) const { + if (!hasReservedCallFrame(MF)) { + // If we have alloca, convert as follows: + // ADJCALLSTACKDOWN -> sub, sp, sp, amount + // ADJCALLSTACKUP -> add, sp, sp, amount + MachineInstr *Old = I; + DebugLoc dl = Old->getDebugLoc(); + unsigned Amount = Old->getOperand(0).getImm(); + if (Amount != 0) { + // We need to keep the stack aligned properly. To do this, we round the + // amount of space needed for the outgoing arguments up to the next + // alignment boundary. + unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment(); + Amount = (Amount+Align-1)/Align*Align; + + // Replace the pseudo instruction with a new instruction... + unsigned Opc = Old->getOpcode(); + ARMCC::CondCodes Pred = (ARMCC::CondCodes)Old->getOperand(1).getImm(); + if (Opc == ARM::ADJCALLSTACKDOWN || Opc == ARM::tADJCALLSTACKDOWN) { + // Note: PredReg is operand 2 for ADJCALLSTACKDOWN. + unsigned PredReg = Old->getOperand(2).getReg(); + emitSPUpdate(MBB, I, TII, dl, -Amount, Pred, PredReg); + } else { + // Note: PredReg is operand 3 for ADJCALLSTACKUP. + unsigned PredReg = Old->getOperand(3).getReg(); + assert(Opc == ARM::ADJCALLSTACKUP || Opc == ARM::tADJCALLSTACKUP); + emitSPUpdate(MBB, I, TII, dl, Amount, Pred, PredReg); + } + } + } + MBB.erase(I); +} + +/// findScratchRegister - Find a 'free' ARM register. If register scavenger +/// is not being used, R12 is available. Otherwise, try for a call-clobbered +/// register first and then a spilled callee-saved register if that fails. +static +unsigned findScratchRegister(RegScavenger *RS, const TargetRegisterClass *RC, + ARMFunctionInfo *AFI) { + unsigned Reg = RS ? RS->FindUnusedReg(RC, true) : (unsigned) ARM::R12; + assert (!AFI->isThumbFunction()); + if (Reg == 0) + // Try a already spilled CS register. + Reg = RS->FindUnusedReg(RC, AFI->getSpilledCSRegisters()); + + return Reg; +} + +void ARMBaseRegisterInfo:: +eliminateFrameIndex(MachineBasicBlock::iterator II, + int SPAdj, RegScavenger *RS) const{ + unsigned i = 0; + MachineInstr &MI = *II; + MachineBasicBlock &MBB = *MI.getParent(); + MachineFunction &MF = *MBB.getParent(); + ARMFunctionInfo *AFI = MF.getInfo(); + DebugLoc dl = MI.getDebugLoc(); + + while (!MI.getOperand(i).isFI()) { + ++i; + assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); + } + + unsigned FrameReg = ARM::SP; + int FrameIndex = MI.getOperand(i).getIndex(); + int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) + + MF.getFrameInfo()->getStackSize() + SPAdj; + + if (AFI->isGPRCalleeSavedArea1Frame(FrameIndex)) + Offset -= AFI->getGPRCalleeSavedArea1Offset(); + else if (AFI->isGPRCalleeSavedArea2Frame(FrameIndex)) + Offset -= AFI->getGPRCalleeSavedArea2Offset(); + else if (AFI->isDPRCalleeSavedAreaFrame(FrameIndex)) + Offset -= AFI->getDPRCalleeSavedAreaOffset(); + else if (hasFP(MF)) { + assert(SPAdj == 0 && "Unexpected"); + // There is alloca()'s in this function, must reference off the frame + // pointer instead. + FrameReg = getFrameRegister(MF); + Offset -= AFI->getFramePtrSpillOffset(); + } + + unsigned Opcode = MI.getOpcode(); + const TargetInstrDesc &Desc = MI.getDesc(); + unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask); + bool isSub = false; + + // Memory operands in inline assembly always use AddrMode2. + if (Opcode == ARM::INLINEASM) + AddrMode = ARMII::AddrMode2; + + if (Opcode == ARM::ADDri) { + Offset += MI.getOperand(i+1).getImm(); + if (Offset == 0) { + // Turn it into a move. + MI.setDesc(TII.get(ARM::MOVr)); + MI.getOperand(i).ChangeToRegister(FrameReg, false); + MI.RemoveOperand(i+1); + return; + } else if (Offset < 0) { + Offset = -Offset; + isSub = true; + MI.setDesc(TII.get(ARM::SUBri)); + } + + // Common case: small offset, fits into instruction. + int ImmedOffset = ARM_AM::getSOImmVal(Offset); + if (ImmedOffset != -1) { + // Replace the FrameIndex with sp / fp + MI.getOperand(i).ChangeToRegister(FrameReg, false); + MI.getOperand(i+1).ChangeToImmediate(ImmedOffset); + return; + } + + // Otherwise, we fallback to common code below to form the imm offset with + // a sequence of ADDri instructions. First though, pull as much of the imm + // into this ADDri as possible. + unsigned RotAmt = ARM_AM::getSOImmValRotate(Offset); + unsigned ThisImmVal = Offset & ARM_AM::rotr32(0xFF, RotAmt); + + // We will handle these bits from offset, clear them. + Offset &= ~ThisImmVal; + + // Get the properly encoded SOImmVal field. + int ThisSOImmVal = ARM_AM::getSOImmVal(ThisImmVal); + assert(ThisSOImmVal != -1 && "Bit extraction didn't work?"); + MI.getOperand(i+1).ChangeToImmediate(ThisSOImmVal); + } else { + unsigned ImmIdx = 0; + int InstrOffs = 0; + unsigned NumBits = 0; + unsigned Scale = 1; + switch (AddrMode) { + case ARMII::AddrMode2: { + ImmIdx = i+2; + InstrOffs = ARM_AM::getAM2Offset(MI.getOperand(ImmIdx).getImm()); + if (ARM_AM::getAM2Op(MI.getOperand(ImmIdx).getImm()) == ARM_AM::sub) + InstrOffs *= -1; + NumBits = 12; + break; + } + case ARMII::AddrMode3: { + ImmIdx = i+2; + InstrOffs = ARM_AM::getAM3Offset(MI.getOperand(ImmIdx).getImm()); + if (ARM_AM::getAM3Op(MI.getOperand(ImmIdx).getImm()) == ARM_AM::sub) + InstrOffs *= -1; + NumBits = 8; + break; + } + case ARMII::AddrMode5: { + ImmIdx = i+1; + InstrOffs = ARM_AM::getAM5Offset(MI.getOperand(ImmIdx).getImm()); + if (ARM_AM::getAM5Op(MI.getOperand(ImmIdx).getImm()) == ARM_AM::sub) + InstrOffs *= -1; + NumBits = 8; + Scale = 4; + break; + } + default: + LLVM_UNREACHABLE("Unsupported addressing mode!"); + break; + } + + Offset += InstrOffs * Scale; + assert((Offset & (Scale-1)) == 0 && "Can't encode this offset!"); + if (Offset < 0) { + Offset = -Offset; + isSub = true; + } + + // Common case: small offset, fits into instruction. + MachineOperand &ImmOp = MI.getOperand(ImmIdx); + int ImmedOffset = Offset / Scale; + unsigned Mask = (1 << NumBits) - 1; + if ((unsigned)Offset <= Mask * Scale) { + // Replace the FrameIndex with sp + MI.getOperand(i).ChangeToRegister(FrameReg, false); + if (isSub) + ImmedOffset |= 1 << NumBits; + ImmOp.ChangeToImmediate(ImmedOffset); + return; + } + + // Otherwise, it didn't fit. Pull in what we can to simplify the immed. + ImmedOffset = ImmedOffset & Mask; + if (isSub) + ImmedOffset |= 1 << NumBits; + ImmOp.ChangeToImmediate(ImmedOffset); + Offset &= ~(Mask*Scale); + } + + // If we get here, the immediate doesn't fit into the instruction. We folded + // as much as possible above, handle the rest, providing a register that is + // SP+LargeImm. + assert(Offset && "This code isn't needed if offset already handled!"); + + // Insert a set of r12 with the full address: r12 = sp + offset + // If the offset we have is too large to fit into the instruction, we need + // to form it with a series of ADDri's. Do this by taking 8-bit chunks + // out of 'Offset'. + unsigned ScratchReg = findScratchRegister(RS, &ARM::GPRRegClass, AFI); + if (ScratchReg == 0) + // No register is "free". Scavenge a register. + ScratchReg = RS->scavengeRegister(&ARM::GPRRegClass, II, SPAdj); + int PIdx = MI.findFirstPredOperandIdx(); + ARMCC::CondCodes Pred = (PIdx == -1) + ? ARMCC::AL : (ARMCC::CondCodes)MI.getOperand(PIdx).getImm(); + unsigned PredReg = (PIdx == -1) ? 0 : MI.getOperand(PIdx+1).getReg(); + emitARMRegPlusImmediate(MBB, II, ScratchReg, FrameReg, + isSub ? -Offset : Offset, Pred, PredReg, TII, dl); + MI.getOperand(i).ChangeToRegister(ScratchReg, false, false, true); +} + +/// Move iterator pass the next bunch of callee save load / store ops for +/// the particular spill area (1: integer area 1, 2: integer area 2, +/// 3: fp area, 0: don't care). +static void movePastCSLoadStoreOps(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MBBI, + int Opc, unsigned Area, + const ARMSubtarget &STI) { + while (MBBI != MBB.end() && + MBBI->getOpcode() == Opc && MBBI->getOperand(1).isFI()) { + if (Area != 0) { + bool Done = false; + unsigned Category = 0; + switch (MBBI->getOperand(0).getReg()) { + case ARM::R4: case ARM::R5: case ARM::R6: case ARM::R7: + case ARM::LR: + Category = 1; + break; + case ARM::R8: case ARM::R9: case ARM::R10: case ARM::R11: + Category = STI.isTargetDarwin() ? 2 : 1; + break; + case ARM::D8: case ARM::D9: case ARM::D10: case ARM::D11: + case ARM::D12: case ARM::D13: case ARM::D14: case ARM::D15: + Category = 3; + break; + default: + Done = true; + break; + } + if (Done || Category != Area) + break; + } + + ++MBBI; + } +} + +void ARMBaseRegisterInfo:: +emitPrologue(MachineFunction &MF) const { + MachineBasicBlock &MBB = MF.front(); + MachineBasicBlock::iterator MBBI = MBB.begin(); + MachineFrameInfo *MFI = MF.getFrameInfo(); + ARMFunctionInfo *AFI = MF.getInfo(); + unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize(); + unsigned NumBytes = MFI->getStackSize(); + const std::vector &CSI = MFI->getCalleeSavedInfo(); + DebugLoc dl = (MBBI != MBB.end() ? + MBBI->getDebugLoc() : DebugLoc::getUnknownLoc()); + + // Determine the sizes of each callee-save spill areas and record which frame + // belongs to which callee-save spill areas. + unsigned GPRCS1Size = 0, GPRCS2Size = 0, DPRCSSize = 0; + int FramePtrSpillFI = 0; + + if (VARegSaveSize) + emitSPUpdate(MBB, MBBI, TII, dl, -VARegSaveSize); + + if (!AFI->hasStackFrame()) { + if (NumBytes != 0) + emitSPUpdate(MBB, MBBI, TII, dl, -NumBytes); + return; + } + + for (unsigned i = 0, e = CSI.size(); i != e; ++i) { + unsigned Reg = CSI[i].getReg(); + int FI = CSI[i].getFrameIdx(); + switch (Reg) { + case ARM::R4: + case ARM::R5: + case ARM::R6: + case ARM::R7: + case ARM::LR: + if (Reg == FramePtr) + FramePtrSpillFI = FI; + AFI->addGPRCalleeSavedArea1Frame(FI); + GPRCS1Size += 4; + break; + case ARM::R8: + case ARM::R9: + case ARM::R10: + case ARM::R11: + if (Reg == FramePtr) + FramePtrSpillFI = FI; + if (STI.isTargetDarwin()) { + AFI->addGPRCalleeSavedArea2Frame(FI); + GPRCS2Size += 4; + } else { + AFI->addGPRCalleeSavedArea1Frame(FI); + GPRCS1Size += 4; + } + break; + default: + AFI->addDPRCalleeSavedAreaFrame(FI); + DPRCSSize += 8; + } + } + + // Build the new SUBri to adjust SP for integer callee-save spill area 1. + emitSPUpdate(MBB, MBBI, TII, dl, -GPRCS1Size); + movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI); + + // Darwin ABI requires FP to point to the stack slot that contains the + // previous FP. + if (STI.isTargetDarwin() || hasFP(MF)) { + MachineInstrBuilder MIB = + BuildMI(MBB, MBBI, dl, TII.get(ARM::ADDri), FramePtr) + .addFrameIndex(FramePtrSpillFI).addImm(0); + AddDefaultCC(AddDefaultPred(MIB)); + } + + // Build the new SUBri to adjust SP for integer callee-save spill area 2. + emitSPUpdate(MBB, MBBI, TII, dl, -GPRCS2Size); + + // Build the new SUBri to adjust SP for FP callee-save spill area. + movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 2, STI); + emitSPUpdate(MBB, MBBI, TII, dl, -DPRCSSize); + + // Determine starting offsets of spill areas. + unsigned DPRCSOffset = NumBytes - (GPRCS1Size + GPRCS2Size + DPRCSSize); + unsigned GPRCS2Offset = DPRCSOffset + DPRCSSize; + unsigned GPRCS1Offset = GPRCS2Offset + GPRCS2Size; + AFI->setFramePtrSpillOffset(MFI->getObjectOffset(FramePtrSpillFI) + NumBytes); + AFI->setGPRCalleeSavedArea1Offset(GPRCS1Offset); + AFI->setGPRCalleeSavedArea2Offset(GPRCS2Offset); + AFI->setDPRCalleeSavedAreaOffset(DPRCSOffset); + + NumBytes = DPRCSOffset; + if (NumBytes) { + // Insert it after all the callee-save spills. + movePastCSLoadStoreOps(MBB, MBBI, ARM::FSTD, 3, STI); + emitSPUpdate(MBB, MBBI, TII, dl, -NumBytes); + } + + if (STI.isTargetELF() && hasFP(MF)) { + MFI->setOffsetAdjustment(MFI->getOffsetAdjustment() - + AFI->getFramePtrSpillOffset()); + } + + AFI->setGPRCalleeSavedArea1Size(GPRCS1Size); + AFI->setGPRCalleeSavedArea2Size(GPRCS2Size); + AFI->setDPRCalleeSavedAreaSize(DPRCSSize); +} + +static bool isCalleeSavedRegister(unsigned Reg, const unsigned *CSRegs) { + for (unsigned i = 0; CSRegs[i]; ++i) + if (Reg == CSRegs[i]) + return true; + return false; +} + +static bool isCSRestore(MachineInstr *MI, const unsigned *CSRegs) { + return ((MI->getOpcode() == ARM::FLDD || + MI->getOpcode() == ARM::LDR) && + MI->getOperand(1).isFI() && + isCalleeSavedRegister(MI->getOperand(0).getReg(), CSRegs)); +} + +void ARMBaseRegisterInfo:: +emitEpilogue(MachineFunction &MF, + MachineBasicBlock &MBB) const { + MachineBasicBlock::iterator MBBI = prior(MBB.end()); + assert(MBBI->getOpcode() == ARM::BX_RET && + "Can only insert epilog into returning blocks"); + DebugLoc dl = MBBI->getDebugLoc(); + MachineFrameInfo *MFI = MF.getFrameInfo(); + ARMFunctionInfo *AFI = MF.getInfo(); + unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize(); + int NumBytes = (int)MFI->getStackSize(); + + if (!AFI->hasStackFrame()) { + if (NumBytes != 0) + emitSPUpdate(MBB, MBBI, TII, dl, NumBytes); + } else { + // Unwind MBBI to point to first LDR / FLDD. + const unsigned *CSRegs = getCalleeSavedRegs(); + if (MBBI != MBB.begin()) { + do + --MBBI; + while (MBBI != MBB.begin() && isCSRestore(MBBI, CSRegs)); + if (!isCSRestore(MBBI, CSRegs)) + ++MBBI; + } + + // Move SP to start of FP callee save spill area. + NumBytes -= (AFI->getGPRCalleeSavedArea1Size() + + AFI->getGPRCalleeSavedArea2Size() + + AFI->getDPRCalleeSavedAreaSize()); + + // Darwin ABI requires FP to point to the stack slot that contains the + // previous FP. + if ((STI.isTargetDarwin() && NumBytes) || hasFP(MF)) { + NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; + // Reset SP based on frame pointer only if the stack frame extends beyond + // frame pointer stack slot or target is ELF and the function has FP. + if (AFI->getGPRCalleeSavedArea2Size() || + AFI->getDPRCalleeSavedAreaSize() || + AFI->getDPRCalleeSavedAreaOffset()|| + hasFP(MF)) { + if (NumBytes) + BuildMI(MBB, MBBI, dl, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr) + .addImm(NumBytes) + .addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); + else + BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP).addReg(FramePtr) + .addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); + } + } else if (NumBytes) { + emitSPUpdate(MBB, MBBI, TII, dl, NumBytes); + } + + // Move SP to start of integer callee save spill area 2. + movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI); + emitSPUpdate(MBB, MBBI, TII, dl, AFI->getDPRCalleeSavedAreaSize()); + + // Move SP to start of integer callee save spill area 1. + movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 2, STI); + emitSPUpdate(MBB, MBBI, TII, dl, AFI->getGPRCalleeSavedArea2Size()); + + // Move SP to SP upon entry to the function. + movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 1, STI); + emitSPUpdate(MBB, MBBI, TII, dl, AFI->getGPRCalleeSavedArea1Size()); + } + + if (VARegSaveSize) + emitSPUpdate(MBB, MBBI, TII, dl, VARegSaveSize); + +} + #include "ARMGenRegisterInfo.inc" Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h?rev=75020&r1=75019&r2=75020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Wed Jul 8 13:31:39 2009 @@ -20,7 +20,7 @@ namespace llvm { class ARMSubtarget; - class TargetInstrInfo; + class ARMBaseInstrInfo; class Type; /// Register allocation hints. @@ -46,14 +46,16 @@ struct ARMBaseRegisterInfo : public ARMGenRegisterInfo { protected: - const TargetInstrInfo &TII; + const ARMBaseInstrInfo &TII; const ARMSubtarget &STI; /// FramePtr - ARM physical register used as frame ptr. unsigned FramePtr; -public: - ARMBaseRegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI); + // Can be only subclassed. + explicit ARMBaseRegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &STI); + +public: /// getRegisterNumbering - Given the enum value for some register, e.g. /// ARM::LR, return the number that it corresponds to (e.g. 14). static unsigned getRegisterNumbering(unsigned RegEnum); @@ -70,8 +72,6 @@ BitVector getReservedRegs(const MachineFunction &MF) const; - bool isReservedReg(const MachineFunction &MF, unsigned Reg) const; - const TargetRegisterClass *getPointerRegClass() const; std::pair @@ -102,6 +102,33 @@ bool isLowRegister(unsigned Reg) const; + + /// emitLoadConstPool - Emits a load from constpool to materialize the + /// specified immediate. + virtual void emitLoadConstPool(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MBBI, + const TargetInstrInfo *TII, DebugLoc dl, + unsigned DestReg, int Val, + ARMCC::CondCodes Pred = ARMCC::AL, + unsigned PredReg = 0) const; + + /// Code Generation virtual methods... + virtual bool isReservedReg(const MachineFunction &MF, unsigned Reg) const; + + virtual bool requiresRegisterScavenging(const MachineFunction &MF) const; + + virtual bool hasReservedCallFrame(MachineFunction &MF) const; + + virtual void eliminateCallFramePseudoInstr(MachineFunction &MF, + MachineBasicBlock &MBB, + MachineBasicBlock::iterator I) const; + + virtual void eliminateFrameIndex(MachineBasicBlock::iterator II, + int SPAdj, RegScavenger *RS = NULL) const; + + virtual void emitPrologue(MachineFunction &MF) const; + virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; + private: unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const; Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp?rev=75020&r1=75019&r2=75020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Wed Jul 8 13:31:39 2009 @@ -34,539 +34,7 @@ #include "llvm/ADT/SmallVector.h" using namespace llvm; -ARMRegisterInfo::ARMRegisterInfo(const TargetInstrInfo &tii, +ARMRegisterInfo::ARMRegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &sti) : ARMBaseRegisterInfo(tii, sti) { } - -static inline -const MachineInstrBuilder &AddDefaultPred(const MachineInstrBuilder &MIB) { - return MIB.addImm((int64_t)ARMCC::AL).addReg(0); -} - -static inline -const MachineInstrBuilder &AddDefaultCC(const MachineInstrBuilder &MIB) { - return MIB.addReg(0); -} - -/// emitLoadConstPool - Emits a load from constpool to materialize the -/// specified immediate. -void ARMRegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo *TII, DebugLoc dl, - unsigned DestReg, int Val, - ARMCC::CondCodes Pred, - unsigned PredReg) const { - MachineFunction &MF = *MBB.getParent(); - MachineConstantPool *ConstantPool = MF.getConstantPool(); - Constant *C = ConstantInt::get(Type::Int32Ty, Val); - unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4); - - BuildMI(MBB, MBBI, dl, TII->get(ARM::LDRcp), DestReg) - .addConstantPoolIndex(Idx) - .addReg(0).addImm(0).addImm(Pred).addReg(PredReg); -} - -bool -ARMRegisterInfo::requiresRegisterScavenging(const MachineFunction &MF) const { - return true; -} - -// hasReservedCallFrame - Under normal circumstances, when a frame pointer is -// not required, we reserve argument space for call sites in the function -// immediately on entry to the current function. This eliminates the need for -// add/sub sp brackets around call sites. Returns true if the call frame is -// included as part of the stack frame. -bool ARMRegisterInfo::hasReservedCallFrame(MachineFunction &MF) const { - const MachineFrameInfo *FFI = MF.getFrameInfo(); - unsigned CFSize = FFI->getMaxCallFrameSize(); - // It's not always a good idea to include the call frame as part of the - // stack frame. ARM (especially Thumb) has small immediate offset to - // address the stack frame. So a large call frame can cause poor codegen - // and may even makes it impossible to scavenge a register. - if (CFSize >= ((1 << 12) - 1) / 2) // Half of imm12 - return false; - - return !MF.getFrameInfo()->hasVarSizedObjects(); -} - -/// emitARMRegPlusImmediate - Emits a series of instructions to materialize -/// a destreg = basereg + immediate in ARM code. -static -void emitARMRegPlusImmediate(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, - unsigned DestReg, unsigned BaseReg, int NumBytes, - ARMCC::CondCodes Pred, unsigned PredReg, - const TargetInstrInfo &TII, - DebugLoc dl) { - bool isSub = NumBytes < 0; - if (isSub) NumBytes = -NumBytes; - - while (NumBytes) { - unsigned RotAmt = ARM_AM::getSOImmValRotate(NumBytes); - unsigned ThisVal = NumBytes & ARM_AM::rotr32(0xFF, RotAmt); - assert(ThisVal && "Didn't extract field correctly"); - - // We will handle these bits from offset, clear them. - NumBytes &= ~ThisVal; - - // Get the properly encoded SOImmVal field. - int SOImmVal = ARM_AM::getSOImmVal(ThisVal); - assert(SOImmVal != -1 && "Bit extraction didn't work?"); - - // Build the new ADD / SUB. - BuildMI(MBB, MBBI, dl, TII.get(isSub ? ARM::SUBri : ARM::ADDri), DestReg) - .addReg(BaseReg, RegState::Kill).addImm(SOImmVal) - .addImm((unsigned)Pred).addReg(PredReg).addReg(0); - BaseReg = DestReg; - } -} - -static void -emitSPUpdate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo &TII, DebugLoc dl, - int NumBytes, - ARMCC::CondCodes Pred = ARMCC::AL, unsigned PredReg = 0) { - emitARMRegPlusImmediate(MBB, MBBI, ARM::SP, ARM::SP, NumBytes, - Pred, PredReg, TII, dl); -} - -void ARMRegisterInfo:: -eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineBasicBlock::iterator I) const { - if (!hasReservedCallFrame(MF)) { - // If we have alloca, convert as follows: - // ADJCALLSTACKDOWN -> sub, sp, sp, amount - // ADJCALLSTACKUP -> add, sp, sp, amount - MachineInstr *Old = I; - DebugLoc dl = Old->getDebugLoc(); - unsigned Amount = Old->getOperand(0).getImm(); - if (Amount != 0) { - // We need to keep the stack aligned properly. To do this, we round the - // amount of space needed for the outgoing arguments up to the next - // alignment boundary. - unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment(); - Amount = (Amount+Align-1)/Align*Align; - - // Replace the pseudo instruction with a new instruction... - unsigned Opc = Old->getOpcode(); - ARMCC::CondCodes Pred = (ARMCC::CondCodes)Old->getOperand(1).getImm(); - if (Opc == ARM::ADJCALLSTACKDOWN || Opc == ARM::tADJCALLSTACKDOWN) { - // Note: PredReg is operand 2 for ADJCALLSTACKDOWN. - unsigned PredReg = Old->getOperand(2).getReg(); - emitSPUpdate(MBB, I, TII, dl, -Amount, Pred, PredReg); - } else { - // Note: PredReg is operand 3 for ADJCALLSTACKUP. - unsigned PredReg = Old->getOperand(3).getReg(); - assert(Opc == ARM::ADJCALLSTACKUP || Opc == ARM::tADJCALLSTACKUP); - emitSPUpdate(MBB, I, TII, dl, Amount, Pred, PredReg); - } - } - } - MBB.erase(I); -} - -/// findScratchRegister - Find a 'free' ARM register. If register scavenger -/// is not being used, R12 is available. Otherwise, try for a call-clobbered -/// register first and then a spilled callee-saved register if that fails. -static -unsigned findScratchRegister(RegScavenger *RS, const TargetRegisterClass *RC, - ARMFunctionInfo *AFI) { - unsigned Reg = RS ? RS->FindUnusedReg(RC, true) : (unsigned) ARM::R12; - assert (!AFI->isThumbFunction()); - if (Reg == 0) - // Try a already spilled CS register. - Reg = RS->FindUnusedReg(RC, AFI->getSpilledCSRegisters()); - - return Reg; -} - -void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, - int SPAdj, RegScavenger *RS) const{ - unsigned i = 0; - MachineInstr &MI = *II; - MachineBasicBlock &MBB = *MI.getParent(); - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo(); - DebugLoc dl = MI.getDebugLoc(); - - while (!MI.getOperand(i).isFI()) { - ++i; - assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); - } - - unsigned FrameReg = ARM::SP; - int FrameIndex = MI.getOperand(i).getIndex(); - int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) + - MF.getFrameInfo()->getStackSize() + SPAdj; - - if (AFI->isGPRCalleeSavedArea1Frame(FrameIndex)) - Offset -= AFI->getGPRCalleeSavedArea1Offset(); - else if (AFI->isGPRCalleeSavedArea2Frame(FrameIndex)) - Offset -= AFI->getGPRCalleeSavedArea2Offset(); - else if (AFI->isDPRCalleeSavedAreaFrame(FrameIndex)) - Offset -= AFI->getDPRCalleeSavedAreaOffset(); - else if (hasFP(MF)) { - assert(SPAdj == 0 && "Unexpected"); - // There is alloca()'s in this function, must reference off the frame - // pointer instead. - FrameReg = getFrameRegister(MF); - Offset -= AFI->getFramePtrSpillOffset(); - } - - unsigned Opcode = MI.getOpcode(); - const TargetInstrDesc &Desc = MI.getDesc(); - unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask); - bool isSub = false; - - // Memory operands in inline assembly always use AddrMode2. - if (Opcode == ARM::INLINEASM) - AddrMode = ARMII::AddrMode2; - - if (Opcode == ARM::ADDri) { - Offset += MI.getOperand(i+1).getImm(); - if (Offset == 0) { - // Turn it into a move. - MI.setDesc(TII.get(ARM::MOVr)); - MI.getOperand(i).ChangeToRegister(FrameReg, false); - MI.RemoveOperand(i+1); - return; - } else if (Offset < 0) { - Offset = -Offset; - isSub = true; - MI.setDesc(TII.get(ARM::SUBri)); - } - - // Common case: small offset, fits into instruction. - int ImmedOffset = ARM_AM::getSOImmVal(Offset); - if (ImmedOffset != -1) { - // Replace the FrameIndex with sp / fp - MI.getOperand(i).ChangeToRegister(FrameReg, false); - MI.getOperand(i+1).ChangeToImmediate(ImmedOffset); - return; - } - - // Otherwise, we fallback to common code below to form the imm offset with - // a sequence of ADDri instructions. First though, pull as much of the imm - // into this ADDri as possible. - unsigned RotAmt = ARM_AM::getSOImmValRotate(Offset); - unsigned ThisImmVal = Offset & ARM_AM::rotr32(0xFF, RotAmt); - - // We will handle these bits from offset, clear them. - Offset &= ~ThisImmVal; - - // Get the properly encoded SOImmVal field. - int ThisSOImmVal = ARM_AM::getSOImmVal(ThisImmVal); - assert(ThisSOImmVal != -1 && "Bit extraction didn't work?"); - MI.getOperand(i+1).ChangeToImmediate(ThisSOImmVal); - } else { - unsigned ImmIdx = 0; - int InstrOffs = 0; - unsigned NumBits = 0; - unsigned Scale = 1; - switch (AddrMode) { - case ARMII::AddrMode2: { - ImmIdx = i+2; - InstrOffs = ARM_AM::getAM2Offset(MI.getOperand(ImmIdx).getImm()); - if (ARM_AM::getAM2Op(MI.getOperand(ImmIdx).getImm()) == ARM_AM::sub) - InstrOffs *= -1; - NumBits = 12; - break; - } - case ARMII::AddrMode3: { - ImmIdx = i+2; - InstrOffs = ARM_AM::getAM3Offset(MI.getOperand(ImmIdx).getImm()); - if (ARM_AM::getAM3Op(MI.getOperand(ImmIdx).getImm()) == ARM_AM::sub) - InstrOffs *= -1; - NumBits = 8; - break; - } - case ARMII::AddrMode5: { - ImmIdx = i+1; - InstrOffs = ARM_AM::getAM5Offset(MI.getOperand(ImmIdx).getImm()); - if (ARM_AM::getAM5Op(MI.getOperand(ImmIdx).getImm()) == ARM_AM::sub) - InstrOffs *= -1; - NumBits = 8; - Scale = 4; - break; - } - default: - LLVM_UNREACHABLE("Unsupported addressing mode!"); - break; - } - - Offset += InstrOffs * Scale; - assert((Offset & (Scale-1)) == 0 && "Can't encode this offset!"); - if (Offset < 0) { - Offset = -Offset; - isSub = true; - } - - // Common case: small offset, fits into instruction. - MachineOperand &ImmOp = MI.getOperand(ImmIdx); - int ImmedOffset = Offset / Scale; - unsigned Mask = (1 << NumBits) - 1; - if ((unsigned)Offset <= Mask * Scale) { - // Replace the FrameIndex with sp - MI.getOperand(i).ChangeToRegister(FrameReg, false); - if (isSub) - ImmedOffset |= 1 << NumBits; - ImmOp.ChangeToImmediate(ImmedOffset); - return; - } - - // Otherwise, it didn't fit. Pull in what we can to simplify the immed. - ImmedOffset = ImmedOffset & Mask; - if (isSub) - ImmedOffset |= 1 << NumBits; - ImmOp.ChangeToImmediate(ImmedOffset); - Offset &= ~(Mask*Scale); - } - - // If we get here, the immediate doesn't fit into the instruction. We folded - // as much as possible above, handle the rest, providing a register that is - // SP+LargeImm. - assert(Offset && "This code isn't needed if offset already handled!"); - - // Insert a set of r12 with the full address: r12 = sp + offset - // If the offset we have is too large to fit into the instruction, we need - // to form it with a series of ADDri's. Do this by taking 8-bit chunks - // out of 'Offset'. - unsigned ScratchReg = findScratchRegister(RS, &ARM::GPRRegClass, AFI); - if (ScratchReg == 0) - // No register is "free". Scavenge a register. - ScratchReg = RS->scavengeRegister(&ARM::GPRRegClass, II, SPAdj); - int PIdx = MI.findFirstPredOperandIdx(); - ARMCC::CondCodes Pred = (PIdx == -1) - ? ARMCC::AL : (ARMCC::CondCodes)MI.getOperand(PIdx).getImm(); - unsigned PredReg = (PIdx == -1) ? 0 : MI.getOperand(PIdx+1).getReg(); - emitARMRegPlusImmediate(MBB, II, ScratchReg, FrameReg, - isSub ? -Offset : Offset, Pred, PredReg, TII, dl); - MI.getOperand(i).ChangeToRegister(ScratchReg, false, false, true); -} - -/// Move iterator pass the next bunch of callee save load / store ops for -/// the particular spill area (1: integer area 1, 2: integer area 2, -/// 3: fp area, 0: don't care). -static void movePastCSLoadStoreOps(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, - int Opc, unsigned Area, - const ARMSubtarget &STI) { - while (MBBI != MBB.end() && - MBBI->getOpcode() == Opc && MBBI->getOperand(1).isFI()) { - if (Area != 0) { - bool Done = false; - unsigned Category = 0; - switch (MBBI->getOperand(0).getReg()) { - case ARM::R4: case ARM::R5: case ARM::R6: case ARM::R7: - case ARM::LR: - Category = 1; - break; - case ARM::R8: case ARM::R9: case ARM::R10: case ARM::R11: - Category = STI.isTargetDarwin() ? 2 : 1; - break; - case ARM::D8: case ARM::D9: case ARM::D10: case ARM::D11: - case ARM::D12: case ARM::D13: case ARM::D14: case ARM::D15: - Category = 3; - break; - default: - Done = true; - break; - } - if (Done || Category != Area) - break; - } - - ++MBBI; - } -} - -void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const { - MachineBasicBlock &MBB = MF.front(); - MachineBasicBlock::iterator MBBI = MBB.begin(); - MachineFrameInfo *MFI = MF.getFrameInfo(); - ARMFunctionInfo *AFI = MF.getInfo(); - unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize(); - unsigned NumBytes = MFI->getStackSize(); - const std::vector &CSI = MFI->getCalleeSavedInfo(); - DebugLoc dl = (MBBI != MBB.end() ? - MBBI->getDebugLoc() : DebugLoc::getUnknownLoc()); - - // Determine the sizes of each callee-save spill areas and record which frame - // belongs to which callee-save spill areas. - unsigned GPRCS1Size = 0, GPRCS2Size = 0, DPRCSSize = 0; - int FramePtrSpillFI = 0; - - if (VARegSaveSize) - emitSPUpdate(MBB, MBBI, TII, dl, -VARegSaveSize); - - if (!AFI->hasStackFrame()) { - if (NumBytes != 0) - emitSPUpdate(MBB, MBBI, TII, dl, -NumBytes); - return; - } - - for (unsigned i = 0, e = CSI.size(); i != e; ++i) { - unsigned Reg = CSI[i].getReg(); - int FI = CSI[i].getFrameIdx(); - switch (Reg) { - case ARM::R4: - case ARM::R5: - case ARM::R6: - case ARM::R7: - case ARM::LR: - if (Reg == FramePtr) - FramePtrSpillFI = FI; - AFI->addGPRCalleeSavedArea1Frame(FI); - GPRCS1Size += 4; - break; - case ARM::R8: - case ARM::R9: - case ARM::R10: - case ARM::R11: - if (Reg == FramePtr) - FramePtrSpillFI = FI; - if (STI.isTargetDarwin()) { - AFI->addGPRCalleeSavedArea2Frame(FI); - GPRCS2Size += 4; - } else { - AFI->addGPRCalleeSavedArea1Frame(FI); - GPRCS1Size += 4; - } - break; - default: - AFI->addDPRCalleeSavedAreaFrame(FI); - DPRCSSize += 8; - } - } - - // Build the new SUBri to adjust SP for integer callee-save spill area 1. - emitSPUpdate(MBB, MBBI, TII, dl, -GPRCS1Size); - movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI); - - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - if (STI.isTargetDarwin() || hasFP(MF)) { - MachineInstrBuilder MIB = - BuildMI(MBB, MBBI, dl, TII.get(ARM::ADDri), FramePtr) - .addFrameIndex(FramePtrSpillFI).addImm(0); - AddDefaultCC(AddDefaultPred(MIB)); - } - - // Build the new SUBri to adjust SP for integer callee-save spill area 2. - emitSPUpdate(MBB, MBBI, TII, dl, -GPRCS2Size); - - // Build the new SUBri to adjust SP for FP callee-save spill area. - movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 2, STI); - emitSPUpdate(MBB, MBBI, TII, dl, -DPRCSSize); - - // Determine starting offsets of spill areas. - unsigned DPRCSOffset = NumBytes - (GPRCS1Size + GPRCS2Size + DPRCSSize); - unsigned GPRCS2Offset = DPRCSOffset + DPRCSSize; - unsigned GPRCS1Offset = GPRCS2Offset + GPRCS2Size; - AFI->setFramePtrSpillOffset(MFI->getObjectOffset(FramePtrSpillFI) + NumBytes); - AFI->setGPRCalleeSavedArea1Offset(GPRCS1Offset); - AFI->setGPRCalleeSavedArea2Offset(GPRCS2Offset); - AFI->setDPRCalleeSavedAreaOffset(DPRCSOffset); - - NumBytes = DPRCSOffset; - if (NumBytes) { - // Insert it after all the callee-save spills. - movePastCSLoadStoreOps(MBB, MBBI, ARM::FSTD, 3, STI); - emitSPUpdate(MBB, MBBI, TII, dl, -NumBytes); - } - - if (STI.isTargetELF() && hasFP(MF)) { - MFI->setOffsetAdjustment(MFI->getOffsetAdjustment() - - AFI->getFramePtrSpillOffset()); - } - - AFI->setGPRCalleeSavedArea1Size(GPRCS1Size); - AFI->setGPRCalleeSavedArea2Size(GPRCS2Size); - AFI->setDPRCalleeSavedAreaSize(DPRCSSize); -} - -static bool isCalleeSavedRegister(unsigned Reg, const unsigned *CSRegs) { - for (unsigned i = 0; CSRegs[i]; ++i) - if (Reg == CSRegs[i]) - return true; - return false; -} - -static bool isCSRestore(MachineInstr *MI, const unsigned *CSRegs) { - return ((MI->getOpcode() == ARM::FLDD || - MI->getOpcode() == ARM::LDR) && - MI->getOperand(1).isFI() && - isCalleeSavedRegister(MI->getOperand(0).getReg(), CSRegs)); -} - -void ARMRegisterInfo::emitEpilogue(MachineFunction &MF, - MachineBasicBlock &MBB) const { - MachineBasicBlock::iterator MBBI = prior(MBB.end()); - assert(MBBI->getOpcode() == ARM::BX_RET && - "Can only insert epilog into returning blocks"); - DebugLoc dl = MBBI->getDebugLoc(); - MachineFrameInfo *MFI = MF.getFrameInfo(); - ARMFunctionInfo *AFI = MF.getInfo(); - unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize(); - int NumBytes = (int)MFI->getStackSize(); - - if (!AFI->hasStackFrame()) { - if (NumBytes != 0) - emitSPUpdate(MBB, MBBI, TII, dl, NumBytes); - } else { - // Unwind MBBI to point to first LDR / FLDD. - const unsigned *CSRegs = getCalleeSavedRegs(); - if (MBBI != MBB.begin()) { - do - --MBBI; - while (MBBI != MBB.begin() && isCSRestore(MBBI, CSRegs)); - if (!isCSRestore(MBBI, CSRegs)) - ++MBBI; - } - - // Move SP to start of FP callee save spill area. - NumBytes -= (AFI->getGPRCalleeSavedArea1Size() + - AFI->getGPRCalleeSavedArea2Size() + - AFI->getDPRCalleeSavedAreaSize()); - - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - if ((STI.isTargetDarwin() && NumBytes) || hasFP(MF)) { - NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; - // Reset SP based on frame pointer only if the stack frame extends beyond - // frame pointer stack slot or target is ELF and the function has FP. - if (AFI->getGPRCalleeSavedArea2Size() || - AFI->getDPRCalleeSavedAreaSize() || - AFI->getDPRCalleeSavedAreaOffset()|| - hasFP(MF)) { - if (NumBytes) - BuildMI(MBB, MBBI, dl, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr) - .addImm(NumBytes) - .addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); - else - BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP).addReg(FramePtr) - .addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); - } - } else if (NumBytes) { - emitSPUpdate(MBB, MBBI, TII, dl, NumBytes); - } - - // Move SP to start of integer callee save spill area 2. - movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI); - emitSPUpdate(MBB, MBBI, TII, dl, AFI->getDPRCalleeSavedAreaSize()); - - // Move SP to start of integer callee save spill area 1. - movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 2, STI); - emitSPUpdate(MBB, MBBI, TII, dl, AFI->getGPRCalleeSavedArea2Size()); - - // Move SP to SP upon entry to the function. - movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 1, STI); - emitSPUpdate(MBB, MBBI, TII, dl, AFI->getGPRCalleeSavedArea1Size()); - } - - if (VARegSaveSize) - emitSPUpdate(MBB, MBBI, TII, dl, VARegSaveSize); - -} - Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h?rev=75020&r1=75019&r2=75020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h Wed Jul 8 13:31:39 2009 @@ -20,38 +20,12 @@ namespace llvm { class ARMSubtarget; - class TargetInstrInfo; + class ARMBaseInstrInfo; class Type; struct ARMRegisterInfo : public ARMBaseRegisterInfo { public: - ARMRegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI); - - /// emitLoadConstPool - Emits a load from constpool to materialize the - /// specified immediate. - void emitLoadConstPool(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo *TII, DebugLoc dl, - unsigned DestReg, int Val, - ARMCC::CondCodes Pred = ARMCC::AL, - unsigned PredReg = 0) const; - - /// Code Generation virtual methods... - bool isReservedReg(const MachineFunction &MF, unsigned Reg) const; - - bool requiresRegisterScavenging(const MachineFunction &MF) const; - - bool hasReservedCallFrame(MachineFunction &MF) const; - - void eliminateCallFramePseudoInstr(MachineFunction &MF, - MachineBasicBlock &MBB, - MachineBasicBlock::iterator I) const; - - void eliminateFrameIndex(MachineBasicBlock::iterator II, - int SPAdj, RegScavenger *RS = NULL) const; - - void emitPrologue(MachineFunction &MF) const; - void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; + ARMRegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &STI); }; } // end namespace llvm Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=75020&r1=75019&r2=75020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Wed Jul 8 13:31:39 2009 @@ -38,7 +38,7 @@ cl::Hidden, cl::desc("Enable register scavenging on Thumb")); -Thumb1RegisterInfo::Thumb1RegisterInfo(const TargetInstrInfo &tii, +Thumb1RegisterInfo::Thumb1RegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &sti) : ARMBaseRegisterInfo(tii, sti) { } @@ -47,9 +47,10 @@ /// specified immediate. void Thumb1RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, + const TargetInstrInfo *TII, DebugLoc dl, unsigned DestReg, int Val, - const TargetInstrInfo *TII, - DebugLoc dl) const { + ARMCC::CondCodes Pred, + unsigned PredReg) const { MachineFunction &MF = *MBB.getParent(); MachineConstantPool *ConstantPool = MF.getConstantPool(); Constant *C = ConstantInt::get(Type::Int32Ty, Val); @@ -130,7 +131,7 @@ BuildMI(MBB, MBBI, dl, TII.get(ARM::tNEG), LdReg) .addReg(LdReg, RegState::Kill); } else - MRI.emitLoadConstPool(MBB, MBBI, LdReg, NumBytes, &TII, dl); + MRI.emitLoadConstPool(MBB, MBBI, &TII, dl, LdReg, NumBytes); // Emit add / sub. int Opc = (isSub) ? ARM::tSUBrr : (isHigh ? ARM::tADDhirr : ARM::tADDrr); @@ -504,7 +505,7 @@ emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg, Offset, false, TII, *this, dl); else { - emitLoadConstPool(MBB, II, TmpReg, Offset, &TII, dl); + emitLoadConstPool(MBB, II, &TII, dl, TmpReg, Offset); UseRR = true; } } else @@ -542,7 +543,7 @@ emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg, Offset, false, TII, *this, dl); else { - emitLoadConstPool(MBB, II, TmpReg, Offset, &TII, dl); + emitLoadConstPool(MBB, II, &TII, dl, TmpReg, Offset); UseRR = true; } } else Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h?rev=75020&r1=75019&r2=75020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h Wed Jul 8 13:31:39 2009 @@ -20,27 +20,26 @@ namespace llvm { class ARMSubtarget; - class TargetInstrInfo; + class ARMBaseInstrInfo; class Type; struct Thumb1RegisterInfo : public ARMBaseRegisterInfo { public: - Thumb1RegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI); + Thumb1RegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &STI); /// emitLoadConstPool - Emits a load from constpool to materialize the /// specified immediate. - void emitLoadConstPool(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, - unsigned DestReg, int Val, - const TargetInstrInfo *TII, - DebugLoc dl) const; + void emitLoadConstPool(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MBBI, + const TargetInstrInfo *TII, DebugLoc dl, + unsigned DestReg, int Val, + ARMCC::CondCodes Pred = ARMCC::AL, + unsigned PredReg = 0) const; /// Code Generation virtual methods... const TargetRegisterClass * getPhysicalRegisterRegClass(unsigned Reg, MVT VT = MVT::Other) const; - bool isReservedReg(const MachineFunction &MF, unsigned Reg) const; - bool requiresRegisterScavenging(const MachineFunction &MF) const; bool hasReservedCallFrame(MachineFunction &MF) const; Modified: llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp?rev=75020&r1=75019&r2=75020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp Wed Jul 8 13:31:39 2009 @@ -38,7 +38,7 @@ cl::Hidden, cl::desc("Enable register scavenging on Thumb-2")); -Thumb2RegisterInfo::Thumb2RegisterInfo(const TargetInstrInfo &tii, +Thumb2RegisterInfo::Thumb2RegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &sti) : ARMBaseRegisterInfo(tii, sti) { } @@ -47,9 +47,10 @@ /// specified immediate. void Thumb2RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, + const TargetInstrInfo *TII, DebugLoc dl, unsigned DestReg, int Val, - const TargetInstrInfo *TII, - DebugLoc dl) const { + ARMCC::CondCodes Pred, + unsigned PredReg) const { MachineFunction &MF = *MBB.getParent(); MachineConstantPool *ConstantPool = MF.getConstantPool(); Constant *C = ConstantInt::get(Type::Int32Ty, Val); @@ -130,7 +131,7 @@ BuildMI(MBB, MBBI, dl, TII.get(ARM::tNEG), LdReg) .addReg(LdReg, RegState::Kill); } else - MRI.emitLoadConstPool(MBB, MBBI, LdReg, NumBytes, &TII, dl); + MRI.emitLoadConstPool(MBB, MBBI, &TII, dl, LdReg, NumBytes); // Emit add / sub. int Opc = (isSub) ? ARM::tSUBrr : (isHigh ? ARM::tADDhirr : ARM::tADDrr); @@ -504,7 +505,7 @@ emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg, Offset, false, TII, *this, dl); else { - emitLoadConstPool(MBB, II, TmpReg, Offset, &TII, dl); + emitLoadConstPool(MBB, II, &TII, dl, TmpReg, Offset); UseRR = true; } } else @@ -542,7 +543,7 @@ emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg, Offset, false, TII, *this, dl); else { - emitLoadConstPool(MBB, II, TmpReg, Offset, &TII, dl); + emitLoadConstPool(MBB, II, &TII, dl, TmpReg, Offset); UseRR = true; } } else Modified: llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h?rev=75020&r1=75019&r2=75020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h Wed Jul 8 13:31:39 2009 @@ -20,27 +20,26 @@ namespace llvm { class ARMSubtarget; - class TargetInstrInfo; + class ARMBaseInstrInfo; class Type; struct Thumb2RegisterInfo : public ARMBaseRegisterInfo { public: - Thumb2RegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI); + Thumb2RegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &STI); /// emitLoadConstPool - Emits a load from constpool to materialize the /// specified immediate. - void emitLoadConstPool(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, - unsigned DestReg, int Val, - const TargetInstrInfo *TII, - DebugLoc dl) const; + void emitLoadConstPool(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MBBI, + const TargetInstrInfo *TII, DebugLoc dl, + unsigned DestReg, int Val, + ARMCC::CondCodes Pred = ARMCC::AL, + unsigned PredReg = 0) const; /// Code Generation virtual methods... const TargetRegisterClass * getPhysicalRegisterRegClass(unsigned Reg, MVT VT = MVT::Other) const; - bool isReservedReg(const MachineFunction &MF, unsigned Reg) const; - bool requiresRegisterScavenging(const MachineFunction &MF) const; bool hasReservedCallFrame(MachineFunction &MF) const; From isanbard at gmail.com Wed Jul 8 13:36:37 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 8 Jul 2009 11:36:37 -0700 Subject: [llvm-commits] [llvm] r75018 - in /llvm/trunk: include/llvm/Support/ lib/Target/ARM/ lib/Target/X86/ lib/Target/X86/AsmPrinter/ lib/VMCore/ In-Reply-To: <200907081802.n68I22Pc019833@zion.cs.uiuc.edu> References: <200907081802.n68I22Pc019833@zion.cs.uiuc.edu> Message-ID: <16e5fdf90907081136g25a88b96r76a156362fc9eed3@mail.gmail.com> On Wed, Jul 8, 2009 at 11:01 AM, Torok Edwin wrote: > Author: edwin > Date: Wed Jul ?8 13:01:40 2009 > New Revision: 75018 > > URL: http://llvm.org/viewvc/llvm-project?rev=75018&view=rev > Log: > Start converting to new error handling API. > cerr+abort -> llvm_report_error > assert(0)+abort -> LLVM_UNREACHABLE (assert(0)+llvm_unreachable-> abort() included) > > Modified: > ? ?llvm/trunk/include/llvm/Support/ErrorHandling.h > ? ?llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp > ? ?llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp > ? ?llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp > ? ?llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp > ? ?llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp > ? ?llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp > ? ?llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp > ? ?llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp > ? ?llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp > ? ?llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp > ? ?llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > ? ?llvm/trunk/lib/Target/X86/X86InstrInfo.cpp > ? ?llvm/trunk/lib/Target/X86/X86JITInfo.cpp > ? ?llvm/trunk/lib/VMCore/AsmWriter.cpp > ? ?llvm/trunk/lib/VMCore/Globals.cpp > ? ?llvm/trunk/lib/VMCore/Instructions.cpp > ? ?llvm/trunk/lib/VMCore/PassManager.cpp > ? ?llvm/trunk/lib/VMCore/Type.cpp > ? ?llvm/trunk/lib/VMCore/Value.cpp > ? ?llvm/trunk/lib/VMCore/Verifier.cpp > > Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=75018&r1=75017&r2=75018&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Support/ErrorHandling.h (original) > +++ llvm/trunk/include/llvm/Support/ErrorHandling.h Wed Jul ?8 13:01:40 2009 > @@ -49,5 +49,7 @@ > ? void llvm_unreachable(void) NORETURN; > ?} > > +#define LLVM_UNREACHABLE(msg) do { assert(0 && msg); llvm_unreachable(); } while(0); > + This probably shouldn't have the trailing semicolon. -bw From sabre at nondot.org Wed Jul 8 13:44:39 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 18:44:39 -0000 Subject: [llvm-commits] [llvm] r75022 - in /llvm/trunk/utils: FileCheck/ FileCheck/CMakeLists.txt FileCheck/FileCheck.cpp FileCheck/Makefile Makefile TableGen/TableGen.cpp Message-ID: <200907081844.n68IinEa021340@zion.cs.uiuc.edu> Author: lattner Date: Wed Jul 8 13:44:05 2009 New Revision: 75022 URL: http://llvm.org/viewvc/llvm-project?rev=75022&view=rev Log: Add a new little "FileCheck" utility for regression testing. Added: llvm/trunk/utils/FileCheck/ llvm/trunk/utils/FileCheck/CMakeLists.txt llvm/trunk/utils/FileCheck/FileCheck.cpp llvm/trunk/utils/FileCheck/Makefile Modified: llvm/trunk/utils/Makefile llvm/trunk/utils/TableGen/TableGen.cpp Added: llvm/trunk/utils/FileCheck/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileCheck/CMakeLists.txt?rev=75022&view=auto ============================================================================== --- llvm/trunk/utils/FileCheck/CMakeLists.txt (added) +++ llvm/trunk/utils/FileCheck/CMakeLists.txt Wed Jul 8 13:44:05 2009 @@ -0,0 +1,11 @@ +add_executable(FileCheck + FileCheck.cpp + ) + +target_link_libraries(FileCheck LLVMSupport LLVMSystem) +if( MINGW ) + target_link_libraries(FileCheck imagehlp psapi) +endif( MINGW ) +if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD ) + target_link_libraries(FileCheck pthread) +endif() Added: llvm/trunk/utils/FileCheck/FileCheck.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileCheck/FileCheck.cpp?rev=75022&view=auto ============================================================================== --- llvm/trunk/utils/FileCheck/FileCheck.cpp (added) +++ llvm/trunk/utils/FileCheck/FileCheck.cpp Wed Jul 8 13:44:05 2009 @@ -0,0 +1,174 @@ +//===- FileCheck.cpp - Check that File's Contents match what is expected --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// FileCheck does a line-by line check of a file that validates whether it +// contains the expected content. This is useful for regression tests etc. +// +// This program exits with an error status of 2 on error, exit status of 0 if +// the file matched the expected contents, and exit status of 1 if it did not +// contain the expected contents. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/SourceMgr.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/System/Signals.h" +using namespace llvm; + +static cl::opt +CheckFilename(cl::Positional, cl::desc(""), cl::Required); + +static cl::opt +InputFilename("input-file", cl::desc("File to check (defaults to stdin)"), + cl::init("-"), cl::value_desc("filename")); + +static cl::opt +CheckPrefix("check-prefix", cl::init("CHECK"), + cl::desc("Prefix to use from check file (defaults to 'CHECK')")); + + +/// FindStringInBuffer - This is basically just a strstr wrapper that differs in +/// two ways: first it handles 'nul' characters in memory buffers, second, it +/// returns the end of the memory buffer on match failure. +static const char *FindStringInBuffer(const char *Str, const char *CurPtr, + const MemoryBuffer &MB) { + // Check to see if we have a match. If so, just return it. + if (const char *Res = strstr(CurPtr, Str)) + return Res; + + // If not, check to make sure we didn't just find an embedded nul in the + // memory buffer. + const char *Ptr = CurPtr + strlen(CurPtr); + + // If we really reached the end of the file, return it. + if (Ptr == MB.getBufferEnd()) + return Ptr; + + // Otherwise, just skip this section of the file, including the nul. + return FindStringInBuffer(Str, Ptr+1, MB); +} + +/// ReadCheckFile - Read the check file, which specifies the sequence of +/// expected strings. The strings are added to the CheckStrings vector. +static bool ReadCheckFile(SourceMgr &SM, + std::vector > + &CheckStrings) { + // Open the check file, and tell SourceMgr about it. + std::string ErrorStr; + MemoryBuffer *F = + MemoryBuffer::getFileOrSTDIN(CheckFilename.c_str(), &ErrorStr); + if (F == 0) { + errs() << "Could not open check file '" << CheckFilename << "': " + << ErrorStr << '\n'; + return true; + } + SM.AddNewSourceBuffer(F, SMLoc()); + + // Find all instances of CheckPrefix followed by : in the file. The + // MemoryBuffer is guaranteed to be nul terminated, but may have nul's + // embedded into it. We don't support check strings with embedded nuls. + std::string Prefix = CheckPrefix + ":"; + const char *CurPtr = F->getBufferStart(), *BufferEnd = F->getBufferEnd(); + + while (1) { + // See if Prefix occurs in the memory buffer. + const char *Ptr = FindStringInBuffer(Prefix.c_str(), CurPtr, *F); + + // If we didn't find a match, we're done. + if (Ptr == BufferEnd) + break; + + // Okay, we found the prefix, yay. Remember the rest of the line, but + // ignore leading and trailing whitespace. + Ptr += Prefix.size(); + while (*Ptr == ' ' || *Ptr == '\t') + ++Ptr; + + // Scan ahead to the end of line. + CurPtr = Ptr; + while (CurPtr != BufferEnd && *CurPtr != '\n' && *CurPtr != '\r') + ++CurPtr; + + // Ignore trailing whitespace. + while (CurPtr[-1] == ' ' || CurPtr[-1] == '\t') + --CurPtr; + + // Check that there is something on the line. + if (Ptr >= CurPtr) { + SM.PrintMessage(SMLoc::getFromPointer(CurPtr), + "found empty check string with prefix '"+Prefix+"'", + "error"); + return true; + } + + // Okay, add the string we captured to the output vector and move on. + CheckStrings.push_back(std::make_pair(std::string(Ptr, CurPtr), + SMLoc::getFromPointer(Ptr))); + } + + if (CheckStrings.empty()) { + errs() << "error: no check strings found with prefix '" << Prefix << "'\n"; + return true; + } + + return false; +} + + +int main(int argc, char **argv) { + sys::PrintStackTraceOnErrorSignal(); + PrettyStackTraceProgram X(argc, argv); + cl::ParseCommandLineOptions(argc, argv); + + SourceMgr SM; + + // Read the expected strings from the check file. + std::vector > CheckStrings; + if (ReadCheckFile(SM, CheckStrings)) + return 2; + + // Open the file to check and add it to SourceMgr. + std::string ErrorStr; + MemoryBuffer *F = + MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), &ErrorStr); + if (F == 0) { + errs() << "Could not open input file '" << InputFilename << "': " + << ErrorStr << '\n'; + return true; + } + SM.AddNewSourceBuffer(F, SMLoc()); + + // Check that we have all of the expected strings, in order, in the input + // file. + const char *CurPtr = F->getBufferStart(), *BufferEnd = F->getBufferEnd(); + + for (unsigned StrNo = 0, e = CheckStrings.size(); StrNo != e; ++StrNo) { + const std::pair &CheckStr = CheckStrings[StrNo]; + + // Find StrNo in the file. + const char *Ptr = FindStringInBuffer(CheckStr.first.c_str(), CurPtr, *F); + + // If we found a match, we're done, move on. + if (Ptr != BufferEnd) { + CurPtr = Ptr + CheckStr.first.size(); + continue; + } + + // Otherwise, we have an error, emit an error message. + SM.PrintMessage(CheckStr.second, "expected string not found in input", + "error"); + SM.PrintMessage(SMLoc::getFromPointer(CurPtr), "scanning from here", + "note"); + } + + return 0; +} Added: llvm/trunk/utils/FileCheck/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileCheck/Makefile?rev=75022&view=auto ============================================================================== --- llvm/trunk/utils/FileCheck/Makefile (added) +++ llvm/trunk/utils/FileCheck/Makefile Wed Jul 8 13:44:05 2009 @@ -0,0 +1,18 @@ +##===- utils/FileCheck/Makefile ----------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +TOOLNAME = FileCheck +USEDLIBS = LLVMSupport.a LLVMSystem.a + +# This tool has no plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +include $(LEVEL)/Makefile.common + Modified: llvm/trunk/utils/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/Makefile?rev=75022&r1=75021&r2=75022&view=diff ============================================================================== --- llvm/trunk/utils/Makefile (original) +++ llvm/trunk/utils/Makefile Wed Jul 8 13:44:05 2009 @@ -8,7 +8,7 @@ ##===----------------------------------------------------------------------===## LEVEL = .. -PARALLEL_DIRS := TableGen fpcmp PerfectShuffle unittest +PARALLEL_DIRS := TableGen fpcmp PerfectShuffle FileCheck unittest EXTRA_DIST := cgiplotNLT.pl check-each-file codegen-diff countloc.sh cvsupdate \ DSAclean.py DSAextract.py emacs findsym.pl GenLibDeps.pl \ Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=75022&r1=75021&r2=75022&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Wed Jul 8 13:44:05 2009 @@ -17,12 +17,6 @@ #include "Record.h" #include "TGParser.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/System/Signals.h" -#include "llvm/Support/FileUtilities.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/raw_ostream.h" #include "CallingConvEmitter.h" #include "CodeEmitterGen.h" #include "RegisterInfoEmitter.h" @@ -35,6 +29,12 @@ #include "IntrinsicEmitter.h" #include "LLVMCConfigurationEmitter.h" #include "ClangDiagnosticsEmitter.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/System/Signals.h" #include #include using namespace llvm; @@ -138,7 +138,7 @@ std::string ErrorStr; MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr); if (F == 0) { - errs() << "Could not open input file '" + Filename + "': " + errs() << "Could not open input file '" << Filename << "': " << ErrorStr <<"\n"; return true; } From sabre at nondot.org Wed Jul 8 13:48:50 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 18:48:50 -0000 Subject: [llvm-commits] [llvm] r75023 - /llvm/trunk/test/CodeGen/X86/zero-remat.ll Message-ID: <200907081848.n68Imr0P021511@zion.cs.uiuc.edu> Author: lattner Date: Wed Jul 8 13:48:24 2009 New Revision: 75023 URL: http://llvm.org/viewvc/llvm-project?rev=75023&view=rev Log: convert a test to "FileCheck" style. Modified: llvm/trunk/test/CodeGen/X86/zero-remat.ll Modified: llvm/trunk/test/CodeGen/X86/zero-remat.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/zero-remat.ll?rev=75023&r1=75022&r2=75023&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/zero-remat.ll (original) +++ llvm/trunk/test/CodeGen/X86/zero-remat.ll Wed Jul 8 13:48:24 2009 @@ -1,16 +1,40 @@ -; RUN: llvm-as < %s | llc -march=x86-64 | grep xor | count 4 +; RUN: llvm-as < %s | llc -march=x86-64 | FileCheck %s --check-prefix=CHECK-64 ; RUN: llvm-as < %s | llc -march=x86-64 -stats -info-output-file - | grep asm-printer | grep 12 -; RUN: llvm-as < %s | llc -march=x86 | grep fldz -; RUN: llvm-as < %s | llc -march=x86 | not grep fldl +; RUN: llvm-as < %s | llc -march=x86 | FileCheck %s --check-prefix=CHECK-32 declare void @bar(double %x) declare void @barf(float %x) define double @foo() nounwind { + call void @bar(double 0.0) ret double 0.0 + +;CHECK-32: foo: +;CHECK-32: call +;CHECK-32: fldz +;CHECK-32: ret + +;CHECK-64: foo: +;CHECK-64: pxor +;CHECK-64: call +;CHECK-64: pxor +;CHECK-64: ret } + + define float @foof() nounwind { call void @barf(float 0.0) ret float 0.0 + +;CHECK-32: foof: +;CHECK-32: call +;CHECK-32: fldz +;CHECK-32: ret + +;CHECK-64: foof: +;CHECK-64: pxor +;CHECK-64: call +;CHECK-64: pxor +;CHECK-64: ret } From sabre at nondot.org Wed Jul 8 13:51:38 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 18:51:38 -0000 Subject: [llvm-commits] [llvm] r75024 - /llvm/trunk/test/CodeGen/X86/vec_compare.ll Message-ID: <200907081851.n68Ipcep021636@zion.cs.uiuc.edu> Author: lattner Date: Wed Jul 8 13:51:25 2009 New Revision: 75024 URL: http://llvm.org/viewvc/llvm-project?rev=75024&view=rev Log: add some more check for vector compares. Modified: llvm/trunk/test/CodeGen/X86/vec_compare.ll Modified: llvm/trunk/test/CodeGen/X86/vec_compare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_compare.ll?rev=75024&r1=75023&r2=75024&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_compare.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_compare.ll Wed Jul 8 13:51:25 2009 @@ -1,9 +1,43 @@ -; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep pcmpgtd +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | FileCheck %s -define <4 x i32> @test2(<4 x i32> %A, <4 x i32> %B) nounwind { +define <4 x i32> @test1(<4 x i32> %A, <4 x i32> %B) nounwind { +; CHECK: test1: +; CHECK: pcmpgtd +; CHECK: ret + %C = icmp sgt <4 x i32> %A, %B %D = sext <4 x i1> %C to <4 x i32> ret <4 x i32> %D } +define <4 x i32> @test2(<4 x i32> %A, <4 x i32> %B) nounwind { +; CHECK: test2: +; CHECK: pcmp +; CHECK: pcmp +; CHECK: xorps +; CHECK: ret + %C = icmp sge <4 x i32> %A, %B + %D = sext <4 x i1> %C to <4 x i32> + ret <4 x i32> %D +} + +define <4 x i32> @test3(<4 x i32> %A, <4 x i32> %B) nounwind { +; CHECK: test3: +; CHECK: pcmpgtd +; CHECK: movaps +; CHECK: ret + %C = icmp slt <4 x i32> %A, %B + %D = sext <4 x i1> %C to <4 x i32> + ret <4 x i32> %D +} + +define <4 x i32> @test4(<4 x i32> %A, <4 x i32> %B) nounwind { +; CHECK: test4: +; CHECK: movaps +; CHECK: pcmpgtd +; CHECK: ret + %C = icmp ugt <4 x i32> %A, %B + %D = sext <4 x i1> %C to <4 x i32> + ret <4 x i32> %D +} From nlewycky at google.com Wed Jul 8 13:59:52 2009 From: nlewycky at google.com (Nick Lewycky) Date: Wed, 8 Jul 2009 11:59:52 -0700 Subject: [llvm-commits] [llvm] r74991 - in /llvm/trunk: docs/ include/llvm-c/ include/llvm/ include/llvm/Bitcode/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Tran Message-ID: 2009/7/7 Chris Lattner > > On Jul 7, 2009, at 8:04 PM, Nick Lewycky wrote: > > > Author: nicholas > > Date: Tue Jul 7 22:04:38 2009 > > New Revision: 74991 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=74991&view=rev > > Log: > > Remove the vicmp and vfcmp instructions. Because we never had a > > release with > > these instructions, no autoupgrade or backwards compatibility > > support is > > provided. > > Nice! > > > +++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h Tue Jul 7 > > 22:04:38 2009 > > @@ -210,7 +210,8 @@ > > FUNC_CODE_INST_GETRESULT = 25, // GETRESULT: [ty, opval, n] > > FUNC_CODE_INST_EXTRACTVAL = 26, // EXTRACTVAL: [n x operands] > > FUNC_CODE_INST_INSERTVAL = 27, // INSERTVAL: [n x operands] > > - // fcmp/icmp returning Int1TY or vector of Int1Ty, NOT for > > vicmp/vfcmp > > + // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, > > exists to > > + // support legacy vicmp/vfcmp instructions. > > FUNC_CODE_INST_CMP2 = 28, // CMP2: [opty, opval, > > opval, pred] > > Can this just be removed? > No. The code as released in LLVM 2.5 had basically no correlation between whether the instruction was [if]cmp or v[if]cmp and whether INST_CMP or INST_CMP2 was used. The comment was only there to confuse the reader. As of this commit, we only generate INST_CMP2 which has a better chance of being read correctly by previous versions of LLVM than if we were to generate INST_CMP. To make matters worse, some 2.5 version bitcode files would contain icmp (but not fcmp?) with a bad type, such as a constant expression icmp that returns <4 x i32> instead of <4 x i1>. Such files will no longer load with current LLVM; we could try to autoupgrade those but I'm inclined to say "sorry, older LLVMs were buggy and produced bad IR in rare circumstances" than to try to deal with it. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090708/36b60626/attachment.html From edwintorok at gmail.com Wed Jul 8 14:03:45 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 08 Jul 2009 22:03:45 +0300 Subject: [llvm-commits] [llvm] r75018 - in /llvm/trunk: include/llvm/Support/ lib/Target/ARM/ lib/Target/X86/ lib/Target/X86/AsmPrinter/ lib/VMCore/ In-Reply-To: <16e5fdf90907081136g25a88b96r76a156362fc9eed3@mail.gmail.com> References: <200907081802.n68I22Pc019833@zion.cs.uiuc.edu> <16e5fdf90907081136g25a88b96r76a156362fc9eed3@mail.gmail.com> Message-ID: <4A54ED91.7050606@gmail.com> On 2009-07-08 21:36, Bill Wendling wrote: >> +#define LLVM_UNREACHABLE(msg) do { assert(0 && msg); llvm_unreachable(); } while(0); >> + >> > This probably shouldn't have the trailing semicolon. > > Indeed, thanks for noticing. Fixed in upcoming commit. Best regards, --Edwin From resistor at mac.com Wed Jul 8 14:04:44 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 08 Jul 2009 19:04:44 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r75026 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-convert.cpp llvm-types.cpp Message-ID: <200907081904.n68J4q0G022193@zion.cs.uiuc.edu> Author: resistor Date: Wed Jul 8 14:04:14 2009 New Revision: 75026 URL: http://llvm.org/viewvc/llvm-project?rev=75026&view=rev Log: Update for LLVM API change. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=75026&r1=75025&r2=75026&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Jul 8 14:04:14 2009 @@ -286,10 +286,10 @@ Constant *LLVMValuesTable = ConstantStruct::get(ValuesForPCH, false); // Create variable to hold this string table. - new GlobalVariable(TheModule->getContext(), LLVMValuesTable->getType(), true, + new GlobalVariable(*TheModule, LLVMValuesTable->getType(), true, GlobalValue::ExternalLinkage, LLVMValuesTable, - "llvm.pch.values", TheModule); + "llvm.pch.values"); } /// eraseLocalLLVMValues - drop all non-global values from the LLVM values map. @@ -804,9 +804,9 @@ Constant *Array = ConstantArray::get(ArrayType::get(InitList[0]->getType(), InitList.size()), InitList); - new GlobalVariable(TheModule->getContext(), Array->getType(), false, + new GlobalVariable(*TheModule, Array->getType(), false, GlobalValue::AppendingLinkage, - Array, Name, TheModule); + Array, Name); } // llvm_asm_file_end - Finish the .s file. @@ -839,9 +839,9 @@ ArrayType *AT = ArrayType::get(SBP, AUGs.size()); Constant *Init = ConstantArray::get(AT, AUGs); - GlobalValue *gv = new GlobalVariable(TheModule->getContext(), AT, false, + GlobalValue *gv = new GlobalVariable(*TheModule, AT, false, GlobalValue::AppendingLinkage, Init, - "llvm.used", TheModule); + "llvm.used"); gv->setSection("llvm.metadata"); AttributeUsedGlobals.clear(); } @@ -852,10 +852,9 @@ ConstantArray::get(ArrayType::get(AttributeAnnotateGlobals[0]->getType(), AttributeAnnotateGlobals.size()), AttributeAnnotateGlobals); - GlobalValue *gv = new GlobalVariable(TheModule->getContext(), - Array->getType(), false, + GlobalValue *gv = new GlobalVariable(*TheModule, Array->getType(), false, GlobalValue::AppendingLinkage, Array, - "llvm.global.annotations", TheModule); + "llvm.global.annotations"); gv->setSection("llvm.metadata"); AttributeAnnotateGlobals.clear(); } @@ -1015,10 +1014,10 @@ if (!Aliasee) { if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))) { if (GlobalVariable *GV = dyn_cast(V)) - Aliasee = new GlobalVariable(TheModule->getContext(), - GV->getType(), GV->isConstant(), + Aliasee = new GlobalVariable(*TheModule, GV->getType(), + GV->isConstant(), GlobalVariable::ExternalWeakLinkage, - NULL, AliaseeName, TheModule); + NULL, AliaseeName); else if (Function *F = dyn_cast(V)) Aliasee = Function::Create(F->getFunctionType(), Function::ExternalWeakLinkage, @@ -1087,10 +1086,9 @@ if (Slot) return Slot; // Create a new string global. - GlobalVariable *GV = new GlobalVariable(TheModule->getContext(), - Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(*TheModule, Init->getType(), true, GlobalVariable::InternalLinkage, - Init, ".str", TheModule); + Init, ".str"); GV->setSection("llvm.metadata"); Slot = GV; return GV; @@ -1197,10 +1195,10 @@ // different from the union element used for the type. if (GV->getType()->getElementType() != Init->getType()) { GV->removeFromParent(); - GlobalVariable *NGV = new GlobalVariable(TheModule->getContext(), - Init->getType(), GV->isConstant(), + GlobalVariable *NGV = new GlobalVariable(*TheModule, Init->getType(), + GV->isConstant(), GV->getLinkage(), 0, - GV->getName(), TheModule); + GV->getName()); NGV->setVisibility(GV->getVisibility()); NGV->setSection(GV->getSection()); NGV->setAlignment(GV->getAlignment()); @@ -1274,10 +1272,10 @@ // different from the union element used for the type. if (GV->getType()->getElementType() != Init->getType()) { GV->removeFromParent(); - GlobalVariable *NGV = new GlobalVariable(TheModule->getContext(), - Init->getType(), GV->isConstant(), + GlobalVariable *NGV = new GlobalVariable(*TheModule, Init->getType(), + GV->isConstant(), GlobalValue::ExternalLinkage, 0, - GV->getName(), TheModule); + GV->getName()); GV->replaceAllUsesWith(TheFolder->CreateBitCast(NGV, GV->getType())); changeLLVMConstant(GV, NGV); delete GV; @@ -1568,9 +1566,8 @@ if (Ty == Type::VoidTy) Ty = StructType::get(NULL, NULL); if (Name[0] == 0) { // Global has no name. - GV = new GlobalVariable(TheModule->getContext(), - Ty, false, GlobalValue::ExternalLinkage, 0, - "", TheModule); + GV = new GlobalVariable(*TheModule, Ty, false, + GlobalValue::ExternalLinkage, 0, ""); // Check for external weak linkage. if (DECL_EXTERNAL(decl) && DECL_WEAK(decl)) @@ -1587,9 +1584,8 @@ GlobalVariable *GVE = TheModule->getGlobalVariable(Name, true); if (GVE == 0) { - GV = new GlobalVariable(TheModule->getContext(), - Ty, false, GlobalValue::ExternalLinkage,0, - Name, TheModule); + GV = new GlobalVariable(*TheModule, Ty, false, + GlobalValue::ExternalLinkage, 0, Name); // Check for external weak linkage. if (DECL_EXTERNAL(decl) && DECL_WEAK(decl)) Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=75026&r1=75025&r2=75026&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Jul 8 14:04:14 2009 @@ -7779,9 +7779,9 @@ if (Slot) return Slot; // Create a new complex global. - Slot = new GlobalVariable(TheModule->getContext(), Init->getType(), true, + Slot = new GlobalVariable(*TheModule, Init->getType(), true, GlobalVariable::InternalLinkage, - Init, ".cpx", TheModule); + Init, ".cpx"); return Slot; } @@ -7804,12 +7804,12 @@ // Create a new string global. const TargetAsmInfo *TAI = TheTarget->getTargetAsmInfo(); - GlobalVariable *GV = new GlobalVariable(TheModule->getContext(), - Init->getType(), StringIsConstant, + GlobalVariable *GV = new GlobalVariable(*TheModule, Init->getType(), + StringIsConstant, GlobalVariable::InternalLinkage, Init, TAI ? TAI->getStringConstantPrefix() : - ".str", TheModule); + ".str"); GV->setAlignment(TYPE_ALIGN(TREE_TYPE(exp)) / 8); Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=75026&r1=75025&r2=75026&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Jul 8 14:04:14 2009 @@ -192,11 +192,11 @@ Constant *LTypesNameTable = ConstantStruct::get(LTypesNames, false); // Create variable to hold this string table. - GlobalVariable *GV = new GlobalVariable(TheModule->getContext(), + GlobalVariable *GV = new GlobalVariable(*TheModule, LTypesNameTable->getType(), true, GlobalValue::ExternalLinkage, LTypesNameTable, - "llvm.pch.types", TheModule); + "llvm.pch.types"); } //===----------------------------------------------------------------------===// From edwintorok at gmail.com Wed Jul 8 14:04:44 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Wed, 08 Jul 2009 19:04:44 -0000 Subject: [llvm-commits] [llvm] r75027 - in /llvm/trunk: include/llvm/CodeGen/ include/llvm/Support/ lib/Target/Alpha/ lib/Target/Alpha/AsmPrinter/ lib/Target/IA64/ lib/Target/IA64/AsmPrinter/ lib/Target/MSP430/ lib/Target/Mips/AsmPrinter/ lib/Target/PIC16/ lib/Target/Sparc/AsmPrinter/ lib/Target/X86/ lib/Target/XCore/ utils/TableGen/ Message-ID: <200907081905.n68J5D0L022265@zion.cs.uiuc.edu> Author: edwin Date: Wed Jul 8 14:04:27 2009 New Revision: 75027 URL: http://llvm.org/viewvc/llvm-project?rev=75027&view=rev Log: Convert more abort() calls to llvm_report_error(). Also remove trailing semicolon. Modified: llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h llvm/trunk/include/llvm/Support/ErrorHandling.h llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp llvm/trunk/utils/TableGen/CodeEmitterGen.cpp llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h Wed Jul 8 14:04:27 2009 @@ -18,6 +18,8 @@ #define LLVM_CODEGEN_MACHINECODEEMITTER_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" namespace llvm { Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Wed Jul 8 14:04:27 2009 @@ -19,6 +19,8 @@ #include "llvm/Pass.h" #include "llvm/Constant.h" #include "llvm/CodeGen/SelectionDAG.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" namespace llvm { class FastISel; Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ErrorHandling.h (original) +++ llvm/trunk/include/llvm/Support/ErrorHandling.h Wed Jul 8 14:04:27 2009 @@ -49,7 +49,7 @@ void llvm_unreachable(void) NORETURN; } -#define LLVM_UNREACHABLE(msg) do { assert(0 && msg); llvm_unreachable(); } while(0); +#define LLVM_UNREACHABLE(msg) do { assert(0 && msg); llvm_unreachable(); } while(0) #endif Modified: llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp Wed Jul 8 14:04:27 2009 @@ -26,6 +26,8 @@ #include "llvm/Function.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; namespace { @@ -164,8 +166,7 @@ case Alpha::R30 : case Alpha::F30 : return 30; case Alpha::R31 : case Alpha::F31 : return 31; default: - assert(0 && "Unhandled reg"); - abort(); + LLVM_UNREACHABLE("Unhandled reg"); } } @@ -216,8 +217,7 @@ Offset = MI.getOperand(3).getImm(); break; default: - assert(0 && "unknown relocatable instruction"); - abort(); + LLVM_UNREACHABLE("unknown relocatable instruction"); } if (MO.isGlobal()) MCE.addRelocation(MachineRelocation::getGV(MCE.getCurrentPCOffset(), @@ -234,9 +234,11 @@ } else if (MO.isMBB()) { MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(), Alpha::reloc_bsr, MO.getMBB())); - }else { - cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n"; - abort(); + } else { + std::string msg; + raw_string_ostream Msg(msg); + Msg << "ERROR: Unknown type of MachineOperand: " << MO; + llvm_report_error(Msg.str()); } return rv; Modified: llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp Wed Jul 8 14:04:27 2009 @@ -323,7 +323,7 @@ T, CurDAG->getRegister(Alpha::F31, T), CurDAG->getRegister(Alpha::F31, T)); } else { - abort(); + llvm_report_error("Unhandled FP constant type"); } break; } Modified: llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp Wed Jul 8 14:04:27 2009 @@ -24,6 +24,7 @@ #include "llvm/Module.h" #include "llvm/Intrinsics.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" using namespace llvm; /// AddLiveIn - This helper function adds the specified physical register to the @@ -312,8 +313,7 @@ SDValue()); switch (Op.getNumOperands()) { default: - assert(0 && "Do not know how to return this many arguments!"); - abort(); + LLVM_UNREACHABLE("Do not know how to return this many arguments!"); case 1: break; //return SDValue(); // ret void is legal Modified: llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp Wed Jul 8 14:04:27 2009 @@ -19,6 +19,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/Support/ErrorHandling.h" using namespace llvm; AlphaInstrInfo::AlphaInstrInfo() @@ -200,7 +201,7 @@ .addReg(SrcReg, getKillRegState(isKill)) .addFrameIndex(FrameIdx).addReg(Alpha::F31); else - abort(); + llvm_report_error("Unhandled register class"); } void AlphaInstrInfo::storeRegToAddr(MachineFunction &MF, unsigned SrcReg, @@ -216,7 +217,7 @@ else if (RC == Alpha::GPRCRegisterClass) Opc = Alpha::STQ; else - abort(); + llvm_report_error("Unhandled register class"); DebugLoc DL = DebugLoc::getUnknownLoc(); MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc)).addReg(SrcReg, getKillRegState(isKill)); @@ -245,7 +246,7 @@ BuildMI(MBB, MI, DL, get(Alpha::LDQ), DestReg) .addFrameIndex(FrameIdx).addReg(Alpha::F31); else - abort(); + llvm_report_error("Unhandled register class"); } void AlphaInstrInfo::loadRegFromAddr(MachineFunction &MF, unsigned DestReg, @@ -260,7 +261,7 @@ else if (RC == Alpha::GPRCRegisterClass) Opc = Alpha::LDQ; else - abort(); + llvm_report_error("Unhandled register class"); DebugLoc DL = DebugLoc::getUnknownLoc(); MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc), DestReg); Modified: llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp Wed Jul 8 14:04:27 2009 @@ -184,8 +184,7 @@ ); #else void AlphaCompilationCallback() { - cerr << "Cannot call AlphaCompilationCallback() on a non-Alpha arch!\n"; - abort(); + LLVM_UNREACHABLE("Cannot call AlphaCompilationCallback() on a non-Alpha arch!"); } #endif } Modified: llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp Wed Jul 8 14:04:27 2009 @@ -28,6 +28,8 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include @@ -244,8 +246,10 @@ BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDA), Alpha::R30) .addImm(getLower16(NumBytes)).addReg(Alpha::R30); } else { - cerr << "Too big a stack frame at " << NumBytes << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "Too big a stack frame at " + NumBytes; + llvm_report_error(Msg.str()); } //now if we need to, save the old FP and set the new @@ -294,8 +298,10 @@ BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDA), Alpha::R30) .addImm(getLower16(NumBytes)).addReg(Alpha::R30); } else { - cerr << "Too big a stack frame at " << NumBytes << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "Too big a stack frame at " + NumBytes; + llvm_report_error(Msg.str()); } } } Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Wed Jul 8 14:04:27 2009 @@ -25,6 +25,7 @@ #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/Statistic.h" @@ -100,8 +101,7 @@ return; case MachineOperand::MO_Immediate: - cerr << "printOp() does not handle immediate values\n"; - abort(); + llvm_report_error("printOp() does not handle immediate values"); return; case MachineOperand::MO_MachineBasicBlock: @@ -188,8 +188,7 @@ // Print the assembly for the instruction. ++EmittedInsts; if (!printInstruction(II)) { - assert(0 && "Unhandled instruction in asm writer!"); - abort(); + LLVM_UNREACHABLE("Unhandled instruction in asm writer!"); } } } @@ -249,9 +248,7 @@ case GlobalValue::PrivateLinkage: break; default: - assert(0 && "Unknown linkage type!"); - cerr << "Unknown linkage type!\n"; - abort(); + LLVM_UNREACHABLE("Unknown linkage type!"); } // 3: Type, Size, Align Modified: llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp Wed Jul 8 14:04:27 2009 @@ -26,6 +26,7 @@ #include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/Target/TargetAsmInfo.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/Statistic.h" @@ -317,16 +318,13 @@ case GlobalValue::PrivateLinkage: break; case GlobalValue::GhostLinkage: - cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n"; - abort(); + llvm_report_error("GhostLinkage cannot appear in IA64AsmPrinter!"); case GlobalValue::DLLImportLinkage: - cerr << "DLLImport linkage is not supported by this target!\n"; - abort(); + llvm_report_error("DLLImport linkage is not supported by this target!"); case GlobalValue::DLLExportLinkage: - cerr << "DLLExport linkage is not supported by this target!\n"; - abort(); + llvm_report_error("DLLExport linkage is not supported by this target!"); default: - assert(0 && "Unknown linkage type!"); + LLVM_UNREACHABLE("Unknown linkage type!"); } EmitAlignment(Align, GVar); Modified: llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp Wed Jul 8 14:04:27 2009 @@ -19,6 +19,7 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Constants.h" #include "llvm/Function.h" using namespace llvm; @@ -579,8 +580,7 @@ switch(Op.getNumOperands()) { default: - assert(0 && "Do not know how to return this many arguments!"); - abort(); + LLVM_UNREACHABLE("Do not know how to return this many arguments!"); case 1: AR_PFSVal = DAG.getCopyFromReg(Op.getOperand(0), dl, VirtGPR, MVT::i64); AR_PFSVal = DAG.getCopyToReg(AR_PFSVal.getValue(1), dl, IA64::AR_PFS, Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Wed Jul 8 14:04:27 2009 @@ -32,6 +32,7 @@ #include "llvm/CodeGen/SelectionDAGISel.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/ADT/VectorExtras.h" using namespace llvm; @@ -190,11 +191,14 @@ // Arguments passed in registers MVT RegVT = VA.getLocVT(); switch (RegVT.getSimpleVT()) { - default: - cerr << "LowerFORMAL_ARGUMENTS Unhandled argument type: " - << RegVT.getSimpleVT() - << "\n"; - abort(); + default: + { + std::string msg; + raw_string_ostream Msg(msg); + Msg << "LowerFORMAL_ARGUMENTS Unhandled argument type: " + << RegVT.getSimpleVT(); + llvm_report_error(Msg.str()); + } case MVT::i16: unsigned VReg = RegInfo.createVirtualRegister(MSP430::GR16RegisterClass); Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Wed Jul 8 14:04:27 2009 @@ -33,6 +33,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" @@ -405,7 +406,7 @@ break; default: - O << ""; abort (); break; + llvm_report_error(""); break; } if (closeP) O << ")"; @@ -544,16 +545,13 @@ printSizeAndType = false; break; case GlobalValue::GhostLinkage: - cerr << "Should not have any unmaterialized functions!\n"; - abort(); + llvm_report_error("Should not have any unmaterialized functions!"); case GlobalValue::DLLImportLinkage: - cerr << "DLLImport linkage is not supported by this target!\n"; - abort(); + llvm_report_error("DLLImport linkage is not supported by this target!"); case GlobalValue::DLLExportLinkage: - cerr << "DLLExport linkage is not supported by this target!\n"; - abort(); + llvm_report_error("DLLExport linkage is not supported by this target!"); default: - assert(0 && "Unknown linkage type!"); + LLVM_UNREACHABLE("Unknown linkage type!"); } EmitAlignment(Align, GVar); Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Wed Jul 8 14:04:27 2009 @@ -23,6 +23,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/Support/ErrorHandling.h" using namespace llvm; @@ -1227,8 +1228,7 @@ // return should have odd number of operands if ((Op.getNumOperands() % 2) == 0 ) { - assert(0 && "Do not know how to return this many arguments!"); - abort(); + LLVM_UNREACHABLE("Do not know how to return this many arguments!"); } // Number of values to return Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Wed Jul 8 14:04:27 2009 @@ -26,6 +26,7 @@ #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetAsmInfo.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/Statistic.h" @@ -184,7 +185,7 @@ << MO.getIndex(); break; default: - O << ""; abort (); break; + llvm_report_error(""); break; } if (CloseParen) O << ")"; } @@ -298,16 +299,13 @@ case GlobalValue::InternalLinkage: break; case GlobalValue::GhostLinkage: - cerr << "Should not have any unmaterialized functions!\n"; - abort(); + llvm_report_error("Should not have any unmaterialized functions!"); case GlobalValue::DLLImportLinkage: - cerr << "DLLImport linkage is not supported by this target!\n"; - abort(); + llvm_report_error("DLLImport linkage is not supported by this target!"); case GlobalValue::DLLExportLinkage: - cerr << "DLLExport linkage is not supported by this target!\n"; - abort(); + llvm_report_error("DLLExport linkage is not supported by this target!"); default: - assert(0 && "Unknown linkage type!"); + LLVM_UNREACHABLE("Unknown linkage type!"); } EmitAlignment(Align, GVar); Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul 8 14:04:27 2009 @@ -1186,8 +1186,7 @@ // If this is x86-64, and we disabled SSE, we can't return FP values if ((CopyVT == MVT::f32 || CopyVT == MVT::f64) && ((Is64Bit || TheCall->isInreg()) && !Subtarget->hasSSE1())) { - cerr << "SSE register return with SSE disabled\n"; - exit(1); + llvm_report_error("SSE register return with SSE disabled"); } // If this is a call to a function that returns an fp value on the floating Modified: llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Wed Jul 8 14:04:27 2009 @@ -32,6 +32,7 @@ #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include @@ -186,8 +187,7 @@ switch (GV->getLinkage()) { case GlobalValue::AppendingLinkage: - cerr << "AppendingLinkage is not supported by this target!\n"; - abort(); + llvm_report_error("AppendingLinkage is not supported by this target!"); case GlobalValue::LinkOnceAnyLinkage: case GlobalValue::LinkOnceODRLinkage: case GlobalValue::WeakAnyLinkage: @@ -204,14 +204,11 @@ case GlobalValue::PrivateLinkage: break; case GlobalValue::GhostLinkage: - cerr << "Should not have any unmaterialized functions!\n"; - abort(); + llvm_report_error("Should not have any unmaterialized functions!"); case GlobalValue::DLLImportLinkage: - cerr << "DLLImport linkage is not supported by this target!\n"; - abort(); + llvm_report_error("DLLImport linkage is not supported by this target!"); case GlobalValue::DLLExportLinkage: - cerr << "DLLExport linkage is not supported by this target!\n"; - abort(); + llvm_report_error("DLLExport linkage is not supported by this target!"); default: assert(0 && "Unknown linkage type!"); } Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Wed Jul 8 14:04:27 2009 @@ -270,9 +270,8 @@ } const Type *Ty = cast(GV->getType())->getElementType(); if (!Ty->isSized() || isZeroLengthArray(Ty)) { - cerr << "Size of thread local object " << GVar->getName() - << " is unknown\n"; - abort(); + llvm_report_error("Size of thread local object " + GVar->getName() + + " is unknown"); } SDValue base = getGlobalAddressWrapper(GA, GV, DAG); const TargetData *TD = TM.getTargetData(); @@ -646,10 +645,13 @@ MVT RegVT = VA.getLocVT(); switch (RegVT.getSimpleVT()) { default: - cerr << "LowerFORMAL_ARGUMENTS Unhandled argument type: " - << RegVT.getSimpleVT() - << "\n"; - abort(); + { + std::string msg; + raw_string_ostream Msg(msg); + Msg << "LowerFORMAL_ARGUMENTS Unhandled argument type: " + << RegVT.getSimpleVT(); + llvm_report_error(Msg.str()); + } case MVT::i32: unsigned VReg = RegInfo.createVirtualRegister( XCore::GRRegsRegisterClass); Modified: llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp Wed Jul 8 14:04:27 2009 @@ -30,6 +30,8 @@ #include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -142,9 +144,11 @@ if (!isU6 && !isImmU16(Amount)) { // FIX could emit multiple instructions in this case. - cerr << "eliminateCallFramePseudoInstr size too big: " - << Amount << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "eliminateCallFramePseudoInstr size too big: " + << Amount; + llvm_report_error(Msg.str()); } MachineInstr *New; @@ -227,8 +231,10 @@ MachineInstr *New = 0; if (!isUs) { if (!RS) { - cerr << "eliminateFrameIndex Frame size too big: " << Offset << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "eliminateFrameIndex Frame size too big: " << Offset; + llvm_report_error(Msg.str()); } unsigned ScratchReg = RS->scavengeRegister(XCore::GRRegsRegisterClass, II, SPAdj); @@ -278,9 +284,10 @@ } else { bool isU6 = isImmU6(Offset); if (!isU6 && !isImmU16(Offset)) { - // FIXME could make this work for LDWSP, LDAWSP. - cerr << "eliminateFrameIndex Frame size too big: " << Offset << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "eliminateFrameIndex Frame size too big: " << Offset; + llvm_report_error(Msg.str()); } switch (MI.getOpcode()) { @@ -354,8 +361,10 @@ // TODO use mkmsk if possible. if (!isImmU16(Value)) { // TODO use constant pool. - cerr << "loadConstant value too big " << Value << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "loadConstant value too big " << Value; + llvm_report_error(Msg.str()); } int Opcode = isImmU6(Value) ? XCore::LDC_ru6 : XCore::LDC_lru6; BuildMI(MBB, I, dl, TII.get(Opcode), DstReg).addImm(Value); @@ -368,8 +377,10 @@ Offset/=4; bool isU6 = isImmU6(Offset); if (!isU6 && !isImmU16(Offset)) { - cerr << "storeToStack offset too big " << Offset << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "storeToStack offset too big " << Offset; + llvm_report_error(Msg.str()); } int Opcode = isU6 ? XCore::STWSP_ru6 : XCore::STWSP_lru6; BuildMI(MBB, I, dl, TII.get(Opcode)) @@ -384,8 +395,10 @@ Offset/=4; bool isU6 = isImmU6(Offset); if (!isU6 && !isImmU16(Offset)) { - cerr << "loadFromStack offset too big " << Offset << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "loadFromStack offset too big " << Offset; + llvm_report_error(Msg.str()); } int Opcode = isU6 ? XCore::LDWSP_ru6 : XCore::LDWSP_lru6; BuildMI(MBB, I, dl, TII.get(Opcode), DstReg) @@ -414,8 +427,10 @@ if (!isU6 && !isImmU16(FrameSize)) { // FIXME could emit multiple instructions. - cerr << "emitPrologue Frame size too big: " << FrameSize << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "emitPrologue Frame size too big: " << FrameSize; + llvm_report_error(Msg.str()); } bool emitFrameMoves = needsFrameMoves(MF); @@ -538,8 +553,10 @@ if (!isU6 && !isImmU16(FrameSize)) { // FIXME could emit multiple instructions. - cerr << "emitEpilogue Frame size too big: " << FrameSize << "\n"; - abort(); + std::string msg; + raw_string_ostream Msg(msg); + Msg << "emitEpilogue Frame size too big: " << FrameSize; + llvm_report_error(Msg.str()); } if (FrameSize) { Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Wed Jul 8 14:04:27 2009 @@ -243,8 +243,10 @@ // Default case: unhandled opcode o << " default:\n" - << " cerr << \"Not supported instr: \" << MI << \"\\n\";\n" - << " abort();\n" + << " std::string msg;\n" + << " raw_string_ostream Msg(msg);\n" + << " Msg << \"Not supported instr: \" << MI;\n" + << " llvm_report_error(Msg.str());\n" << " }\n" << " return Value;\n" << "}\n\n"; Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=75027&r1=75026&r2=75027&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Wed Jul 8 14:04:27 2009 @@ -2083,20 +2083,19 @@ << "}\n\n"; OS << "void CannotYetSelect(SDValue N) DISABLE_INLINE {\n" - << " cerr << \"Cannot yet select: \";\n" - << " N.getNode()->dump(CurDAG);\n" - << " cerr << '\\n';\n" - << " abort();\n" + << " std::string msg;\n" + << " raw_string_ostream Msg(msg);\n" + << " Msg << \"Cannot yet select: \";\n" + << " N.getNode()->print(Msg, CurDAG);\n" + << " llvm_report_error(Msg.str());\n" << "}\n\n"; OS << "void CannotYetSelectIntrinsic(SDValue N) DISABLE_INLINE {\n" << " cerr << \"Cannot yet select: \";\n" << " unsigned iid = cast(N.getOperand(" << "N.getOperand(0).getValueType() == MVT::Other))->getZExtValue();\n" - << " cerr << \"intrinsic %\"<< " - << "Intrinsic::getName((Intrinsic::ID)iid);\n" - << " cerr << '\\n';\n" - << " abort();\n" + << " llvm_report_error(\"Cannot yet select: intrinsic %\" +\n" + << "Intrinsic::getName((Intrinsic::ID)iid));\n" << "}\n\n"; } From resistor at mac.com Wed Jul 8 14:04:44 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 08 Jul 2009 19:04:44 -0000 Subject: [llvm-commits] [llvm] r75025 - in /llvm/trunk: examples/BrainF/ include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Linker/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ Message-ID: <200907081905.n68J5C6w022262@zion.cs.uiuc.edu> Author: resistor Date: Wed Jul 8 14:03:57 2009 New Revision: 75025 URL: http://llvm.org/viewvc/llvm-project?rev=75025&view=rev Log: Switch GlobalVariable ctors to a sane API, where *either* a context or a module is required. Modified: llvm/trunk/examples/BrainF/BrainF.cpp llvm/trunk/include/llvm/GlobalVariable.h llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/CodeGen/ShadowStackGC.cpp llvm/trunk/lib/Linker/LinkModules.cpp llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/CloneModule.cpp llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Globals.cpp llvm/trunk/lib/VMCore/Module.cpp llvm/trunk/tools/bugpoint/ExtractFunction.cpp llvm/trunk/tools/bugpoint/Miscompilation.cpp Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Wed Jul 8 14:03:57 2009 @@ -128,13 +128,12 @@ get("Error: The head has left the tape.", true); GlobalVariable *aberrormsg = new GlobalVariable( - module->getContext(), + *module, msg_0->getType(), true, GlobalValue::InternalLinkage, msg_0, - "aberrormsg", - module); + "aberrormsg"); //declare i32 @puts(i8 *) Function *puts_func = cast(module-> Modified: llvm/trunk/include/llvm/GlobalVariable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalVariable.h?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/include/llvm/GlobalVariable.h (original) +++ llvm/trunk/include/llvm/GlobalVariable.h Wed Jul 8 14:03:57 2009 @@ -26,9 +26,9 @@ namespace llvm { -class LLVMContext; class Module; class Constant; +class LLVMContext; template class SymbolTableListTraits; @@ -50,17 +50,16 @@ } /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. - GlobalVariable(LLVMContext &Context, const Type *Ty, - bool isConstant, LinkageTypes Linkage, + GlobalVariable(LLVMContext &Context, const Type *Ty, bool isConstant, + LinkageTypes Linkage, Constant *Initializer = 0, const std::string &Name = "", - Module *Parent = 0, bool ThreadLocal = false, - unsigned AddressSpace = 0); + bool ThreadLocal = false, unsigned AddressSpace = 0); /// GlobalVariable ctor - This creates a global and inserts it before the /// specified other global. - GlobalVariable(LLVMContext &Context, const Type *Ty, - bool isConstant, LinkageTypes Linkage, - Constant *Initializer, const std::string &Name, - GlobalVariable *InsertBefore, bool ThreadLocal = false, + GlobalVariable(Module &M, const Type *Ty, bool isConstant, + LinkageTypes Linkage, Constant *Initializer, + const std::string &Name, + GlobalVariable *InsertBefore = 0, bool ThreadLocal = false, unsigned AddressSpace = 0); ~GlobalVariable() { Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jul 8 14:03:57 2009 @@ -20,7 +20,6 @@ #include "llvm/GlobalAlias.h" #include "llvm/GlobalVariable.h" #include "llvm/Function.h" -#include "llvm/LLVMContext.h" #include "llvm/Support/ConstantFolder.h" namespace llvm { @@ -43,16 +42,12 @@ BasicBlock *BB; BasicBlock::iterator InsertPt; T Folder; - LLVMContext& Context; public: - IRBuilder(const T& F = T(), LLVMContext &C = getGlobalContext()) : - Folder(F), Context(C) { ClearInsertionPoint(); } - explicit IRBuilder(BasicBlock *TheBB, const T& F = T(), - LLVMContext &C = getGlobalContext()) : - Folder(F), Context(C) { SetInsertPoint(TheBB); } - IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F = T(), - LLVMContext &C = getGlobalContext()) - : Folder(F), Context(C) { SetInsertPoint(TheBB, IP); } + IRBuilder(const T& F = T()) : Folder(F) { ClearInsertionPoint(); } + explicit IRBuilder(BasicBlock *TheBB, const T& F = T()) + : Folder(F) { SetInsertPoint(TheBB); } + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F = T()) + : Folder(F) { SetInsertPoint(TheBB, IP); } /// getFolder - Get the constant folder being used. const T& getFolder() { return Folder; } @@ -130,7 +125,7 @@ /// ReturnInst *CreateAggregateRet(Value * const* retVals, unsigned N) { const Type *RetType = BB->getParent()->getReturnType(); - Value *V = Context.getUndef(RetType); + Value *V = UndefValue::get(RetType); for (unsigned i = 0; i != N; ++i) V = CreateInsertValue(V, retVals[i], i, "mrv"); return Insert(ReturnInst::Create(V)); @@ -354,7 +349,7 @@ return Insert(GetElementPtrInst::Create(Ptr, Idx), Name); } Value *CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const char *Name = "") { - Value *Idx = Context.getConstantInt(Type::Int32Ty, Idx0); + Value *Idx = ConstantInt::get(Type::Int32Ty, Idx0); if (Constant *PC = dyn_cast(Ptr)) return Folder.CreateGetElementPtr(PC, &Idx, 1); @@ -364,8 +359,8 @@ Value *CreateConstGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1, const char *Name = "") { Value *Idxs[] = { - Context.getConstantInt(Type::Int32Ty, Idx0), - Context.getConstantInt(Type::Int32Ty, Idx1) + ConstantInt::get(Type::Int32Ty, Idx0), + ConstantInt::get(Type::Int32Ty, Idx1) }; if (Constant *PC = dyn_cast(Ptr)) @@ -374,7 +369,7 @@ return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name); } Value *CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const char *Name = "") { - Value *Idx = Context.getConstantInt(Type::Int64Ty, Idx0); + Value *Idx = ConstantInt::get(Type::Int64Ty, Idx0); if (Constant *PC = dyn_cast(Ptr)) return Folder.CreateGetElementPtr(PC, &Idx, 1); @@ -384,8 +379,8 @@ Value *CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const char *Name = "") { Value *Idxs[] = { - Context.getConstantInt(Type::Int64Ty, Idx0), - Context.getConstantInt(Type::Int64Ty, Idx1) + ConstantInt::get(Type::Int64Ty, Idx0), + ConstantInt::get(Type::Int64Ty, Idx1) }; if (Constant *PC = dyn_cast(Ptr)) @@ -397,21 +392,21 @@ return CreateConstGEP2_32(Ptr, 0, Idx, Name); } Value *CreateGlobalString(const char *Str = "", const char *Name = "") { - Constant *StrConstant = Context.getConstantArray(Str, true); - GlobalVariable *gv = new GlobalVariable(Context, + Constant *StrConstant = ConstantArray::get(Str, true); + GlobalVariable *gv = new GlobalVariable(*BB->getParent()->getParent(), StrConstant->getType(), true, GlobalValue::InternalLinkage, StrConstant, "", - BB->getParent()->getParent(), + 0, false); gv->setName(Name); return gv; } Value *CreateGlobalStringPtr(const char *Str = "", const char *Name = "") { Value *gv = CreateGlobalString(Str, Name); - Value *zero = Context.getConstantInt(Type::Int32Ty, 0); + Value *zero = ConstantInt::get(Type::Int32Ty, 0); Value *Args[] = { zero, zero }; return CreateGEP(gv, Args, Args+2, Name); } @@ -688,13 +683,13 @@ /// CreateIsNull - Return an i1 value testing if \arg Arg is null. Value *CreateIsNull(Value *Arg, const char *Name = "") { - return CreateICmpEQ(Arg, Context.getNullValue(Arg->getType()), + return CreateICmpEQ(Arg, Constant::getNullValue(Arg->getType()), Name); } /// CreateIsNotNull - Return an i1 value testing if \arg Arg is not null. Value *CreateIsNotNull(Value *Arg, const char *Name = "") { - return CreateICmpNE(Arg, Context.getNullValue(Arg->getType()), + return CreateICmpNE(Arg, Constant::getNullValue(Arg->getType()), Name); } @@ -709,7 +704,7 @@ Value *RHS_int = CreatePtrToInt(RHS, Type::Int64Ty); Value *Difference = CreateSub(LHS_int, RHS_int); return CreateSDiv(Difference, - Context.getConstantExprSizeOf(ArgType->getElementType()), + ConstantExpr::getSizeOf(ArgType->getElementType()), Name); } }; Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Wed Jul 8 14:03:57 2009 @@ -490,9 +490,9 @@ Constant *ConstStr = VMContext.getConstantArray(String); // Otherwise create and return a new string global. - GlobalVariable *StrGV = new GlobalVariable(VMContext,ConstStr->getType(), true, + GlobalVariable *StrGV = new GlobalVariable(M, ConstStr->getType(), true, GlobalVariable::InternalLinkage, - ConstStr, ".str", &M); + ConstStr, ".str"); StrGV->setSection("llvm.metadata"); return Slot = VMContext.getConstantExprBitCast(StrGV, DestTy); } @@ -516,9 +516,9 @@ DIDescriptor &Entry = SimpleConstantCache[Init]; if (!Entry.isNull()) return DIArray(Entry.getGV()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::InternalLinkage, - Init, "llvm.dbg.array", &M); + Init, "llvm.dbg.array"); GV->setSection("llvm.metadata"); Entry = DIDescriptor(GV); return DIArray(GV); @@ -542,9 +542,9 @@ M.addTypeName("llvm.dbg.subrange.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::InternalLinkage, - Init, "llvm.dbg.subrange", &M); + Init, "llvm.dbg.subrange"); GV->setSection("llvm.metadata"); Entry = DIDescriptor(GV); return DISubrange(GV); @@ -579,9 +579,9 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.compile_unit.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::LinkOnceAnyLinkage, - Init, "llvm.dbg.compile_unit", &M); + Init, "llvm.dbg.compile_unit"); GV->setSection("llvm.metadata"); return DICompileUnit(GV); } @@ -598,9 +598,9 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.enumerator.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::InternalLinkage, - Init, "llvm.dbg.enumerator", &M); + Init, "llvm.dbg.enumerator"); GV->setSection("llvm.metadata"); return DIEnumerator(GV); } @@ -632,9 +632,9 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.basictype.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::InternalLinkage, - Init, "llvm.dbg.basictype", &M); + Init, "llvm.dbg.basictype"); GV->setSection("llvm.metadata"); return DIBasicType(GV); } @@ -668,9 +668,9 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.derivedtype.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::InternalLinkage, - Init, "llvm.dbg.derivedtype", &M); + Init, "llvm.dbg.derivedtype"); GV->setSection("llvm.metadata"); return DIDerivedType(GV); } @@ -708,9 +708,9 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.composite.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::InternalLinkage, - Init, "llvm.dbg.composite", &M); + Init, "llvm.dbg.composite"); GV->setSection("llvm.metadata"); return DICompositeType(GV); } @@ -746,9 +746,9 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.subprogram.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::LinkOnceAnyLinkage, - Init, "llvm.dbg.subprogram", &M); + Init, "llvm.dbg.subprogram"); GV->setSection("llvm.metadata"); return DISubprogram(GV); } @@ -780,9 +780,9 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.global_variable.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::LinkOnceAnyLinkage, - Init, "llvm.dbg.global_variable", &M); + Init, "llvm.dbg.global_variable"); GV->setSection("llvm.metadata"); return DIGlobalVariable(GV); } @@ -806,9 +806,9 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.variable.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::InternalLinkage, - Init, "llvm.dbg.variable", &M); + Init, "llvm.dbg.variable"); GV->setSection("llvm.metadata"); return DIVariable(GV); } @@ -826,9 +826,9 @@ sizeof(Elts)/sizeof(Elts[0])); M.addTypeName("llvm.dbg.block.type", Init->getType()); - GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true, + GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true, GlobalValue::InternalLinkage, - Init, "llvm.dbg.block", &M); + Init, "llvm.dbg.block"); GV->setSection("llvm.metadata"); return DIBlock(GV); } Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Jul 8 14:03:57 2009 @@ -516,9 +516,8 @@ } if (GV == 0) { - GV = new GlobalVariable(Context, Ty, false, - GlobalValue::ExternalLinkage, 0, Name, - M, false, AddrSpace); + GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, 0, + Name, 0, false, AddrSpace); } else { if (GV->getType()->getElementType() != Ty) return Error(TyLoc, @@ -608,8 +607,8 @@ FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M); } else { - FwdVal = new GlobalVariable(Context, PTy->getElementType(), false, - GlobalValue::ExternalWeakLinkage, 0, Name, M); + FwdVal = new GlobalVariable(*M, PTy->getElementType(), false, + GlobalValue::ExternalWeakLinkage, 0, Name); } ForwardRefVals[Name] = std::make_pair(FwdVal, Loc); @@ -652,8 +651,8 @@ } FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M); } else { - FwdVal = new GlobalVariable(Context, PTy->getElementType(), false, - GlobalValue::ExternalWeakLinkage, 0, "", M); + FwdVal = new GlobalVariable(*M, PTy->getElementType(), false, + GlobalValue::ExternalWeakLinkage, 0, ""); } ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc); Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Jul 8 14:03:57 2009 @@ -1254,7 +1254,7 @@ isThreadLocal = Record[7]; GlobalVariable *NewGV = - new GlobalVariable(Context, Ty, isConstant, Linkage, 0, "", TheModule, + new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0, isThreadLocal, AddressSpace); NewGV->setAlignment(Alignment); if (!Section.empty()) Modified: llvm/trunk/lib/CodeGen/ShadowStackGC.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShadowStackGC.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ShadowStackGC.cpp (original) +++ llvm/trunk/lib/CodeGen/ShadowStackGC.cpp Wed Jul 8 14:03:57 2009 @@ -229,10 +229,9 @@ // to be a ModulePass (which means it cannot be in the 'llc' pipeline // (which uses a FunctionPassManager (which segfaults (not asserts) if // provided a ModulePass))). - Constant *GV = new GlobalVariable(*F.getContext(), FrameMap->getType(), true, + Constant *GV = new GlobalVariable(*F.getParent(), FrameMap->getType(), true, GlobalVariable::InternalLinkage, - FrameMap, "__gc_" + F.getName(), - F.getParent()); + FrameMap, "__gc_" + F.getName()); Constant *GEPIndices[2] = { ConstantInt::get(Type::Int32Ty, 0), ConstantInt::get(Type::Int32Ty, 0) }; @@ -292,10 +291,10 @@ if (!Head) { // If the root chain does not exist, insert a new one with linkonce // linkage! - Head = new GlobalVariable(M.getContext(), StackEntryPtrTy, false, + Head = new GlobalVariable(M, StackEntryPtrTy, false, GlobalValue::LinkOnceAnyLinkage, Constant::getNullValue(StackEntryPtrTy), - "llvm_gc_root_chain", &M); + "llvm_gc_root_chain"); } else if (Head->hasExternalLinkage() && Head->isDeclaration()) { Head->setInitializer(Constant::getNullValue(StackEntryPtrTy)); Head->setLinkage(GlobalValue::LinkOnceAnyLinkage); Modified: llvm/trunk/lib/Linker/LinkModules.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkModules.cpp (original) +++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Jul 8 14:03:57 2009 @@ -573,9 +573,9 @@ // symbol over in the dest module... the initializer will be filled in // later by LinkGlobalInits. GlobalVariable *NewDGV = - new GlobalVariable(Context, SGV->getType()->getElementType(), + new GlobalVariable(*Dest, SGV->getType()->getElementType(), SGV->isConstant(), SGV->getLinkage(), /*init*/0, - SGV->getName(), Dest, false, + SGV->getName(), 0, false, SGV->getType()->getAddressSpace()); // Propagate alignment, visibility and section info. CopyGVAttributes(NewDGV, SGV); @@ -606,9 +606,9 @@ // AppendingVars map. The name is cleared out so that no linkage is // performed. GlobalVariable *NewDGV = - new GlobalVariable(Context, SGV->getType()->getElementType(), + new GlobalVariable(*Dest, SGV->getType()->getElementType(), SGV->isConstant(), SGV->getLinkage(), /*init*/0, - "", Dest, false, + "", 0, false, SGV->getType()->getAddressSpace()); // Set alignment allowing CopyGVAttributes merge it with alignment of SGV. @@ -634,9 +634,9 @@ // we are replacing may be a function (if a prototype, weak, etc) or a // global variable. GlobalVariable *NewDGV = - new GlobalVariable(Context, SGV->getType()->getElementType(), + new GlobalVariable(*Dest, SGV->getType()->getElementType(), SGV->isConstant(), NewLinkage, /*init*/0, - DGV->getName(), Dest, false, + DGV->getName(), 0, false, SGV->getType()->getAddressSpace()); // Propagate alignment, section, and visibility info. @@ -1157,8 +1157,8 @@ // Create the new global variable... GlobalVariable *NG = - new GlobalVariable(Context, NewType, G1->isConstant(), G1->getLinkage(), - /*init*/0, First->first, M, G1->isThreadLocal(), + new GlobalVariable(*M, NewType, G1->isConstant(), G1->getLinkage(), + /*init*/0, First->first, 0, G1->isThreadLocal(), G1->getType()->getAddressSpace()); // Propagate alignment, visibility and section info. Modified: llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp Wed Jul 8 14:03:57 2009 @@ -108,9 +108,9 @@ } ArrayType *AT = Context->getArrayType(SBP, AUGs.size()); Constant *Init = Context->getConstantArray(AT, AUGs); - GlobalValue *gv = new GlobalVariable(M.getContext(), AT, false, + GlobalValue *gv = new GlobalVariable(M, AT, false, GlobalValue::AppendingLinkage, - Init, "llvm.used", &M); + Init, "llvm.used"); gv->setSection("llvm.metadata"); } Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Wed Jul 8 14:03:57 2009 @@ -490,11 +490,10 @@ Context->getConstantInt(Type::Int32Ty, i), Context); assert(In && "Couldn't get element of initializer?"); - GlobalVariable *NGV = new GlobalVariable(*Context, STy->getElementType(i), - false, + GlobalVariable *NGV = new GlobalVariable(*Context, + STy->getElementType(i), false, GlobalVariable::InternalLinkage, In, GV->getName()+"."+utostr(i), - (Module *)NULL, GV->isThreadLocal(), GV->getType()->getAddressSpace()); Globals.insert(GV, NGV); @@ -527,13 +526,12 @@ Context); assert(In && "Couldn't get element of initializer?"); - GlobalVariable *NGV = new GlobalVariable(*Context, STy->getElementType(), - false, + GlobalVariable *NGV = new GlobalVariable(*Context, + STy->getElementType(), false, GlobalVariable::InternalLinkage, In, GV->getName()+"."+utostr(i), - (Module *)NULL, GV->isThreadLocal(), - GV->getType()->getAddressSpace()); + GV->getType()->getAddressSpace()); Globals.insert(GV, NGV); NewGlobals.push_back(NGV); @@ -842,18 +840,17 @@ // Create the new global variable. The contents of the malloc'd memory is // undefined, so initialize with an undef value. + // FIXME: This new global should have the alignment returned by malloc. Code + // could depend on malloc returning large alignment (on the mac, 16 bytes) but + // this would only guarantee some lower alignment. Constant *Init = Context->getUndef(MI->getAllocatedType()); - GlobalVariable *NewGV = new GlobalVariable(*Context, MI->getAllocatedType(), - false, + GlobalVariable *NewGV = new GlobalVariable(*GV->getParent(), + MI->getAllocatedType(), false, GlobalValue::InternalLinkage, Init, GV->getName()+".body", - (Module *)NULL, + GV, GV->isThreadLocal()); - // FIXME: This new global should have the alignment returned by malloc. Code - // could depend on malloc returning large alignment (on the mac, 16 bytes) but - // this would only guarantee some lower alignment. - GV->getParent()->getGlobalList().insert(GV, NewGV); - + // Anything that used the malloc now uses the global directly. MI->replaceAllUsesWith(NewGV); @@ -868,7 +865,7 @@ new GlobalVariable(*Context, Type::Int1Ty, false, GlobalValue::InternalLinkage, Context->getConstantIntFalse(), GV->getName()+".init", - (Module *)NULL, GV->isThreadLocal()); + GV->isThreadLocal()); bool InitBoolUsed = false; // Loop over all uses of GV, processing them in turn. @@ -1286,8 +1283,8 @@ const Type *PFieldTy = Context->getPointerTypeUnqual(FieldTy); GlobalVariable *NGV = - new GlobalVariable(*Context, PFieldTy, false, - GlobalValue::InternalLinkage, + new GlobalVariable(*GV->getParent(), + PFieldTy, false, GlobalValue::InternalLinkage, Context->getNullValue(PFieldTy), GV->getName() + ".f" + utostr(FieldNo), GV, GV->isThreadLocal()); @@ -1587,7 +1584,6 @@ GlobalVariable *NewGV = new GlobalVariable(*Context, Type::Int1Ty, false, GlobalValue::InternalLinkage, Context->getConstantIntFalse(), GV->getName()+".b", - (Module *)NULL, GV->isThreadLocal()); GV->getParent()->getGlobalList().insert(GV, NewGV); @@ -1982,7 +1978,6 @@ GlobalVariable *NGV = new GlobalVariable(*Context, CA->getType(), GCL->isConstant(), GCL->getLinkage(), CA, "", - (Module *)NULL, GCL->isThreadLocal()); GCL->getParent()->getGlobalList().insert(GCL, NGV); NGV->takeName(GCL); Modified: llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp Wed Jul 8 14:03:57 2009 @@ -65,8 +65,8 @@ const Type *ATy = Context->getArrayType(Type::Int32Ty, NumFunctions); GlobalVariable *Counters = - new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage, - Context->getNullValue(ATy), "FuncProfCounters", &M); + new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage, + Context->getNullValue(ATy), "FuncProfCounters"); // Instrument all of the functions... unsigned i = 0; @@ -110,8 +110,8 @@ const Type *ATy = Context->getArrayType(Type::Int32Ty, NumBlocks); GlobalVariable *Counters = - new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage, - Context->getNullValue(ATy), "BlockProfCounters", &M); + new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage, + Context->getNullValue(ATy), "BlockProfCounters"); // Instrument all of the blocks... unsigned i = 0; Modified: llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp Wed Jul 8 14:03:57 2009 @@ -66,8 +66,8 @@ const Type *ATy = Context->getArrayType(Type::Int32Ty, NumEdges); GlobalVariable *Counters = - new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage, - Context->getNullValue(ATy), "EdgeProfCounters", &M); + new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage, + Context->getNullValue(ATy), "EdgeProfCounters"); // Instrument all of the edges... unsigned i = 0; Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Wed Jul 8 14:03:57 2009 @@ -198,9 +198,8 @@ uint64_t resetval) : T(t) { ConstantInt* Init = M.getContext().getConstantInt(T, resetval); ResetValue = Init; - Counter = new GlobalVariable(M.getContext(), T, false, - GlobalValue::InternalLinkage, - Init, "RandomSteeringCounter", &M); + Counter = new GlobalVariable(M, T, false, GlobalValue::InternalLinkage, + Init, "RandomSteeringCounter"); } GlobalRandomCounter::~GlobalRandomCounter() {} @@ -238,9 +237,8 @@ : AI(0), T(t) { ConstantInt* Init = M.getContext().getConstantInt(T, resetval); ResetValue = Init; - Counter = new GlobalVariable(M.getContext(), T, false, - GlobalValue::InternalLinkage, - Init, "RandomSteeringCounter", &M); + Counter = new GlobalVariable(M, T, false, GlobalValue::InternalLinkage, + Init, "RandomSteeringCounter"); } GlobalRandomCounterOpt::~GlobalRandomCounterOpt() {} Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Wed Jul 8 14:03:57 2009 @@ -1290,9 +1290,8 @@ // pass to be run after this pass, to merge duplicate strings. FormatStr.erase(FormatStr.end()-1); Constant *C = Context->getConstantArray(FormatStr, true); - C = new GlobalVariable(*Context, C->getType(), - true, GlobalVariable::InternalLinkage, - C, "str", Callee->getParent()); + C = new GlobalVariable(*Callee->getParent(), C->getType(), true, + GlobalVariable::InternalLinkage, C, "str"); EmitPutS(C, B); return CI->use_empty() ? (Value*)CI : Context->getConstantInt(CI->getType(), FormatStr.size()+1); Modified: llvm/trunk/lib/Transforms/Utils/CloneModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneModule.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Wed Jul 8 14:03:57 2009 @@ -56,11 +56,11 @@ // for (Module::const_global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) { - GlobalVariable *GV = new GlobalVariable(M->getContext(), + GlobalVariable *GV = new GlobalVariable(*New, I->getType()->getElementType(), false, GlobalValue::ExternalLinkage, 0, - I->getName(), New); + I->getName()); GV->setAlignment(I->getAlignment()); ValueMap[I] = GV; } Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Wed Jul 8 14:03:57 2009 @@ -139,11 +139,10 @@ // Now that we've done that, insert the jmpbuf list head global, unless it // already exists. if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))) { - JBListHead = new GlobalVariable(M.getContext(), - PtrJBList, false, + JBListHead = new GlobalVariable(M, PtrJBList, false, GlobalValue::LinkOnceAnyLinkage, Context->getNullValue(PtrJBList), - "llvm.sjljeh.jblist", &M); + "llvm.sjljeh.jblist"); } // VisualStudio defines setjmp as _setjmp via #include / , @@ -183,10 +182,9 @@ Context->getConstantArray("ERROR: Exception thrown, but not caught!\n"); AbortMessageLength = Msg->getNumOperands()-1; // don't include \0 - GlobalVariable *MsgGV = new GlobalVariable(M->getContext(), - Msg->getType(), true, + GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true, GlobalValue::InternalLinkage, - Msg, "abortmsg", M); + Msg, "abortmsg"); std::vector GEPIdx(2, Context->getNullValue(Type::Int32Ty)); AbortMessage = Context->getConstantExprGetElementPtr(MsgGV, &GEPIdx[0], 2); } else { @@ -197,10 +195,9 @@ "Recompile program with -enable-correct-eh-support.\n"); AbortMessageLength = Msg->getNumOperands()-1; // don't include \0 - GlobalVariable *MsgGV = new GlobalVariable(M->getContext(), - Msg->getType(), true, + GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true, GlobalValue::InternalLinkage, - Msg, "abortmsg", M); + Msg, "abortmsg"); std::vector GEPIdx(2, Context->getNullValue(Type::Int32Ty)); AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2); } Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Wed Jul 8 14:03:57 2009 @@ -700,10 +700,8 @@ /*--.. Operations on global variables ......................................--*/ LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name) { - LLVMContext &Context = unwrap(M)->getContext(); - return wrap(new GlobalVariable(Context, unwrap(Ty), false, - GlobalValue::ExternalLinkage, 0, Name, - unwrap(M))); + return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false, + GlobalValue::ExternalLinkage, 0, Name)); } LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name) { Modified: llvm/trunk/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Globals.cpp (original) +++ llvm/trunk/lib/VMCore/Globals.cpp Wed Jul 8 14:03:57 2009 @@ -97,8 +97,7 @@ GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty, bool constant, LinkageTypes Link, Constant *InitVal, const std::string &Name, - Module *ParentModule, bool ThreadLocal, - unsigned AddressSpace) + bool ThreadLocal, unsigned AddressSpace) : GlobalValue(Context.getPointerType(Ty, AddressSpace), Value::GlobalVariableVal, OperandTraits::op_begin(this), @@ -111,18 +110,14 @@ } LeakDetector::addGarbageObject(this); - - if (ParentModule) - ParentModule->getGlobalList().push_back(this); } -GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty, - bool constant, LinkageTypes Link, - Constant *InitVal, const std::string &Name, +GlobalVariable::GlobalVariable(Module &M, const Type *Ty, bool constant, + LinkageTypes Link, Constant *InitVal, + const std::string &Name, GlobalVariable *Before, bool ThreadLocal, unsigned AddressSpace) - : GlobalValue(Context.getPointerType(Ty, AddressSpace), - Value::GlobalVariableVal, + : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, OperandTraits::op_begin(this), InitVal != 0, Link, Name), isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) { @@ -136,6 +131,8 @@ if (Before) Before->getParent()->getGlobalList().insert(Before, this); + else + M.getGlobalList().push_back(this); } void GlobalVariable::setParent(Module *parent) { Modified: llvm/trunk/lib/VMCore/Module.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Module.cpp (original) +++ llvm/trunk/lib/VMCore/Module.cpp Wed Jul 8 14:03:57 2009 @@ -28,20 +28,17 @@ //===----------------------------------------------------------------------===// // Methods to implement the globals and functions lists. -// NOTE: It is ok to allocate the globals used for these methods from the -// global context, because all we ever do is use them to compare for equality. // GlobalVariable *ilist_traits::createSentinel() { - GlobalVariable *Ret = new GlobalVariable(getGlobalContext(), - Type::Int32Ty, false, - GlobalValue::ExternalLinkage); + GlobalVariable *Ret = new GlobalVariable(getGlobalContext(), Type::Int32Ty, + false, GlobalValue::ExternalLinkage); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); return Ret; } GlobalAlias *ilist_traits::createSentinel() { - GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty, + GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty, GlobalValue::ExternalLinkage); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); @@ -273,10 +270,9 @@ if (GV == 0) { // Nope, add it GlobalVariable *New = - new GlobalVariable(getContext(), Ty, false, - GlobalVariable::ExternalLinkage, 0, Name); - GlobalList.push_back(New); - return New; // Return the new declaration. + new GlobalVariable(*this, Ty, false, GlobalVariable::ExternalLinkage, + 0, Name); + return New; // Return the new declaration. } // If the variable exists but has the wrong type, return a bitcast to the Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original) +++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Wed Jul 8 14:03:57 2009 @@ -236,9 +236,9 @@ GV->eraseFromParent(); if (!M1Tors.empty()) { Constant *M1Init = GetTorInit(M1Tors); - new GlobalVariable(M1->getContext(), M1Init->getType(), false, + new GlobalVariable(*M1, M1Init->getType(), false, GlobalValue::AppendingLinkage, - M1Init, GlobalName, M1); + M1Init, GlobalName); } GV = M2->getNamedGlobal(GlobalName); @@ -248,9 +248,9 @@ GV->eraseFromParent(); if (!M2Tors.empty()) { Constant *M2Init = GetTorInit(M2Tors); - new GlobalVariable(M2->getContext(), M2Init->getType(), false, + new GlobalVariable(*M2, M2Init->getType(), false, GlobalValue::AppendingLinkage, - M2Init, GlobalName, M2); + M2Init, GlobalName); } } Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=75025&r1=75024&r2=75025&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original) +++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Wed Jul 8 14:03:57 2009 @@ -703,10 +703,9 @@ // 1. Add a string constant with its name to the global file Constant *InitArray = ConstantArray::get(F->getName()); GlobalVariable *funcName = - new GlobalVariable(Safe->getContext(), - InitArray->getType(), true /*isConstant*/, + new GlobalVariable(*Safe, InitArray->getType(), true /*isConstant*/, GlobalValue::InternalLinkage, InitArray, - F->getName() + "_name", Safe); + F->getName() + "_name"); // 2. Use `GetElementPtr *funcName, 0, 0' to convert the string to an // sbyte* so it matches the signature of the resolver function. @@ -723,9 +722,9 @@ // Create a new global to hold the cached function pointer. Constant *NullPtr = ConstantPointerNull::get(F->getType()); GlobalVariable *Cache = - new GlobalVariable(F->getParent()->getContext(), - F->getType(), false,GlobalValue::InternalLinkage, - NullPtr,F->getName()+".fpcache", F->getParent()); + new GlobalVariable(*F->getParent(), F->getType(), + false, GlobalValue::InternalLinkage, + NullPtr,F->getName()+".fpcache"); // Construct a new stub function that will re-route calls to F const FunctionType *FuncTy = F->getFunctionType(); From gohman at apple.com Wed Jul 8 14:15:11 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 08 Jul 2009 19:15:11 -0000 Subject: [llvm-commits] [llvm] r75029 - /llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Message-ID: <200907081915.n68JFItT022629@zion.cs.uiuc.edu> Author: djg Date: Wed Jul 8 14:14:29 2009 New Revision: 75029 URL: http://llvm.org/viewvc/llvm-project?rev=75029&view=rev Log: Tell ScalarEvolution to forget a loop before starting to delete it. This way ScalarEvolution can examine the loop to determine what state it needs to update, if it chooses. Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp?rev=75029&r1=75028&r2=75029&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Wed Jul 8 14:14:29 2009 @@ -199,7 +199,12 @@ // Because we're deleting a large chunk of code at once, the sequence in which // we remove things is very important to avoid invalidation issues. Don't // mess with this unless you have good reason and know what you're doing. - + + // Tell ScalarEvolution that the loop is deleted. Do this before + // deleting the loop so that ScalarEvolution can look at the loop + // to determine what it needs to clean up. + SE.forgetLoopBackedgeTakenCount(L); + // Move simple loop-invariant expressions out of the loop, since they // might be needed by the exit phis. for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); @@ -248,11 +253,6 @@ (*LI)->dropAllReferences(); } - // Tell ScalarEvolution that the loop is deleted. Do this before - // deleting the loop so that ScalarEvolution can look at the loop - // to determine what it needs to clean up. - SE.forgetLoopBackedgeTakenCount(L); - // Erase the instructions and the blocks without having to worry // about ordering because we already dropped the references. // NOTE: This iteration is safe because erasing the block does not remove its From dpatel at apple.com Wed Jul 8 14:24:09 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 08 Jul 2009 19:24:09 -0000 Subject: [llvm-commits] [llvm] r75031 - in /llvm/trunk: lib/AsmParser/LLParser.cpp lib/AsmParser/LLParser.h test/Feature/mdnode4.ll Message-ID: <200907081924.n68JOHbd023046@zion.cs.uiuc.edu> Author: dpatel Date: Wed Jul 8 14:23:54 2009 New Revision: 75031 URL: http://llvm.org/viewvc/llvm-project?rev=75031&view=rev Log: Support MDNode forward reference. Added: llvm/trunk/test/Feature/mdnode4.ll Modified: llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLParser.h Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=75031&r1=75030&r2=75031&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Jul 8 14:23:54 2009 @@ -84,6 +84,12 @@ "use of undefined value '@" + utostr(ForwardRefValIDs.begin()->first) + "'"); + if (!ForwardRefMDNodes.empty()) + return Error(ForwardRefMDNodes.begin()->second.second, + "use of undefined metadata '!" + + utostr(ForwardRefMDNodes.begin()->first) + "'"); + + // Look for intrinsic functions and CallInst that need to be upgraded for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ) UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove @@ -382,6 +388,14 @@ return true; MetadataCache[MetadataID] = Init; + std::map >::iterator + FI = ForwardRefMDNodes.find(MetadataID); + if (FI != ForwardRefMDNodes.end()) { + Constant *FwdNode = FI->second.first; + FwdNode->replaceAllUsesWith(Init); + ForwardRefMDNodes.erase(FI); + } + return false; } @@ -1632,9 +1646,24 @@ unsigned MID = 0; if (!ParseUInt32(MID)) { std::map::iterator I = MetadataCache.find(MID); - if (I == MetadataCache.end()) - return TokError("Unknown metadata reference"); - ID.ConstantVal = I->second; + if (I != MetadataCache.end()) + ID.ConstantVal = I->second; + else { + std::map >::iterator + FI = ForwardRefMDNodes.find(MID); + if (FI != ForwardRefMDNodes.end()) + ID.ConstantVal = FI->second.first; + else { + // Create MDNode forward reference + SmallVector Elts; + std::string FwdRefName = "llvm.mdnode.fwdref." + MID; + Elts.push_back(Context.getMDString(FwdRefName)); + MDNode *FwdNode = Context.getMDNode(Elts.data(), Elts.size()); + ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc()); + ID.ConstantVal = FwdNode; + } + } + return false; } Modified: llvm/trunk/lib/AsmParser/LLParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=75031&r1=75030&r2=75031&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.h (original) +++ llvm/trunk/lib/AsmParser/LLParser.h Wed Jul 8 14:23:54 2009 @@ -46,6 +46,8 @@ std::vector NumberedTypes; /// MetadataCache - This map keeps track of parsed metadata constants. std::map MetadataCache; + std::map > ForwardRefMDNodes; + struct UpRefRecord { /// Loc - This is the location of the upref. LocTy Loc; Added: llvm/trunk/test/Feature/mdnode4.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/mdnode4.ll?rev=75031&view=auto ============================================================================== --- llvm/trunk/test/Feature/mdnode4.ll (added) +++ llvm/trunk/test/Feature/mdnode4.ll Wed Jul 8 14:23:54 2009 @@ -0,0 +1,5 @@ +; Test forward MDNode reference +; RUN: llvm-as < %s | llvm-dis -f -o /dev/null + + at llvm.blah = constant metadata !{metadata !1} +!1 = constant metadata !{i32 23, i32 24} From gohman at apple.com Wed Jul 8 14:24:09 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 08 Jul 2009 19:24:09 -0000 Subject: [llvm-commits] [llvm] r75030 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp Message-ID: <200907081924.n68JOHZO023048@zion.cs.uiuc.edu> Author: djg Date: Wed Jul 8 14:23:34 2009 New Revision: 75030 URL: http://llvm.org/viewvc/llvm-project?rev=75030&view=rev Log: Make the code that updates ScalarEvolution's internal state in response to a loop deletion more thorough. Don't prune the def-use tree search at instructions that don't have SCEVs computed, because an instruction with a user that has a computed SCEV may itself lack a computed SCEV. Also, remove loop-related values from the ValuesAtScopes and ConstantEvolutionLoopExitValues maps as well. This fixes a regression in 483.xalancbmk. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=75030&r1=75029&r2=75030&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Wed Jul 8 14:23:34 2009 @@ -346,11 +346,6 @@ Constant *getConstantEvolutionLoopExitValue(PHINode *PN, const APInt& BEs, const Loop *L); - /// forgetLoopPHIs - Delete the memoized SCEVs associated with the - /// PHI nodes in the given loop. This is used when the trip count of - /// the loop may have changed. - void forgetLoopPHIs(const Loop *L); - public: static char ID; // Pass identification, replacement for typeid ScalarEvolution(); Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=75030&r1=75029&r2=75030&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Jul 8 14:23:34 2009 @@ -81,6 +81,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallPtrSet.h" #include using namespace llvm; @@ -2856,6 +2857,29 @@ return getBackedgeTakenInfo(L).Max; } +/// PushLoopPHIs - Push PHI nodes in the header of the given loop +/// onto the given Worklist. +static void +PushLoopPHIs(const Loop *L, SmallVectorImpl &Worklist) { + BasicBlock *Header = L->getHeader(); + + // Push all Loop-header PHIs onto the Worklist stack. + for (BasicBlock::iterator I = Header->begin(); + PHINode *PN = dyn_cast(I); ++I) + Worklist.push_back(PN); +} + +/// PushDefUseChildren - Push users of the given Instruction +/// onto the given Worklist. +static void +PushDefUseChildren(Instruction *I, + SmallVectorImpl &Worklist) { + // Push the def-use children onto the Worklist stack. + for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); + UI != UE; ++UI) + Worklist.push_back(cast(UI)); +} + const ScalarEvolution::BackedgeTakenInfo & ScalarEvolution::getBackedgeTakenInfo(const Loop *L) { // Initially insert a CouldNotCompute for this loop. If the insertion @@ -2886,10 +2910,38 @@ // Now that we know more about the trip count for this loop, forget any // existing SCEV values for PHI nodes in this loop since they are only - // conservative estimates made without the benefit - // of trip count information. - if (ItCount.hasAnyInfo()) - forgetLoopPHIs(L); + // conservative estimates made without the benefit of trip count + // information. This is similar to the code in + // forgetLoopBackedgeTakenCount, except that it handles SCEVUnknown PHI + // nodes specially. + if (ItCount.hasAnyInfo()) { + SmallVector Worklist; + PushLoopPHIs(L, Worklist); + + SmallPtrSet Visited; + while (!Worklist.empty()) { + Instruction *I = Worklist.pop_back_val(); + if (!Visited.insert(I)) continue; + + std::map::iterator It = + Scalars.find(static_cast(I)); + if (It != Scalars.end()) { + // SCEVUnknown for a PHI either means that it has an unrecognized + // structure, or it's a PHI that's in the progress of being computed + // by createNodeForPHI. In the former case, additional loop trip count + // information isn't going to change anything. In the later case, + // createNodeForPHI will perform the necessary updates on its own when + // it gets to that point. + if (!isa(I) || !isa(It->second)) + Scalars.erase(It); + ValuesAtScopes.erase(I); + if (PHINode *PN = dyn_cast(I)) + ConstantEvolutionLoopExitValue.erase(PN); + } + + PushDefUseChildren(I, Worklist); + } + } } return Pair.first->second; } @@ -2900,37 +2952,25 @@ /// is deleted. void ScalarEvolution::forgetLoopBackedgeTakenCount(const Loop *L) { BackedgeTakenCounts.erase(L); - forgetLoopPHIs(L); -} -/// forgetLoopPHIs - Delete the memoized SCEVs associated with the -/// PHI nodes in the given loop. This is used when the trip count of -/// the loop may have changed. -void ScalarEvolution::forgetLoopPHIs(const Loop *L) { - BasicBlock *Header = L->getHeader(); - - // Push all Loop-header PHIs onto the Worklist stack, except those - // that are presently represented via a SCEVUnknown. SCEVUnknown for - // a PHI either means that it has an unrecognized structure, or it's - // a PHI that's in the progress of being computed by createNodeForPHI. - // In the former case, additional loop trip count information isn't - // going to change anything. In the later case, createNodeForPHI will - // perform the necessary updates on its own when it gets to that point. SmallVector Worklist; - for (BasicBlock::iterator I = Header->begin(); - PHINode *PN = dyn_cast(I); ++I) { - std::map::iterator It = - Scalars.find((Value*)I); - if (It != Scalars.end() && !isa(It->second)) - Worklist.push_back(PN); - } + PushLoopPHIs(L, Worklist); + SmallPtrSet Visited; while (!Worklist.empty()) { Instruction *I = Worklist.pop_back_val(); - if (Scalars.erase(I)) - for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); - UI != UE; ++UI) - Worklist.push_back(cast(UI)); + if (!Visited.insert(I)) continue; + + std::map::iterator It = + Scalars.find(static_cast(I)); + if (It != Scalars.end()) { + Scalars.erase(It); + ValuesAtScopes.erase(I); + if (PHINode *PN = dyn_cast(I)) + ConstantEvolutionLoopExitValue.erase(PN); + } + + PushDefUseChildren(I, Worklist); } } From clattner at apple.com Wed Jul 8 14:39:40 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 8 Jul 2009 12:39:40 -0700 Subject: [llvm-commits] [llvm] r74991 - in /llvm/trunk: docs/ include/llvm-c/ include/llvm/ include/llvm/Bitcode/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Tran In-Reply-To: References: Message-ID: On Jul 8, 2009, at 11:59 AM, Nick Lewycky wrote: > > Can this just be removed? > > No. The code as released in LLVM 2.5 had basically no correlation > between whether the instruction was [if]cmp or v[if]cmp and whether > INST_CMP or INST_CMP2 was used. The comment was only there to > confuse the reader. > > As of this commit, we only generate INST_CMP2 which has a better > chance of being read correctly by previous versions of LLVM than if > we were to generate INST_CMP. > > To make matters worse, some 2.5 version bitcode files would contain > icmp (but not fcmp?) with a bad type, such as a constant expression > icmp that returns <4 x i32> instead of <4 x i1>. Such files will no > longer load with current LLVM; we could try to autoupgrade those but > I'm inclined to say "sorry, older LLVMs were buggy and produced bad > IR in rare circumstances" than to try to deal with it. Ok. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090708/2e82503f/attachment.html From clattner at apple.com Wed Jul 8 14:40:54 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 8 Jul 2009 12:40:54 -0700 Subject: [llvm-commits] [llvm] r75025 - in /llvm/trunk: examples/BrainF/ include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Linker/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ In-Reply-To: <200907081905.n68J5C6w022262@zion.cs.uiuc.edu> References: <200907081905.n68J5C6w022262@zion.cs.uiuc.edu> Message-ID: On Jul 8, 2009, at 12:04 PM, Owen Anderson wrote: > Author: resistor > Date: Wed Jul 8 14:03:57 2009 > New Revision: 75025 > > URL: http://llvm.org/viewvc/llvm-project?rev=75025&view=rev > Log: > Switch GlobalVariable ctors to a sane API, where *either* a context > or a module is required. Ok... > +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jul 8 14:03:57 > 2009 > Value *Idxs[] = { > - Context.getConstantInt(Type::Int32Ty, Idx0), > - Context.getConstantInt(Type::Int32Ty, Idx1) > + ConstantInt::get(Type::Int32Ty, Idx0), > + ConstantInt::get(Type::Int32Ty, Idx1) > }; This (and other things) seem really wrong. -Chris From resistor at mac.com Wed Jul 8 14:43:15 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 08 Jul 2009 12:43:15 -0700 Subject: [llvm-commits] [llvm] r75025 - in /llvm/trunk: examples/BrainF/ include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Linker/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ In-Reply-To: References: <200907081905.n68J5C6w022262@zion.cs.uiuc.edu> Message-ID: <2F572201-52EA-4541-ACCF-B00C8C069969@mac.com> On Jul 8, 2009, at 12:40 PM, Chris Lattner wrote: >> +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jul 8 14:03:57 >> 2009 >> Value *Idxs[] = { >> - Context.getConstantInt(Type::Int32Ty, Idx0), >> - Context.getConstantInt(Type::Int32Ty, Idx1) >> + ConstantInt::get(Type::Int32Ty, Idx0), >> + ConstantInt::get(Type::Int32Ty, Idx1) >> }; > > This (and other things) seem really wrong. I reverted all of r74985 as part of this, because my initial attempt at fixing the API without doing so caused a lot of failures. I'll go back and reapply the relevant parts now. --Owen From isanbard at gmail.com Wed Jul 8 14:47:32 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 08 Jul 2009 19:47:32 -0000 Subject: [llvm-commits] [llvm] r75033 - /llvm/tags/Apple/llvmCore-2117/ Message-ID: <200907081947.n68JlXHH023897@zion.cs.uiuc.edu> Author: void Date: Wed Jul 8 14:47:28 2009 New Revision: 75033 URL: http://llvm.org/viewvc/llvm-project?rev=75033&view=rev Log: Creating llvmCore-2117 branch Added: llvm/tags/Apple/llvmCore-2117/ - copied from r75032, llvm/branches/Apple/Bender/ From isanbard at gmail.com Wed Jul 8 14:47:54 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 08 Jul 2009 19:47:54 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r75034 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2117/ Message-ID: <200907081947.n68Jls92023915@zion.cs.uiuc.edu> Author: void Date: Wed Jul 8 14:47:49 2009 New Revision: 75034 URL: http://llvm.org/viewvc/llvm-project?rev=75034&view=rev Log: Creating llvmgcc42-2117 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2117/ - copied from r75033, llvm-gcc-4.2/branches/Apple/Bender/ From clattner at apple.com Wed Jul 8 14:50:08 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 8 Jul 2009 12:50:08 -0700 Subject: [llvm-commits] [llvm] r75018 - in /llvm/trunk: include/llvm/Support/ lib/Target/ARM/ lib/Target/X86/ lib/Target/X86/AsmPrinter/ lib/VMCore/ In-Reply-To: <200907081802.n68I22Pc019833@zion.cs.uiuc.edu> References: <200907081802.n68I22Pc019833@zion.cs.uiuc.edu> Message-ID: On Jul 8, 2009, at 11:01 AM, Torok Edwin wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=75018&view=rev > Log: > Start converting to new error handling API. > cerr+abort -> llvm_report_error > assert(0)+abort -> LLVM_UNREACHABLE (assert(0)+llvm_unreachable-> > abort() included) Thanks Edwin, most of this looks great. Several of these below are assertions that have a message: the preferred style is something like: #ifndef NDEBUG cerr << "WHATEVER\n"; #endif unreachable(); > > +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Wed Jul 8 13:01:40 > 2009 > @@ -255,8 +257,10 @@ > else if (MO.isMBB()) > emitMachineBasicBlock(MO.getMBB(), ARM::reloc_arm_branch); > else { > - cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n"; > - abort(); > + std::string msg; > + raw_string_ostream Msg(msg); > + Msg << "ERROR: Unknown type of MachineOperand: " << MO; > + llvm_report_error(Msg.str()); This should be an assertion. > @@ -586,13 +588,12 @@ > unsigned Opcode = MI.getDesc().Opcode; > switch (Opcode) { > default: > - abort(); // FIXME: > + llvm_report_error("ARMCodeEmitter::emitPseudoInstruction");// > FIXME: This should be an assertion. > @@ -1120,7 +1120,7 @@ > const TargetInstrDesc &TID = MI.getDesc(); > > if (TID.Opcode == ARM::TPsoft) > - abort(); // FIXME > + llvm_report_error("ARM::TPsoft FIXME"); // FIXME This should be an assertion. > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp Wed Jul 8 13:01:40 2009 > @@ -123,14 +123,12 @@ > // ldr pc, [pc,#-4] > // > if (!sys::Memory::setRangeWritable((void*)StubAddr, 8)) { > - cerr << "ERROR: Unable to mark stub writable\n"; > - abort(); > + llvm_report_error("ERROR: Unable to mark stub writable"); > } > *(intptr_t *)StubAddr = 0xe51ff004; // ldr pc, [pc, #-4] > *(intptr_t *)(StubAddr+4) = NewVal; > if (!sys::Memory::setRangeExecutable((void*)StubAddr, 8)) { > - cerr << "ERROR: Unable to mark stub executable\n"; > - abort(); > + llvm_report_error("ERROR: Unable to mark stub executable"); > } > } These should be assertions. > +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Wed Jul 8 > 13:01:40 2009 > @@ -29,6 +29,7 @@ > #include "llvm/Target/TargetMachine.h" > #include "llvm/Target/TargetRegisterInfo.h" > #include "llvm/Support/Compiler.h" > +#include "llvm/Support/ErrorHandling.h" > #include "llvm/ADT/DenseMap.h" > #include "llvm/ADT/STLExtras.h" > #include "llvm/ADT/SmallPtrSet.h" > @@ -119,7 +120,7 @@ > case ARM::FSTD: > NumFSTMGened++; > return ARM::FSTMD; > - default: abort(); > + default: llvm_report_error("Unhandled opcode!"); > } > return 0; > } > @@ -441,7 +442,7 @@ > case ARM::FLDD: return ARM::FLDMD; > case ARM::FSTS: return ARM::FSTMS; > case ARM::FSTD: return ARM::FSTMD; > - default: abort(); > + default: llvm_report_error("Unhandled opcode!"); > } > return 0; > } > @@ -454,7 +455,7 @@ > case ARM::FLDD: return ARM::FLDMD; > case ARM::FSTS: return ARM::FSTMS; > case ARM::FSTD: return ARM::FSTMD; > - default: abort(); > + default: llvm_report_error("Unhandled opcode!"); > } These should be assertions. > +++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp Wed Jul 8 > 13:01:40 2009 > @@ -30,6 +30,7 @@ > #include "llvm/ADT/BitVector.h" > #include "llvm/ADT/SmallVector.h" > #include "llvm/Support/CommandLine.h" > +#include "llvm/Support/ErrorHandling.h" > using namespace llvm; > > static cl::opt > @@ -452,8 +453,7 @@ > break; > } > default: > - assert(0 && "Unsupported addressing mode!"); > - abort(); > + llvm_report_error("Unsupported addressing mode!"); Should be an assertion. > +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Wed > Jul 8 13:01:40 2009 > @@ -16,6 +16,7 @@ > #include "llvm/MC/MCInst.h" > #include "X86ATTAsmPrinter.h" > #include "llvm/Target/TargetAsmInfo.h" > +#include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/raw_ostream.h" > using namespace llvm; > > @@ -103,7 +104,7 @@ > if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) > O << DispVal; > } else { > - abort(); > + llvm_report_error("non-immediate displacement for LEA?"); Assertion. This file is not production quality yet anyway. > +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Wed Jul 8 13:01:40 > 2009 > @@ -805,10 +806,10 @@ > } > > if (!Desc->isVariadic() && CurOp != NumOps) { > - cerr << "Cannot encode: "; > - MI.dump(); > - cerr << '\n'; > - abort(); > + std::string msg; > + raw_string_ostream Msg(msg); > + Msg << "Cannot encode: " << MI; > + llvm_report_error(Msg.str()); This should be an assertion. > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul 8 > 13:01:40 2009 > @@ -33,6 +33,7 @@ > #include "llvm/CodeGen/PseudoSourceValue.h" > #include "llvm/Support/MathExtras.h" > #include "llvm/Support/Debug.h" > +#include "llvm/Support/ErrorHandling.h" > #include "llvm/Target/TargetOptions.h" > #include "llvm/ADT/SmallSet.h" > #include "llvm/ADT/StringExtras.h" > @@ -6054,8 +6055,7 @@ > SDValue SrcPtr = Op.getOperand(1); > SDValue SrcSV = Op.getOperand(2); > > - assert(0 && "VAArgInst is not yet implemented for x86-64!"); > - abort(); > + LLVM_UNREACHABLE("VAArgInst is not yet implemented for x86-64!"); > return SDValue(); This should be a report_error. > > @@ -3196,10 +3196,10 @@ > } > > if (!Desc->isVariadic() && CurOp != NumOps) { > - cerr << "Cannot determine size: "; > - MI.dump(); > - cerr << '\n'; > - abort(); > + std::string msg; > + raw_string_ostream Msg(msg); > + Msg << "Cannot determine size: " << MI; > + llvm_report_error(Msg.str()); > } assertion. > > +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Wed Jul 8 13:01:40 2009 > @@ -31,6 +31,7 @@ > #include "llvm/ADT/StringExtras.h" > #include "llvm/ADT/STLExtras.h" > #include "llvm/Support/CFG.h" > +#include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/MathExtras.h" > #include "llvm/Support/raw_ostream.h" > #include > @@ -1234,8 +1235,7 @@ > case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; > case GlobalValue::ExternalLinkage: break; > case GlobalValue::GhostLinkage: > - Out << "GhostLinkage not allowed in AsmWriter!\n"; > - abort(); > + llvm_report_error("GhostLinkage not allowed in AsmWriter!"); assertion. > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/Type.cpp (original) > +++ llvm/trunk/lib/VMCore/Type.cpp Wed Jul 8 13:01:40 2009 > @@ -20,6 +20,7 @@ > #include "llvm/ADT/STLExtras.h" > #include "llvm/Support/Compiler.h" > #include "llvm/Support/Debug.h" > +#include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/ManagedStatic.h" > #include "llvm/Support/MathExtras.h" > #include "llvm/Support/raw_ostream.h" > @@ -264,10 +265,10 @@ > } > > void Type::refineAbstractType(const DerivedType *OldTy, const Type > *NewTy) { > - abort(); > + llvm_report_error("Attempting to refine a derived type!"); > } > void Type::typeBecameConcrete(const DerivedType *AbsTy) { > - abort(); > + llvm_report_error("DerivedType is already a concrete type!"); > } assertion. > +++ llvm/trunk/lib/VMCore/Value.cpp Wed Jul 8 13:01:40 2009 > @@ -19,6 +19,7 @@ > #include "llvm/Module.h" > #include "llvm/ValueSymbolTable.h" > #include "llvm/Support/Debug.h" > +#include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/LeakDetector.h" > #include "llvm/Support/ManagedStatic.h" > #include "llvm/Support/ValueHandle.h" > @@ -514,8 +515,8 @@ > cerr << "While deleting: " << *V->getType() << " %" << V- > >getNameStr() > << "\n"; > #endif > - cerr << "An asserting value handle still pointed to this > value!\n"; > - abort(); > + llvm_report_error("An asserting value handle still pointed to > this" > + "value!"); Assertion. > +++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Jul 8 13:01:40 2009 > @@ -62,6 +62,7 @@ > #include "llvm/ADT/StringExtras.h" > #include "llvm/ADT/STLExtras.h" > #include "llvm/Support/Compiler.h" > +#include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/raw_ostream.h" > #include > #include > @@ -93,7 +94,7 @@ > } > > if (Broken) > - abort(); > + llvm_report_error("Broken module, no Basic Block > terminator!"); > > return false; > } > @@ -210,8 +211,7 @@ > default: assert(0 && "Unknown action"); > case AbortProcessAction: > msgs << "compilation aborted!\n"; > - cerr << msgs.str(); > - abort(); > + llvm_report_error(msgs.str()); > case PrintMessageAction: > msgs << "verification continues.\n"; > cerr << msgs.str(); The verifier really should abort when the action is AbortProcessAction. Clients that want to use the verifier in other modes can pick a different reaction. -Chris From clattner at apple.com Wed Jul 8 15:00:51 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 8 Jul 2009 13:00:51 -0700 Subject: [llvm-commits] [llvm] r75027 - in /llvm/trunk: include/llvm/CodeGen/ include/llvm/Support/ lib/Target/Alpha/ lib/Target/Alpha/AsmPrinter/ lib/Target/IA64/ lib/Target/IA64/AsmPrinter/ lib/Target/MSP430/ lib/Target/Mips/AsmPrinter/ lib/Target/PIC16/ lib/Target/Sparc/AsmPrinter/ lib/Target/X86/ lib/Target/XCore/ utils/TableGen/ In-Reply-To: <200907081905.n68J5D0L022265@zion.cs.uiuc.edu> References: <200907081905.n68J5D0L022265@zion.cs.uiuc.edu> Message-ID: <1D0FF115-7457-4C11-97B9-14450DD66259@apple.com> On Jul 8, 2009, at 12:04 PM, Torok Edwin wrote: > Log: > Convert more abort() calls to llvm_report_error(). > Also remove trailing semicolon. Ok. > +++ llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h Wed Jul 8 > 14:04:27 2009 > @@ -18,6 +18,8 @@ > #define LLVM_CODEGEN_MACHINECODEEMITTER_H > > #include "llvm/Support/DataTypes.h" > +#include "llvm/Support/ErrorHandling.h" > +#include "llvm/Support/raw_ostream.h" Please don't include headers in other headers unless you cannot avoid it. > +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Wed Jul 8 > 14:04:27 2009 > @@ -19,6 +19,8 @@ > #include "llvm/Pass.h" > #include "llvm/Constant.h" > #include "llvm/CodeGen/SelectionDAG.h" > +#include "llvm/Support/ErrorHandling.h" > +#include "llvm/Support/raw_ostream.h" Likewise. > +++ llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp Wed Jul 8 > 14:04:27 2009 > @@ -234,9 +234,11 @@ > } else if (MO.isMBB()) { > > MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(), > Alpha::reloc_bsr, > MO.getMBB())); > - }else { > - cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n"; > - abort(); > + } else { > + std::string msg; > + raw_string_ostream Msg(msg); > + Msg << "ERROR: Unknown type of MachineOperand: " << MO; > + llvm_report_error(Msg.str()); > } Should be an assertion. > +++ llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp Wed Jul 8 > 14:04:27 2009 > @@ -19,6 +19,7 @@ > #include "llvm/ADT/STLExtras.h" > #include "llvm/ADT/SmallVector.h" > #include "llvm/CodeGen/MachineInstrBuilder.h" > +#include "llvm/Support/ErrorHandling.h" > using namespace llvm; > > AlphaInstrInfo::AlphaInstrInfo() > @@ -200,7 +201,7 @@ > .addReg(SrcReg, getKillRegState(isKill)) > .addFrameIndex(FrameIdx).addReg(Alpha::F31); > else > - abort(); > + llvm_report_error("Unhandled register class"); > } > > void AlphaInstrInfo::storeRegToAddr(MachineFunction &MF, unsigned > SrcReg, > @@ -216,7 +217,7 @@ > else if (RC == Alpha::GPRCRegisterClass) > Opc = Alpha::STQ; > else > - abort(); > + llvm_report_error("Unhandled register class"); > DebugLoc DL = DebugLoc::getUnknownLoc(); > MachineInstrBuilder MIB = > BuildMI(MF, DL, get(Opc)).addReg(SrcReg, getKillRegState(isKill)); > @@ -245,7 +246,7 @@ > BuildMI(MBB, MI, DL, get(Alpha::LDQ), DestReg) > .addFrameIndex(FrameIdx).addReg(Alpha::F31); > else > - abort(); > + llvm_report_error("Unhandled register class"); > } > > void AlphaInstrInfo::loadRegFromAddr(MachineFunction &MF, unsigned > DestReg, > @@ -260,7 +261,7 @@ > else if (RC == Alpha::GPRCRegisterClass) > Opc = Alpha::LDQ; > else > - abort(); > + llvm_report_error("Unhandled register class"); > DebugLoc DL = DebugLoc::getUnknownLoc(); > MachineInstrBuilder MIB = > BuildMI(MF, DL, get(Opc), DestReg); These should all be assertions. > > +++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Wed > Jul 8 14:04:27 2009 > @@ -100,8 +101,7 @@ > return; > > case MachineOperand::MO_Immediate: > - cerr << "printOp() does not handle immediate values\n"; > - abort(); > + llvm_report_error("printOp() does not handle immediate values"); > return; assertion. > > +++ llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp Wed > Jul 8 14:04:27 2009 > @@ -26,6 +26,7 @@ > #include "llvm/CodeGen/DwarfWriter.h" > #include "llvm/CodeGen/MachineFunctionPass.h" > #include "llvm/Target/TargetAsmInfo.h" > +#include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/Mangler.h" > #include "llvm/Support/raw_ostream.h" > #include "llvm/ADT/Statistic.h" > @@ -317,16 +318,13 @@ > case GlobalValue::PrivateLinkage: > break; > case GlobalValue::GhostLinkage: > - cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n"; > - abort(); > + llvm_report_error("GhostLinkage cannot appear in > IA64AsmPrinter!"); > case GlobalValue::DLLImportLinkage: > - cerr << "DLLImport linkage is not supported by this target!\n"; > - abort(); > + llvm_report_error("DLLImport linkage is not supported by this > target!"); > case GlobalValue::DLLExportLinkage: > - cerr << "DLLExport linkage is not supported by this target!\n"; > - abort(); > + llvm_report_error("DLLExport linkage is not supported by this > target!"); assertions. > +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Wed Jul 8 > 14:04:27 2009 > @@ -32,6 +32,7 @@ > #include "llvm/CodeGen/SelectionDAGISel.h" > #include "llvm/CodeGen/ValueTypes.h" > #include "llvm/Support/Debug.h" > +#include "llvm/Support/ErrorHandling.h" > #include "llvm/ADT/VectorExtras.h" > using namespace llvm; > > @@ -190,11 +191,14 @@ > // Arguments passed in registers > MVT RegVT = VA.getLocVT(); > switch (RegVT.getSimpleVT()) { > - default: > - cerr << "LowerFORMAL_ARGUMENTS Unhandled argument type: " > - << RegVT.getSimpleVT() > - << "\n"; > - abort(); > + default: > + { > + std::string msg; > + raw_string_ostream Msg(msg); > + Msg << "LowerFORMAL_ARGUMENTS Unhandled argument type: " > + << RegVT.getSimpleVT(); > + llvm_report_error(Msg.str()); assertion. > +++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Wed > Jul 8 14:04:27 2009 > @@ -405,7 +406,7 @@ > break; > > default: > - O << ""; abort (); break; > + llvm_report_error(""); break; assertion. > } > > if (closeP) O << ")"; > @@ -544,16 +545,13 @@ > printSizeAndType = false; > break; > case GlobalValue::GhostLinkage: > - cerr << "Should not have any unmaterialized functions!\n"; > - abort(); > + llvm_report_error("Should not have any unmaterialized > functions!"); > case GlobalValue::DLLImportLinkage: > - cerr << "DLLImport linkage is not supported by this target!\n"; > - abort(); > + llvm_report_error("DLLImport linkage is not supported by this > target!"); > case GlobalValue::DLLExportLinkage: > - cerr << "DLLExport linkage is not supported by this target!\n"; > - abort(); > + llvm_report_error("DLLExport linkage is not supported by this > target!"); assertions. > > +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Wed > Jul 8 14:04:27 2009 > @@ -184,7 +185,7 @@ > << MO.getIndex(); > break; > default: > - O << ""; abort (); break; > + llvm_report_error(""); break; assertion. > } > if (CloseParen) O << ")"; > } > @@ -298,16 +299,13 @@ > case GlobalValue::InternalLinkage: > break; > case GlobalValue::GhostLinkage: > - cerr << "Should not have any unmaterialized functions!\n"; > - abort(); > + llvm_report_error("Should not have any unmaterialized > functions!"); > case GlobalValue::DLLImportLinkage: > - cerr << "DLLImport linkage is not supported by this target!\n"; > - abort(); > + llvm_report_error("DLLImport linkage is not supported by this > target!"); > case GlobalValue::DLLExportLinkage: > - cerr << "DLLExport linkage is not supported by this target!\n"; > - abort(); > + llvm_report_error("DLLExport linkage is not supported by this > target!"); assertions. > > +++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Wed Jul 8 > 14:04:27 2009 > @@ -204,14 +204,11 @@ > case GlobalValue::PrivateLinkage: > break; > case GlobalValue::GhostLinkage: > - cerr << "Should not have any unmaterialized functions!\n"; > - abort(); > + llvm_report_error("Should not have any unmaterialized > functions!"); > case GlobalValue::DLLImportLinkage: > - cerr << "DLLImport linkage is not supported by this target!\n"; > - abort(); > + llvm_report_error("DLLImport linkage is not supported by this > target!"); > case GlobalValue::DLLExportLinkage: > - cerr << "DLLExport linkage is not supported by this target!\n"; > - abort(); > + llvm_report_error("DLLExport linkage is not supported by this > target!"); assertions. :) > > +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Wed Jul 8 > 14:04:27 2009 > @@ -270,9 +270,8 @@ > } > const Type *Ty = cast(GV->getType())->getElementType(); > if (!Ty->isSized() || isZeroLengthArray(Ty)) { > - cerr << "Size of thread local object " << GVar->getName() > - << " is unknown\n"; > - abort(); > + llvm_report_error("Size of thread local object " + GVar- > >getName() > + + " is unknown"); This should be an assertion, does the verifier catch this? If not, it should. > } > SDValue base = getGlobalAddressWrapper(GA, GV, DAG); > const TargetData *TD = TM.getTargetData(); > @@ -646,10 +645,13 @@ > MVT RegVT = VA.getLocVT(); > switch (RegVT.getSimpleVT()) { > default: > - cerr << "LowerFORMAL_ARGUMENTS Unhandled argument type: " > - << RegVT.getSimpleVT() > - << "\n"; > - abort(); > + { > + std::string msg; > + raw_string_ostream Msg(msg); > + Msg << "LowerFORMAL_ARGUMENTS Unhandled argument type: " > + << RegVT.getSimpleVT(); > + llvm_report_error(Msg.str()); > + } assertion. > > +++ llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp Wed Jul 8 > 14:04:27 2009 > @@ -30,6 +30,8 @@ > #include "llvm/ADT/BitVector.h" > #include "llvm/ADT/STLExtras.h" > #include "llvm/Support/Debug.h" > +#include "llvm/Support/ErrorHandling.h" > +#include "llvm/Support/raw_ostream.h" > > using namespace llvm; > > @@ -142,9 +144,11 @@ > > if (!isU6 && !isImmU16(Amount)) { > // FIX could emit multiple instructions in this case. > - cerr << "eliminateCallFramePseudoInstr size too big: " > - << Amount << "\n"; > - abort(); > + std::string msg; > + raw_string_ostream Msg(msg); > + Msg << "eliminateCallFramePseudoInstr size too big: " > + << Amount; > + llvm_report_error(Msg.str()); assertion. > +++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Wed Jul 8 14:04:27 > 2009 > @@ -243,8 +243,10 @@ > > // Default case: unhandled opcode > o << " default:\n" > - << " cerr << \"Not supported instr: \" << MI << \"\\n\";\n" > - << " abort();\n" > + << " std::string msg;\n" > + << " raw_string_ostream Msg(msg);\n" > + << " Msg << \"Not supported instr: \" << MI;\n" > + << " llvm_report_error(Msg.str());\n" Yay :) -Chris From clattner at apple.com Wed Jul 8 15:01:02 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 8 Jul 2009 13:01:02 -0700 Subject: [llvm-commits] [llvm] r75025 - in /llvm/trunk: examples/BrainF/ include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Linker/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ In-Reply-To: <2F572201-52EA-4541-ACCF-B00C8C069969@mac.com> References: <200907081905.n68J5C6w022262@zion.cs.uiuc.edu> <2F572201-52EA-4541-ACCF-B00C8C069969@mac.com> Message-ID: ok On Jul 8, 2009, at 12:43 PM, Owen Anderson wrote: > > On Jul 8, 2009, at 12:40 PM, Chris Lattner wrote: >>> +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jul 8 14:03:57 >>> 2009 >>> Value *Idxs[] = { >>> - Context.getConstantInt(Type::Int32Ty, Idx0), >>> - Context.getConstantInt(Type::Int32Ty, Idx1) >>> + ConstantInt::get(Type::Int32Ty, Idx0), >>> + ConstantInt::get(Type::Int32Ty, Idx1) >>> }; >> >> This (and other things) seem really wrong. > > I reverted all of r74985 as part of this, because my initial attempt > at fixing the API without doing so caused a lot of failures. I'll go > back and reapply the relevant parts now. > > --Owen > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From vkutuzov at accesssoftek.com Wed Jul 8 15:06:24 2009 From: vkutuzov at accesssoftek.com (Viktor Kutuzov) Date: Wed, 8 Jul 2009 13:06:24 -0700 Subject: [llvm-commits] [PATCH] Fix for Path::makeAbsolute Message-ID: Hello everyone, The Path::makeAbsolute for Windows doesn't handle correctly a given absolute path with a drive letter or any UNC name. Please find the patch attached. -Viktor -------------- next part -------------- A non-text attachment was scrubbed... Name: makeAbsolute.patch Type: application/octet-stream Size: 2937 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090708/798a2a92/attachment.obj From xerxes at zafena.se Wed Jul 8 15:14:26 2009 From: xerxes at zafena.se (Xerxes Ranby) Date: Wed, 08 Jul 2009 20:14:26 -0000 Subject: [llvm-commits] [llvm] r75035 - /llvm/trunk/lib/Target/ARM/CMakeLists.txt Message-ID: <200907082014.n68KEUSH025023@zion.cs.uiuc.edu> Author: xranby Date: Wed Jul 8 15:13:41 2009 New Revision: 75035 URL: http://llvm.org/viewvc/llvm-project?rev=75035&view=rev Log: Fix cmake build. Added ARMBaseRegisterInfo.cpp to lib/Target/ARM/CMakeLists.txt Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/CMakeLists.txt?rev=75035&r1=75034&r2=75035&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/ARM/CMakeLists.txt Wed Jul 8 15:13:41 2009 @@ -13,6 +13,7 @@ add_llvm_target(ARMCodeGen ARMBaseInstrInfo.cpp + ARMBaseRegisterInfo.cpp ARMCodeEmitter.cpp ARMConstantIslandPass.cpp ARMConstantPoolValue.cpp From david_goodwin at apple.com Wed Jul 8 15:29:01 2009 From: david_goodwin at apple.com (David Goodwin) Date: Wed, 08 Jul 2009 20:29:01 -0000 Subject: [llvm-commits] [llvm] r75036 - in /llvm/trunk/lib/Target/ARM: ARMBaseInstrInfo.h ARMBaseRegisterInfo.cpp ARMBaseRegisterInfo.h ARMInstrInfo.cpp ARMInstrThumb2.td ARMRegisterInfo.cpp Thumb1InstrInfo.cpp Thumb1RegisterInfo.cpp Thumb1RegisterInfo.h Thumb2InstrInfo.cpp Thumb2RegisterInfo.cpp Thumb2RegisterInfo.h Message-ID: <200907082029.n68KTDAW025510@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Jul 8 15:28:28 2009 New Revision: 75036 URL: http://llvm.org/viewvc/llvm-project?rev=75036&view=rev Log: Generalize opcode selection in ARMBaseRegisterInfo. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Wed Jul 8 15:28:28 2009 @@ -169,6 +169,7 @@ BR_JTr, BR_JTm, BR_JTadd, + BX_RET, FCPYS, FCPYD, FLDD, Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Jul 8 15:28:28 2009 @@ -155,6 +155,11 @@ FramePtr((STI.isTargetDarwin() || STI.isThumb()) ? ARM::R7 : ARM::R11) { } +unsigned ARMBaseRegisterInfo:: +getOpcode(int Op) const { + return TII.getOpcode((ARMII::Op)Op); +} + const unsigned* ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { static const unsigned CalleeSavedRegs[] = { @@ -878,7 +883,7 @@ void ARMBaseRegisterInfo:: emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo *TII, DebugLoc dl, + DebugLoc dl, unsigned DestReg, int Val, ARMCC::CondCodes Pred, unsigned PredReg) const { @@ -887,7 +892,7 @@ Constant *C = ConstantInt::get(Type::Int32Ty, Val); unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4); - BuildMI(MBB, MBBI, dl, TII->get(ARM::LDRcp), DestReg) + BuildMI(MBB, MBBI, dl, TII.get(ARM::LDRcp), DestReg) .addConstantPoolIndex(Idx) .addReg(0).addImm(0).addImm(Pred).addReg(PredReg); } @@ -923,7 +928,7 @@ MachineBasicBlock::iterator &MBBI, unsigned DestReg, unsigned BaseReg, int NumBytes, ARMCC::CondCodes Pred, unsigned PredReg, - const TargetInstrInfo &TII, + const ARMBaseInstrInfo &TII, DebugLoc dl) { bool isSub = NumBytes < 0; if (isSub) NumBytes = -NumBytes; @@ -941,7 +946,7 @@ assert(SOImmVal != -1 && "Bit extraction didn't work?"); // Build the new ADD / SUB. - BuildMI(MBB, MBBI, dl, TII.get(isSub ? ARM::SUBri : ARM::ADDri), DestReg) + BuildMI(MBB, MBBI, dl, TII.get(TII.getOpcode(isSub ? ARMII::SUBri : ARMII::ADDri)), DestReg) .addReg(BaseReg, RegState::Kill).addImm(SOImmVal) .addImm((unsigned)Pred).addReg(PredReg).addReg(0); BaseReg = DestReg; @@ -950,7 +955,7 @@ static void emitSPUpdate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo &TII, DebugLoc dl, + const ARMBaseInstrInfo &TII, DebugLoc dl, int NumBytes, ARMCC::CondCodes Pred = ARMCC::AL, unsigned PredReg = 0) { emitARMRegPlusImmediate(MBB, MBBI, ARM::SP, ARM::SP, NumBytes, @@ -1050,18 +1055,18 @@ if (Opcode == ARM::INLINEASM) AddrMode = ARMII::AddrMode2; - if (Opcode == ARM::ADDri) { + if (Opcode == getOpcode(ARMII::ADDri)) { Offset += MI.getOperand(i+1).getImm(); if (Offset == 0) { // Turn it into a move. - MI.setDesc(TII.get(ARM::MOVr)); + MI.setDesc(TII.get(getOpcode(ARMII::MOVr))); MI.getOperand(i).ChangeToRegister(FrameReg, false); MI.RemoveOperand(i+1); return; } else if (Offset < 0) { Offset = -Offset; isSub = true; - MI.setDesc(TII.get(ARM::SUBri)); + MI.setDesc(TII.get(getOpcode(ARMII::SUBri))); } // Common case: small offset, fits into instruction. @@ -1270,13 +1275,13 @@ // Build the new SUBri to adjust SP for integer callee-save spill area 1. emitSPUpdate(MBB, MBBI, TII, dl, -GPRCS1Size); - movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI); + movePastCSLoadStoreOps(MBB, MBBI, getOpcode(ARMII::STR), 1, STI); // Darwin ABI requires FP to point to the stack slot that contains the // previous FP. if (STI.isTargetDarwin() || hasFP(MF)) { MachineInstrBuilder MIB = - BuildMI(MBB, MBBI, dl, TII.get(ARM::ADDri), FramePtr) + BuildMI(MBB, MBBI, dl, TII.get(getOpcode(ARMII::ADDri)), FramePtr) .addFrameIndex(FramePtrSpillFI).addImm(0); AddDefaultCC(AddDefaultPred(MIB)); } @@ -1285,7 +1290,7 @@ emitSPUpdate(MBB, MBBI, TII, dl, -GPRCS2Size); // Build the new SUBri to adjust SP for FP callee-save spill area. - movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 2, STI); + movePastCSLoadStoreOps(MBB, MBBI, getOpcode(ARMII::STR), 2, STI); emitSPUpdate(MBB, MBBI, TII, dl, -DPRCSSize); // Determine starting offsets of spill areas. @@ -1300,7 +1305,7 @@ NumBytes = DPRCSOffset; if (NumBytes) { // Insert it after all the callee-save spills. - movePastCSLoadStoreOps(MBB, MBBI, ARM::FSTD, 3, STI); + movePastCSLoadStoreOps(MBB, MBBI, getOpcode(ARMII::FSTD), 3, STI); emitSPUpdate(MBB, MBBI, TII, dl, -NumBytes); } @@ -1321,9 +1326,11 @@ return false; } -static bool isCSRestore(MachineInstr *MI, const unsigned *CSRegs) { - return ((MI->getOpcode() == ARM::FLDD || - MI->getOpcode() == ARM::LDR) && +static bool isCSRestore(MachineInstr *MI, + const ARMBaseInstrInfo &TII, + const unsigned *CSRegs) { + return ((MI->getOpcode() == (int)TII.getOpcode(ARMII::FLDD) || + MI->getOpcode() == (int)TII.getOpcode(ARMII::LDR)) && MI->getOperand(1).isFI() && isCalleeSavedRegister(MI->getOperand(0).getReg(), CSRegs)); } @@ -1332,7 +1339,7 @@ emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const { MachineBasicBlock::iterator MBBI = prior(MBB.end()); - assert(MBBI->getOpcode() == ARM::BX_RET && + assert(MBBI->getOpcode() == (int)getOpcode(ARMII::BX_RET) && "Can only insert epilog into returning blocks"); DebugLoc dl = MBBI->getDebugLoc(); MachineFrameInfo *MFI = MF.getFrameInfo(); @@ -1349,8 +1356,8 @@ if (MBBI != MBB.begin()) { do --MBBI; - while (MBBI != MBB.begin() && isCSRestore(MBBI, CSRegs)); - if (!isCSRestore(MBBI, CSRegs)) + while (MBBI != MBB.begin() && isCSRestore(MBBI, TII, CSRegs)); + if (!isCSRestore(MBBI, TII, CSRegs)) ++MBBI; } @@ -1370,11 +1377,11 @@ AFI->getDPRCalleeSavedAreaOffset()|| hasFP(MF)) { if (NumBytes) - BuildMI(MBB, MBBI, dl, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr) + BuildMI(MBB, MBBI, dl, TII.get(getOpcode(ARMII::SUBri)), ARM::SP).addReg(FramePtr) .addImm(NumBytes) .addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); else - BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP).addReg(FramePtr) + BuildMI(MBB, MBBI, dl, TII.get(getOpcode(ARMII::MOVr)), ARM::SP).addReg(FramePtr) .addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); } } else if (NumBytes) { @@ -1382,15 +1389,15 @@ } // Move SP to start of integer callee save spill area 2. - movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI); + movePastCSLoadStoreOps(MBB, MBBI, getOpcode(ARMII::FLDD), 3, STI); emitSPUpdate(MBB, MBBI, TII, dl, AFI->getDPRCalleeSavedAreaSize()); // Move SP to start of integer callee save spill area 1. - movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 2, STI); + movePastCSLoadStoreOps(MBB, MBBI, getOpcode(ARMII::LDR), 2, STI); emitSPUpdate(MBB, MBBI, TII, dl, AFI->getGPRCalleeSavedArea2Size()); // Move SP to SP upon entry to the function. - movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 1, STI); + movePastCSLoadStoreOps(MBB, MBBI, getOpcode(ARMII::LDR), 1, STI); emitSPUpdate(MBB, MBBI, TII, dl, AFI->getGPRCalleeSavedArea1Size()); } Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Wed Jul 8 15:28:28 2009 @@ -55,6 +55,9 @@ // Can be only subclassed. explicit ARMBaseRegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &STI); + // Return the opcode that implements 'Op', or 0 if no opcode + unsigned getOpcode(int Op) const; + public: /// getRegisterNumbering - Given the enum value for some register, e.g. /// ARM::LR, return the number that it corresponds to (e.g. 14). @@ -107,7 +110,7 @@ /// specified immediate. virtual void emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo *TII, DebugLoc dl, + DebugLoc dl, unsigned DestReg, int Val, ARMCC::CondCodes Pred = ARMCC::AL, unsigned PredReg = 0) const; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Wed Jul 8 15:28:28 2009 @@ -73,6 +73,7 @@ case ARMII::BR_JTr: return ARM::BR_JTr; case ARMII::BR_JTm: return ARM::BR_JTm; case ARMII::BR_JTadd: return ARM::BR_JTadd; + case ARMII::BX_RET: return ARM::BX_RET; case ARMII::FCPYS: return ARM::FCPYS; case ARMII::FCPYD: return ARM::FCPYD; case ARMII::FLDD: return ARM::FLDD; @@ -120,7 +121,7 @@ const MachineInstr *Orig) const { DebugLoc dl = Orig->getDebugLoc(); if (Orig->getOpcode() == ARM::MOVi2pieces) { - RI.emitLoadConstPool(MBB, I, this, dl, + RI.emitLoadConstPool(MBB, I, dl, DestReg, Orig->getOperand(1).getImm(), (ARMCC::CondCodes)Orig->getOperand(2).getImm(), Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Wed Jul 8 15:28:28 2009 @@ -1063,34 +1063,34 @@ // Control-Flow Instructions // -//let isReturn = 1, isTerminator = 1 in -// def t2BX_RET : T2XI<(outs), (ins), "bx lr", [(ARMretflag)]>; -// +let isReturn = 1, isTerminator = 1 in + def t2BX_RET : T2XI<(outs), (ins), "bx lr", [(ARMretflag)]>; + // On non-Darwin platforms R9 is callee-saved. -//let isCall = 1, -// Defs = [R0, R1, R2, R3, R12, LR, -// D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in { -//def t2BL : T2XI<(outs), (ins i32imm:$func, variable_ops), -// "bl ${func:call}", -// [(ARMcall tglobaladdr:$func)]>, Requires<[IsNotDarwin]>; -// -//def t2BLX : T2XI<(outs), (ins GPR:$func, variable_ops), -// "blx $func", -// [(ARMcall GPR:$func)]>, Requires<[IsNotDarwin]>; -//} +let isCall = 1, + Defs = [R0, R1, R2, R3, R12, LR, + D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in { +def t2BL : T2XI<(outs), (ins i32imm:$func, variable_ops), + "bl ${func:call}", + [(ARMcall tglobaladdr:$func)]>, Requires<[IsNotDarwin]>; + +def t2BLX : T2XI<(outs), (ins GPR:$func, variable_ops), + "blx $func", + [(ARMcall GPR:$func)]>, Requires<[IsNotDarwin]>; +} // On Darwin R9 is call-clobbered. -//let isCall = 1, -// Defs = [R0, R1, R2, R3, R9, R12, LR, -// D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in { -//def t2BLr9 : T2XI<(outs), (ins i32imm:$func, variable_ops), -// "bl ${func:call}", -// [(ARMcall tglobaladdr:$func)]>, Requires<[IsDarwin]>; -// -//def t2BLXr9 : T2XI<(outs), (ins GPR:$func, variable_ops), -// "blx $func", -// [(ARMcall GPR:$func)]>, Requires<[IsDarwin]>; -//} +let isCall = 1, + Defs = [R0, R1, R2, R3, R9, R12, LR, + D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in { +def t2BLr9 : T2XI<(outs), (ins i32imm:$func, variable_ops), + "bl ${func:call}", + [(ARMcall tglobaladdr:$func)]>, Requires<[IsDarwin]>; + +def t2BLXr9 : T2XI<(outs), (ins GPR:$func, variable_ops), + "blx $func", + [(ARMcall GPR:$func)]>, Requires<[IsDarwin]>; +} let isBranch = 1, isTerminator = 1, isBarrier = 1 in { let isPredicable = 1 in Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Wed Jul 8 15:28:28 2009 @@ -13,6 +13,7 @@ #include "ARM.h" #include "ARMAddressingModes.h" +#include "ARMBaseInstrInfo.h" #include "ARMInstrInfo.h" #include "ARMMachineFunctionInfo.h" #include "ARMRegisterInfo.h" Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Wed Jul 8 15:28:28 2009 @@ -42,6 +42,7 @@ case ARMII::BR_JTr: return ARM::tBR_JTr; case ARMII::BR_JTm: return 0; case ARMII::BR_JTadd: return 0; + case ARMII::BX_RET: return ARM::tBX_RET; case ARMII::FCPYS: return 0; case ARMII::FCPYD: return 0; case ARMII::FLDD: return 0; Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Wed Jul 8 15:28:28 2009 @@ -13,6 +13,7 @@ #include "ARM.h" #include "ARMAddressingModes.h" +#include "ARMBaseInstrInfo.h" #include "ARMMachineFunctionInfo.h" #include "ARMSubtarget.h" #include "Thumb1InstrInfo.h" @@ -47,7 +48,7 @@ /// specified immediate. void Thumb1RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo *TII, DebugLoc dl, + DebugLoc dl, unsigned DestReg, int Val, ARMCC::CondCodes Pred, unsigned PredReg) const { @@ -56,7 +57,7 @@ Constant *C = ConstantInt::get(Type::Int32Ty, Val); unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4); - BuildMI(MBB, MBBI, dl, TII->get(ARM::tLDRcp), DestReg) + BuildMI(MBB, MBBI, dl, TII.get(ARM::tLDRcp), DestReg) .addConstantPoolIndex(Idx); } @@ -131,7 +132,7 @@ BuildMI(MBB, MBBI, dl, TII.get(ARM::tNEG), LdReg) .addReg(LdReg, RegState::Kill); } else - MRI.emitLoadConstPool(MBB, MBBI, &TII, dl, LdReg, NumBytes); + MRI.emitLoadConstPool(MBB, MBBI, dl, LdReg, NumBytes); // Emit add / sub. int Opc = (isSub) ? ARM::tSUBrr : (isHigh ? ARM::tADDhirr : ARM::tADDrr); @@ -505,7 +506,7 @@ emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg, Offset, false, TII, *this, dl); else { - emitLoadConstPool(MBB, II, &TII, dl, TmpReg, Offset); + emitLoadConstPool(MBB, II, dl, TmpReg, Offset); UseRR = true; } } else @@ -543,7 +544,7 @@ emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg, Offset, false, TII, *this, dl); else { - emitLoadConstPool(MBB, II, &TII, dl, TmpReg, Offset); + emitLoadConstPool(MBB, II, dl, TmpReg, Offset); UseRR = true; } } else Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h Wed Jul 8 15:28:28 2009 @@ -31,7 +31,7 @@ /// specified immediate. void emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo *TII, DebugLoc dl, + DebugLoc dl, unsigned DestReg, int Val, ARMCC::CondCodes Pred = ARMCC::AL, unsigned PredReg = 0) const; Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Wed Jul 8 15:28:28 2009 @@ -43,6 +43,7 @@ case ARMII::BR_JTr: return ARM::t2BR_JTr; case ARMII::BR_JTm: return ARM::t2BR_JTm; case ARMII::BR_JTadd: return ARM::t2BR_JTadd; + case ARMII::BX_RET: return ARM::t2BX_RET; case ARMII::FCPYS: return ARM::FCPYS; case ARMII::FCPYD: return ARM::FCPYD; case ARMII::FLDD: return ARM::FLDD; Modified: llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp Wed Jul 8 15:28:28 2009 @@ -13,6 +13,7 @@ #include "ARM.h" #include "ARMAddressingModes.h" +#include "ARMBaseInstrInfo.h" #include "ARMMachineFunctionInfo.h" #include "ARMSubtarget.h" #include "Thumb2InstrInfo.h" @@ -47,7 +48,7 @@ /// specified immediate. void Thumb2RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo *TII, DebugLoc dl, + DebugLoc dl, unsigned DestReg, int Val, ARMCC::CondCodes Pred, unsigned PredReg) const { @@ -56,8 +57,8 @@ Constant *C = ConstantInt::get(Type::Int32Ty, Val); unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4); - BuildMI(MBB, MBBI, dl, TII->get(ARM::tLDRcp), DestReg) - .addConstantPoolIndex(Idx); + BuildMI(MBB, MBBI, dl, TII.get(ARM::t2LDRpci), DestReg) + .addConstantPoolIndex(Idx).addImm(Pred).addReg(PredReg); } const TargetRegisterClass* @@ -131,7 +132,7 @@ BuildMI(MBB, MBBI, dl, TII.get(ARM::tNEG), LdReg) .addReg(LdReg, RegState::Kill); } else - MRI.emitLoadConstPool(MBB, MBBI, &TII, dl, LdReg, NumBytes); + MRI.emitLoadConstPool(MBB, MBBI, dl, LdReg, NumBytes); // Emit add / sub. int Opc = (isSub) ? ARM::tSUBrr : (isHigh ? ARM::tADDhirr : ARM::tADDrr); @@ -505,7 +506,7 @@ emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg, Offset, false, TII, *this, dl); else { - emitLoadConstPool(MBB, II, &TII, dl, TmpReg, Offset); + emitLoadConstPool(MBB, II, dl, TmpReg, Offset); UseRR = true; } } else @@ -543,7 +544,7 @@ emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg, Offset, false, TII, *this, dl); else { - emitLoadConstPool(MBB, II, &TII, dl, TmpReg, Offset); + emitLoadConstPool(MBB, II, dl, TmpReg, Offset); UseRR = true; } } else Modified: llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h?rev=75036&r1=75035&r2=75036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h Wed Jul 8 15:28:28 2009 @@ -31,7 +31,7 @@ /// specified immediate. void emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, - const TargetInstrInfo *TII, DebugLoc dl, + DebugLoc dl, unsigned DestReg, int Val, ARMCC::CondCodes Pred = ARMCC::AL, unsigned PredReg = 0) const; From bob.wilson at apple.com Wed Jul 8 15:32:04 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 08 Jul 2009 20:32:04 -0000 Subject: [llvm-commits] [llvm] r75037 - in /llvm/trunk: lib/Target/ARM/ARMInstrNEON.td test/CodeGen/ARM/vst1.ll Message-ID: <200907082032.n68KW4JI025599@zion.cs.uiuc.edu> Author: bwilson Date: Wed Jul 8 15:32:02 2009 New Revision: 75037 URL: http://llvm.org/viewvc/llvm-project?rev=75037&view=rev Log: Implement NEON vst1 instruction. Added: llvm/trunk/test/CodeGen/ARM/vst1.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=75037&r1=75036&r2=75037&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Wed Jul 8 15:32:02 2009 @@ -133,6 +133,28 @@ def VLD1qf : VLD1Q<"vld1.32", v4f32, int_arm_neon_vldf>; def VLD1q64 : VLD1Q<"vld1.64", v2i64, int_arm_neon_vldi>; +// VST1 : Vector Store (multiple single elements) +class VST1D + : NLdSt<(outs), (ins addrmode6:$addr, DPR:$src), + !strconcat(OpcodeStr, "\t${src:dregsingle}, $addr"), + [(IntOp addrmode6:$addr, (Ty DPR:$src), 1)]>; +class VST1Q + : NLdSt<(outs), (ins addrmode6:$addr, QPR:$src), + !strconcat(OpcodeStr, "\t${src:dregpair}, $addr"), + [(IntOp addrmode6:$addr, (Ty QPR:$src), 1)]>; + +def VST1d8 : VST1D<"vst1.8", v8i8, int_arm_neon_vsti>; +def VST1d16 : VST1D<"vst1.16", v4i16, int_arm_neon_vsti>; +def VST1d32 : VST1D<"vst1.32", v2i32, int_arm_neon_vsti>; +def VST1df : VST1D<"vst1.32", v2f32, int_arm_neon_vstf>; +def VST1d64 : VST1D<"vst1.64", v1i64, int_arm_neon_vsti>; + +def VST1q8 : VST1Q<"vst1.8", v16i8, int_arm_neon_vsti>; +def VST1q16 : VST1Q<"vst1.16", v8i16, int_arm_neon_vsti>; +def VST1q32 : VST1Q<"vst1.32", v4i32, int_arm_neon_vsti>; +def VST1qf : VST1Q<"vst1.32", v4f32, int_arm_neon_vstf>; +def VST1q64 : VST1Q<"vst1.64", v2i64, int_arm_neon_vsti>; + //===----------------------------------------------------------------------===// // NEON pattern fragments Added: llvm/trunk/test/CodeGen/ARM/vst1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vst1.ll?rev=75037&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vst1.ll (added) +++ llvm/trunk/test/CodeGen/ARM/vst1.ll Wed Jul 8 15:32:02 2009 @@ -0,0 +1,77 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon > %t +; RUN: grep {vst1\\.8} %t | count 2 +; RUN: grep {vst1\\.16} %t | count 2 +; RUN: grep {vst1\\.32} %t | count 4 +; RUN: grep {vst1\\.64} %t | count 2 + +define void @vst1i8(i8* %A, <8 x i8>* %B) nounwind { + %tmp1 = load <8 x i8>* %B + call void @llvm.arm.neon.vsti.v8i8(i8* %A, <8 x i8> %tmp1, i32 1) + ret void +} + +define void @vst1i16(i16* %A, <4 x i16>* %B) nounwind { + %tmp1 = load <4 x i16>* %B + call void @llvm.arm.neon.vsti.v4i16(i16* %A, <4 x i16> %tmp1, i32 1) + ret void +} + +define void @vst1i32(i32* %A, <2 x i32>* %B) nounwind { + %tmp1 = load <2 x i32>* %B + call void @llvm.arm.neon.vsti.v2i32(i32* %A, <2 x i32> %tmp1, i32 1) + ret void +} + +define void @vst1f(float* %A, <2 x float>* %B) nounwind { + %tmp1 = load <2 x float>* %B + call void @llvm.arm.neon.vstf.v2f32(float* %A, <2 x float> %tmp1, i32 1) + ret void +} + +define void @vst1i64(i64* %A, <1 x i64>* %B) nounwind { + %tmp1 = load <1 x i64>* %B + call void @llvm.arm.neon.vsti.v1i64(i64* %A, <1 x i64> %tmp1, i32 1) + ret void +} + +define void @vst1Qi8(i8* %A, <16 x i8>* %B) nounwind { + %tmp1 = load <16 x i8>* %B + call void @llvm.arm.neon.vsti.v16i8(i8* %A, <16 x i8> %tmp1, i32 1) + ret void +} + +define void @vst1Qi16(i16* %A, <8 x i16>* %B) nounwind { + %tmp1 = load <8 x i16>* %B + call void @llvm.arm.neon.vsti.v8i16(i16* %A, <8 x i16> %tmp1, i32 1) + ret void +} + +define void @vst1Qi32(i32* %A, <4 x i32>* %B) nounwind { + %tmp1 = load <4 x i32>* %B + call void @llvm.arm.neon.vsti.v4i32(i32* %A, <4 x i32> %tmp1, i32 1) + ret void +} + +define void @vst1Qf(float* %A, <4 x float>* %B) nounwind { + %tmp1 = load <4 x float>* %B + call void @llvm.arm.neon.vstf.v4f32(float* %A, <4 x float> %tmp1, i32 1) + ret void +} + +define void @vst1Qi64(i64* %A, <2 x i64>* %B) nounwind { + %tmp1 = load <2 x i64>* %B + call void @llvm.arm.neon.vsti.v2i64(i64* %A, <2 x i64> %tmp1, i32 1) + ret void +} + +declare void @llvm.arm.neon.vsti.v8i8(i8*, <8 x i8>, i32) nounwind readnone +declare void @llvm.arm.neon.vsti.v4i16(i16*, <4 x i16>, i32) nounwind readnone +declare void @llvm.arm.neon.vsti.v2i32(i32*, <2 x i32>, i32) nounwind readnone +declare void @llvm.arm.neon.vstf.v2f32(float*, <2 x float>, i32) nounwind readnone +declare void @llvm.arm.neon.vsti.v1i64(i64*, <1 x i64>, i32) nounwind readnone + +declare void @llvm.arm.neon.vsti.v16i8(i8*, <16 x i8>, i32) nounwind readnone +declare void @llvm.arm.neon.vsti.v8i16(i16*, <8 x i16>, i32) nounwind readnone +declare void @llvm.arm.neon.vsti.v4i32(i32*, <4 x i32>, i32) nounwind readnone +declare void @llvm.arm.neon.vstf.v4f32(float*, <4 x float>, i32) nounwind readnone +declare void @llvm.arm.neon.vsti.v2i64(i64*, <2 x i64>, i32) nounwind readnone From sabre at nondot.org Wed Jul 8 15:41:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 20:41:11 -0000 Subject: [llvm-commits] [llvm] r75038 - /llvm/trunk/test/MC/AsmParser/directive_ascii.s Message-ID: <200907082041.n68KfJb5025904@zion.cs.uiuc.edu> Author: lattner Date: Wed Jul 8 15:40:54 2009 New Revision: 75038 URL: http://llvm.org/viewvc/llvm-project?rev=75038&view=rev Log: convert to FileCheck style. Modified: llvm/trunk/test/MC/AsmParser/directive_ascii.s Modified: llvm/trunk/test/MC/AsmParser/directive_ascii.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_ascii.s?rev=75038&r1=75037&r2=75038&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_ascii.s (original) +++ llvm/trunk/test/MC/AsmParser/directive_ascii.s Wed Jul 8 15:40:54 2009 @@ -1,24 +1,23 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 1 TEST0 %t > %t2 -# RUN: not grep ".byte" %t2 +# CHECK: TEST0: TEST0: .ascii -# RUN: grep -A 1 TEST1 %t > %t2 -# RUN: not grep "byte" %t2 +# CHECK: TEST1: TEST1: .asciz -# RUN: grep -A 2 TEST2 %t > %t2 -# RUN: grep ".byte 65" %t2 | count 1 +# CHECK: TEST2: +# CHECK: .byte 65 TEST2: .ascii "A" -# RUN: grep -A 5 TEST3 %t > %t2 -# RUN: grep ".byte 66" %t2 | count 1 -# RUN: grep ".byte 67" %t2 | count 1 -# RUN: grep ".byte 0" %t2 | count 2 +# CHECK: TEST3: +# CHECK: .byte 66 +# CHECK: .byte 0 +# CHECK: .byte 67 +# CHECK: .byte 0 TEST3: .asciz "B", "C" From gohman at apple.com Wed Jul 8 15:43:35 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 8 Jul 2009 13:43:35 -0700 Subject: [llvm-commits] [PATCH] New pass: pointer (bounds) tracking! In-Reply-To: <4A4D0B51.1060302@gmail.com> References: <4A4D0B51.1060302@gmail.com> Message-ID: Hi Edwin, On Jul 2, 2009, at 12:32 PM, T?r?k Edwin wrote: > Hi, > > The attached patch introduces a new pass that can be queried for > allocation size of pointers, > and contains a simple solver [*] for (a ult b) inequalities useful in > bounds checking. This is based on the bounds checker tool I developed > for my undergraduate thesis. This sounds cool. Thanks for your patience; I'm finally getting around to taking a look. > > If this pass is something that would be accepted in LLVM, I will > cleanup > the code to conform to LLVM coding style, add testcases, and resubmit > the patch. I have just attached the patch now as a preview. > > I've seen that there is a lot of work being done to support SSI/ > ABCD. I > think my approach is complementary: I try to determine whether the > existing bounds checks are sufficient for the safety of a memory > access, > and not whether any of the bounds checks are redundant and can be > removed. It may be that the code in your pass could be used for both purposes. It will be interesting to compare different approaches. > > I haven't made up by mind whether all this should be in one pass, > or I > should split it up further: > PointerTracking for size information and bounds checking, and > SCEVSolver > for the SCEV inequality solver? > Or maybe the SCEVSolver parts should be integrated directly into > ScalarEvolution? It looks like most of this code could be integrated into ScalarEvolution, and it would help out a number of important optimizations. However, I think it'd be fine if you wanted to check it in as a separate analysis first and do the integration in separate steps. There are some tricky areas, and this would make it easier to see what's being changed. > > [*] > The solver uses isLoopGuardedByCond(), but is able to handle more > complicated situations by using > properties of SCEV expressions, and transitivity of ULT/ULE: > - if a SCEVAddRecExpr is monotonic it checks whether the start and > exit > value is known to be ULT Limit. This is cool :-). > - for PHI nodes that are SCEVUnknowns it checks whether all parts of > the PHI are known to be ULT > - if a value is a constant offset away from a PHI: C + X X > It also looks for predicates among the basic blocks that dominate the > memory access, trying to > find a predicate that is sufficient for the validity of the memory > access. > > Best regards, > --Edwin > > Here are some comments on the patch. > namespace llvm { > char PointerTracking::ID=0; > > [...] Don't indent namespace contents. > void PointerTracking::getAnalysisUsage(AnalysisUsage &AU) const { > AU.addRequired(); > AU.addRequired(); > AU.addRequired(); These should be addRequiredTransitive instead of addRequired, so that the required analyses are preserved throughout the lifetime of the PointerTracking analysis. > callocFunc = M.getFunction("calloc"); [...] > reallocFunc = M.getFunction("realloc"); I don't know what the current prevailing fasion is with respect to passes knowing special things about functions with standard C library names. It would be good to mention that this pass knows about "calloc" and "realloc" in a high-level comment though. > const SCEV *PointerTracking::getAllocationSize(Value *V) This name is a little confusing. Can you rename this to getAllocationElementCount or something? > { > if (AllocationInst *AI = dyn_cast(V)) { > Value *arraySize = AI->getArraySize(); > if (ConstantInt *C = dyn_cast(arraySize)) { > return SE->getConstant(C); > } > return SE->getSCEVAtScope(arraySize, LI->getLoopFor(AI- >getParent())); It isn't actually necessary to check for a ConstantInt specially here. getSCEVAtScope will effectively do this automatically. > } > if (GlobalVariable *GV = dyn_cast(V)) { > if (GV->hasInitializer()) { > Constant *C = GV->getInitializer(); > if (const ArrayType *ATy = dyn_cast(C->getType ())) { > return SE->getConstant(Type::Int32Ty, ATy->getNumElements ()); Hard-coding Int32Ty here may be problematic in some cases. > } > } > return SE->getConstant(Type::Int32Ty, 1); > } > // TODO: implement more complicated pointer size tracking > return 0; > } > const SCEV *PointerTracking::getAllocationSizeInBytes(Value *V) > { > assert(TD && "TargetData must be available to calculate size in bytes!"); Would it make sense to postpone this check until TD is actually needed, and then return CouldNotCompute if TD is unavailable? > const SCEV *S = getAllocationSize(V); > if (isa(S)) { > if (CallInst *CI = dyn_cast(V)) { > CallSite CS(CI); > Function *F = dyn_cast(CS.getCalledValue()- >stripPointerCasts()); This line exceeds 80 columns. > const Loop *L = LI->getLoopFor(CI->getParent()); > if (F == callocFunc) { > return > SE->getSCEVAtScope(SE->getMulExpr(SE->getSCEV (CS.getArgument(0)), > SE->getSCEV (CS.getArgument(1))), > L); > } else if (F == reallocFunc) { > return SE->getSCEVAtScope(CS.getArgument(1), L); > } > } > return S; > } > uint64_t elementsize = TD->getTypeStoreSize(V->getType()); > return SE->getMulExpr(SE->getConstant(S->getType(), elementsize), S); The size of the allocation will be the number of elements multiplied by the "Alloc" size, not the "Store" size. > const SCEV *getStart(const SCEV *A, const Loop *L) > { Here and elsewhere, the brace for a function definition goes on the same line as the close paren. > if (isa(A)) > return A; This would be a little stronger as A->isLoopInvariant(L). > DomTreeNodeBase *N = DT->getNode(BB); > DomTreeNodeBase *D = N->getIDom(); > while (D) { // D dominates N > BasicBlock *dBB = D->getBlock(); > bool negated; > Value *V = getConditionToReach(dBB, BB, negated); > if (conditionSufficient(V, negated, I, ICmpInst::ICMP_ULT, Limit)) > return AlwaysTrue; > BB = dBB; > D = D->getIDom(); > } This doesn't appear correct. Even if D dominates N and has a conditional branch with a successor that reaches N, it's possible that the other successor of the conditional branch reaches N also. See ScalarEvolution's getPredecessorWithUniqueSuccessorForBB for code that solves a similar problem. Dan From edwintorok at gmail.com Wed Jul 8 15:46:58 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 08 Jul 2009 23:46:58 +0300 Subject: [llvm-commits] [llvm] r75027 - in /llvm/trunk: include/llvm/CodeGen/ include/llvm/Support/ lib/Target/Alpha/ lib/Target/Alpha/AsmPrinter/ lib/Target/IA64/ lib/Target/IA64/AsmPrinter/ lib/Target/MSP430/ lib/Target/Mips/AsmPrinter/ lib/Target/PIC16/ lib/Target/Sparc/AsmPrinter/ lib/Target/X86/ lib/Target/XCore/ utils/TableGen/ In-Reply-To: <1D0FF115-7457-4C11-97B9-14450DD66259@apple.com> References: <200907081905.n68J5D0L022265@zion.cs.uiuc.edu> <1D0FF115-7457-4C11-97B9-14450DD66259@apple.com> Message-ID: <4A5505C2.6050706@gmail.com> On 2009-07-08 23:00, Chris Lattner wrote: > On Jul 8, 2009, at 12:04 PM, Torok Edwin wrote: > >> Log: >> Convert more abort() calls to llvm_report_error(). >> Also remove trailing semicolon. >> > > Ok. > Thanks for reviewing my commit, looks like I got it wrong in many places. At least error handling should be more consistent now, asserts that are meant to be assert are ;) > >> +++ llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h Wed Jul 8 >> 14:04:27 2009 >> @@ -18,6 +18,8 @@ >> #define LLVM_CODEGEN_MACHINECODEEMITTER_H >> >> #include "llvm/Support/DataTypes.h" >> +#include "llvm/Support/ErrorHandling.h" >> +#include "llvm/Support/raw_ostream.h" >> > > Please don't include headers in other headers unless you cannot avoid > it. > > I included it because then I don't need to include it in all the *ISelDAGToDAG.cpp files. I removed it now, and included the necessary headers in each .cpp file. > >> +++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Wed Jul 8 >> 14:04:27 2009 >> @@ -204,14 +204,11 @@ >> case GlobalValue::PrivateLinkage: >> break; >> case GlobalValue::GhostLinkage: >> - cerr << "Should not have any unmaterialized functions!\n"; >> - abort(); >> + llvm_report_error("Should not have any unmaterialized >> functions!"); >> case GlobalValue::DLLImportLinkage: >> - cerr << "DLLImport linkage is not supported by this target!\n"; >> - abort(); >> + llvm_report_error("DLLImport linkage is not supported by this >> target!"); >> case GlobalValue::DLLExportLinkage: >> - cerr << "DLLExport linkage is not supported by this target!\n"; >> - abort(); >> + llvm_report_error("DLLExport linkage is not supported by this >> target!"); >> > > assertions. :) > Thanks, I changed them. Quite a lot of copy+pasting between the targets, isn't it? >> +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Wed Jul 8 >> 14:04:27 2009 >> @@ -270,9 +270,8 @@ >> } >> const Type *Ty = cast(GV->getType())->getElementType(); >> if (!Ty->isSized() || isZeroLengthArray(Ty)) { >> - cerr << "Size of thread local object " << GVar->getName() >> - << " is unknown\n"; >> - abort(); >> + llvm_report_error("Size of thread local object " + GVar- >> >>> getName() >>> >> + + " is unknown"); >> > > This should be an assertion, does the verifier catch this? If not, it > should. > I will check this tomorrow. On 2009-07-08 22:50, Chris Lattner wrote: > On Jul 8, 2009, at 11:01 AM, Torok Edwin wrote: > >> URL: http://llvm.org/viewvc/llvm-project?rev=75018&view=rev >> Log: >> Start converting to new error handling API. >> cerr+abort -> llvm_report_error >> assert(0)+abort -> LLVM_UNREACHABLE (assert(0)+llvm_unreachable-> >> abort() included) >> > > Thanks Edwin, most of this looks great. Several of these below are > assertions that have a message: the preferred style is something like: > > #ifndef NDEBUG > cerr << "WHATEVER\n"; > #endif > unreachable(); > Ok, I changed LLVM_UNREACHABLE to do that. I also used this style when a more complicated message was printed. > >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul 8 >> 13:01:40 2009 >> @@ -33,6 +33,7 @@ >> #include "llvm/CodeGen/PseudoSourceValue.h" >> #include "llvm/Support/MathExtras.h" >> #include "llvm/Support/Debug.h" >> +#include "llvm/Support/ErrorHandling.h" >> #include "llvm/Target/TargetOptions.h" >> #include "llvm/ADT/SmallSet.h" >> #include "llvm/ADT/StringExtras.h" >> @@ -6054,8 +6055,7 @@ >> SDValue SrcPtr = Op.getOperand(1); >> SDValue SrcSV = Op.getOperand(2); >> >> - assert(0 && "VAArgInst is not yet implemented for x86-64!"); >> - abort(); >> + LLVM_UNREACHABLE("VAArgInst is not yet implemented for x86-64!"); >> return SDValue(); >> > > This should be a report_error. > Ok :) > The verifier really should abort when the action is > AbortProcessAction. Clients that want to use the verifier in other > modes can pick a different reaction. > Ok, I restored the abort there, and added a comment explaining why. Best regards, --Edwin From sabre at nondot.org Wed Jul 8 15:51:03 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Jul 2009 20:51:03 -0000 Subject: [llvm-commits] [llvm] r75039 - in /llvm/trunk/test/MC/AsmParser: assignment.s directive_align.s directive_comm.s directive_fill.s directive_org.s directive_set.s directive_space.s directive_symbol_attrs.s directive_values.s Message-ID: <200907082051.n68Kp9UN026249@zion.cs.uiuc.edu> Author: lattner Date: Wed Jul 8 15:50:34 2009 New Revision: 75039 URL: http://llvm.org/viewvc/llvm-project?rev=75039&view=rev Log: Switch all the MC tests to use FileCheck. Modified: llvm/trunk/test/MC/AsmParser/assignment.s llvm/trunk/test/MC/AsmParser/directive_align.s llvm/trunk/test/MC/AsmParser/directive_comm.s llvm/trunk/test/MC/AsmParser/directive_fill.s llvm/trunk/test/MC/AsmParser/directive_org.s llvm/trunk/test/MC/AsmParser/directive_set.s llvm/trunk/test/MC/AsmParser/directive_space.s llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s llvm/trunk/test/MC/AsmParser/directive_values.s Modified: llvm/trunk/test/MC/AsmParser/assignment.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/assignment.s?rev=75039&r1=75038&r2=75039&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/assignment.s (original) +++ llvm/trunk/test/MC/AsmParser/assignment.s Wed Jul 8 15:50:34 2009 @@ -1,7 +1,7 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 2 TEST0 %t > %t2 -# RUN: grep "a = 0" %t2 +# CHECK: TEST0: +# CHECK: a = 0 TEST0: a = 0 \ No newline at end of file Modified: llvm/trunk/test/MC/AsmParser/directive_align.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_align.s?rev=75039&r1=75038&r2=75039&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_align.s (original) +++ llvm/trunk/test/MC/AsmParser/directive_align.s Wed Jul 8 15:50:34 2009 @@ -1,16 +1,16 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 2 TEST0 %t > %t2 -# RUN: grep ".p2align 1, 0" %t2 | count 1 +# CHECK: TEST0: +# CHECK: .p2align 1, 0 TEST0: .align 1 -# RUN: grep -A 2 TEST1 %t > %t2 -# RUN: grep ".p2alignl 3, 0, 2" %t2 | count 1 +# CHECK: TEST1: +# CHECK: .p2alignl 3, 0, 2 TEST1: .align32 3,,2 -# RUN: grep -A 2 TEST2 %t > %t2 -# RUN: grep ".balign 3, 10" %t2 | count 1 +# CHECK: TEST2: +# CHECK: .balign 3, 10 TEST2: .balign 3,10 Modified: llvm/trunk/test/MC/AsmParser/directive_comm.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_comm.s?rev=75039&r1=75038&r2=75039&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_comm.s (original) +++ llvm/trunk/test/MC/AsmParser/directive_comm.s Wed Jul 8 15:50:34 2009 @@ -1,8 +1,8 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 3 TEST0 %t > %t2 -# RUN: grep ".comm a,6,2" %t2 | count 1 -# RUN: grep ".comm b,8" %t2 | count 1 +# CHECK: TEST0: +# CHECK: .comm a,6,2 +# CHECK: .comm b,8 TEST0: .comm a, 4+2, 2 .comm b,8 Modified: llvm/trunk/test/MC/AsmParser/directive_fill.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_fill.s?rev=75039&r1=75038&r2=75039&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_fill.s (original) +++ llvm/trunk/test/MC/AsmParser/directive_fill.s Wed Jul 8 15:50:34 2009 @@ -1,11 +1,12 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 2 TEST0 %t > %t2 -# RUN: grep ".byte 10" %t2 | count 1 +# CHECK: TEST0: +# CHECK: .byte 10 TEST0: .fill 1, 1, 10 -# RUN: grep -A 3 TEST1 %t > %t2 -# RUN: grep ".short 3" %t2 | count 2 +# CHECK: TEST1: +# CHECK: .short 3 +# CHECK: .short 3 TEST1: .fill 2, 2, 3 Modified: llvm/trunk/test/MC/AsmParser/directive_org.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_org.s?rev=75039&r1=75038&r2=75039&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_org.s (original) +++ llvm/trunk/test/MC/AsmParser/directive_org.s Wed Jul 8 15:50:34 2009 @@ -1,11 +1,11 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 2 TEST0 %t > %t2 -# RUN: grep ".org 1, 0" %t2 | count 1 +# CHECK: TEST0: +# CHECK: .org 1, 0 TEST0: .org 1 -# RUN: grep -A 2 TEST1 %t > %t2 -# RUN: grep ".org 1, 3" %t2 | count 1 +# CHECK: TEST1: +# CHECK: .org 1, 3 TEST1: .org 1, 3 Modified: llvm/trunk/test/MC/AsmParser/directive_set.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_set.s?rev=75039&r1=75038&r2=75039&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_set.s (original) +++ llvm/trunk/test/MC/AsmParser/directive_set.s Wed Jul 8 15:50:34 2009 @@ -1,7 +1,7 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 2 TEST0 %t > %t2 -# RUN: grep ".set a, 0" %t2 +# CHECK: TEST0: +# CHECK: .set a, 0 TEST0: .set a, 0 \ No newline at end of file Modified: llvm/trunk/test/MC/AsmParser/directive_space.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_space.s?rev=75039&r1=75038&r2=75039&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_space.s (original) +++ llvm/trunk/test/MC/AsmParser/directive_space.s Wed Jul 8 15:50:34 2009 @@ -1,11 +1,12 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 2 TEST0 %t > %t2 -# RUN: grep ".byte 0" %t2 | count 1 +# CHECK: TEST0: +# CHECK: .byte 0 TEST0: .space 1 -# RUN: grep -A 3 TEST1 %t > %t2 -# RUN: grep ".byte 3" %t2 | count 2 +# CHECK: TEST1: +# CHECK: .byte 3 +# CHECK: .byte 3 TEST1: .space 2, 3 Modified: llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s?rev=75039&r1=75038&r2=75039&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s (original) +++ llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s Wed Jul 8 15:50:34 2009 @@ -1,7 +1,7 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 3 TEST0 %t > %t2 -# RUN: grep ".globl a" %t2 | count 1 -# RUN: grep ".globl b" %t2 | count 1 +# CHECK: TEST0: +# CHECK: .globl a +# CHECK: .globl b TEST0: .globl a, b Modified: llvm/trunk/test/MC/AsmParser/directive_values.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_values.s?rev=75039&r1=75038&r2=75039&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/directive_values.s (original) +++ llvm/trunk/test/MC/AsmParser/directive_values.s Wed Jul 8 15:50:34 2009 @@ -1,21 +1,21 @@ -# RUN: llvm-mc %s > %t +# RUN: llvm-mc %s | FileCheck %s -# RUN: grep -A 2 TEST0 %t > %t2 -# RUN: grep ".byte 0" %t2 | count 1 +# CHECK: TEST0: +# CHECK: .byte 0 TEST0: .byte 0 -# RUN: grep -A 2 TEST1 %t > %t2 -# RUN: grep ".short 3" %t2 | count 1 +# CHECK: TEST1: +# CHECK: .short 3 TEST1: .short 3 -# RUN: grep -A 2 TEST2 %t > %t2 -# RUN: grep ".long 8" %t2 | count 1 +# CHECK: TEST2: +# CHECK: .long 8 TEST2: .long 8 -# RUN: grep -A 2 TEST3 %t > %t2 -# RUN: grep ".quad 9" %t2 | count 1 +# CHECK: TEST3: +# CHECK: .quad 9 TEST3: .quad 9 From resistor at mac.com Wed Jul 8 15:51:03 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 08 Jul 2009 20:51:03 -0000 Subject: [llvm-commits] [llvm] r75040 - in /llvm/trunk: docs/tutorial/LangImpl3.html docs/tutorial/LangImpl4.html docs/tutorial/LangImpl5.html docs/tutorial/LangImpl6.html docs/tutorial/LangImpl7.html examples/Kaleidoscope/toy.cpp include/llvm/Analysis/ScalarEvolutionExpander.h include/llvm/Support/IRBuilder.h lib/CodeGen/IntrinsicLowering.cpp lib/CodeGen/ShadowStackGC.cpp lib/Transforms/Scalar/SimplifyLibCalls.cpp lib/VMCore/Core.cpp Message-ID: <200907082051.n68Kp901026256@zion.cs.uiuc.edu> Author: resistor Date: Wed Jul 8 15:50:47 2009 New Revision: 75040 URL: http://llvm.org/viewvc/llvm-project?rev=75040&view=rev Log: Push LLVMContext _back_ through IRBuilder. Modified: llvm/trunk/docs/tutorial/LangImpl3.html llvm/trunk/docs/tutorial/LangImpl4.html llvm/trunk/docs/tutorial/LangImpl5.html llvm/trunk/docs/tutorial/LangImpl6.html llvm/trunk/docs/tutorial/LangImpl7.html llvm/trunk/examples/Kaleidoscope/toy.cpp llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp llvm/trunk/lib/CodeGen/ShadowStackGC.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/docs/tutorial/LangImpl3.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl3.html?rev=75040&r1=75039&r2=75040&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl3.html (original) +++ llvm/trunk/docs/tutorial/LangImpl3.html Wed Jul 8 15:50:47 2009 @@ -115,7 +115,7 @@ Value *ErrorV(const char *Str) { Error(Str); return 0; } static Module *TheModule; -static IRBuilder<> Builder; +static IRBuilder<> Builder(getGlobalContext()); static std::map<std::string, Value*> NamedValues; @@ -682,6 +682,7 @@ // See example below. #include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Support/IRBuilder.h" @@ -1216,7 +1217,7 @@ //===----------------------------------------------------------------------===// int main() { - TheModule = new Module("my cool jit"); + TheModule = new Module("my cool jit", getGlobalContext()); // Install standard binary operators. // 1 is lowest precedence. Modified: llvm/trunk/docs/tutorial/LangImpl4.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl4.html?rev=75040&r1=75039&r2=75040&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl4.html (original) +++ llvm/trunk/docs/tutorial/LangImpl4.html Wed Jul 8 15:50:47 2009 @@ -512,6 +512,7 @@
     #include "llvm/DerivedTypes.h"
     #include "llvm/ExecutionEngine/ExecutionEngine.h"
    +#include "llvm/LLVMContext.h"
     #include "llvm/Module.h"
     #include "llvm/ModuleProvider.h"
     #include "llvm/PassManager.h"
    @@ -861,7 +862,7 @@
     //===----------------------------------------------------------------------===//
     
     static Module *TheModule;
    -static IRBuilder<> Builder;
    +static IRBuilder<> Builder(getGlobalContext());
     static std::map<std::string, Value*> NamedValues;
     static FunctionPassManager *TheFPM;
     
    @@ -1074,7 +1075,7 @@
       getNextToken();
     
       // Make the module, which holds all the code.
    -  TheModule = new Module("my cool jit");
    +  TheModule = new Module("my cool jit", getGlobalContext());
       
       // Create the JIT.
       TheExecutionEngine = ExecutionEngine::create(TheModule);
    
    Modified: llvm/trunk/docs/tutorial/LangImpl5.html
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl5.html?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/docs/tutorial/LangImpl5.html (original)
    +++ llvm/trunk/docs/tutorial/LangImpl5.html Wed Jul  8 15:50:47 2009
    @@ -901,6 +901,7 @@
     
     #include "llvm/DerivedTypes.h"
     #include "llvm/ExecutionEngine/ExecutionEngine.h"
    +#include "llvm/LLVMContext.h"
     #include "llvm/Module.h"
     #include "llvm/ModuleProvider.h"
     #include "llvm/PassManager.h"
    @@ -1352,7 +1353,7 @@
     //===----------------------------------------------------------------------===//
     
     static Module *TheModule;
    -static IRBuilder<> Builder;
    +static IRBuilder<> Builder(getGlobalContext());
     static std::map<std::string, Value*> NamedValues;
     static FunctionPassManager *TheFPM;
     
    @@ -1708,7 +1709,7 @@
       getNextToken();
     
       // Make the module, which holds all the code.
    -  TheModule = new Module("my cool jit");
    +  TheModule = new Module("my cool jit", getGlobalContext());
       
       // Create the JIT.
       TheExecutionEngine = ExecutionEngine::create(TheModule);
    
    Modified: llvm/trunk/docs/tutorial/LangImpl6.html
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl6.html?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/docs/tutorial/LangImpl6.html (original)
    +++ llvm/trunk/docs/tutorial/LangImpl6.html Wed Jul  8 15:50:47 2009
    @@ -821,6 +821,7 @@
     
     #include "llvm/DerivedTypes.h"
     #include "llvm/ExecutionEngine/ExecutionEngine.h"
    +#include "llvm/LLVMContext.h"
     #include "llvm/Module.h"
     #include "llvm/ModuleProvider.h"
     #include "llvm/PassManager.h"
    @@ -1357,7 +1358,7 @@
     //===----------------------------------------------------------------------===//
     
     static Module *TheModule;
    -static IRBuilder<> Builder;
    +static IRBuilder<> Builder(getGlobalContext());
     static std::map<std::string, Value*> NamedValues;
     static FunctionPassManager *TheFPM;
     
    @@ -1747,7 +1748,7 @@
       getNextToken();
     
       // Make the module, which holds all the code.
    -  TheModule = new Module("my cool jit");
    +  TheModule = new Module("my cool jit", getGlobalContext());
       
       // Create the JIT.
       TheExecutionEngine = ExecutionEngine::create(TheModule);
    
    Modified: llvm/trunk/docs/tutorial/LangImpl7.html
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl7.html?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/docs/tutorial/LangImpl7.html (original)
    +++ llvm/trunk/docs/tutorial/LangImpl7.html Wed Jul  8 15:50:47 2009
    @@ -1003,6 +1003,7 @@
     
     #include "llvm/DerivedTypes.h"
     #include "llvm/ExecutionEngine/ExecutionEngine.h"
    +#include "llvm/LLVMContext.h"
     #include "llvm/Module.h"
     #include "llvm/ModuleProvider.h"
     #include "llvm/PassManager.h"
    @@ -1605,7 +1606,7 @@
     //===----------------------------------------------------------------------===//
     
     static Module *TheModule;
    -static IRBuilder<> Builder;
    +static IRBuilder<> Builder(getGlobalContext());
     static std::map<std::string, AllocaInst*> NamedValues;
     static FunctionPassManager *TheFPM;
     
    @@ -2099,7 +2100,7 @@
       getNextToken();
     
       // Make the module, which holds all the code.
    -  TheModule = new Module("my cool jit");
    +  TheModule = new Module("my cool jit", getGlobalContext());
       
       // Create the JIT.
       TheExecutionEngine = ExecutionEngine::create(TheModule);
    
    Modified: llvm/trunk/examples/Kaleidoscope/toy.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/toy.cpp?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/examples/Kaleidoscope/toy.cpp (original)
    +++ llvm/trunk/examples/Kaleidoscope/toy.cpp Wed Jul  8 15:50:47 2009
    @@ -604,7 +604,7 @@
     //===----------------------------------------------------------------------===//
     
     static Module *TheModule;
    -static IRBuilder<> Builder;
    +static IRBuilder<> Builder(getGlobalContext());
     static std::map NamedValues;
     static FunctionPassManager *TheFPM;
     
    
    Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original)
    +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Wed Jul  8 15:50:47 2009
    @@ -37,7 +37,8 @@
         friend struct SCEVVisitor;
       public:
         explicit SCEVExpander(ScalarEvolution &se)
    -      : SE(se), Builder(TargetFolder(se.TD, se.getContext())) {}
    +      : SE(se), Builder(*se.getContext(),
    +                        TargetFolder(se.TD, se.getContext())) {}
     
         /// clear - Erase the contents of the InsertedExpressions map so that users
         /// trying to expand the same expression into multiple BasicBlocks or
    
    Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
    +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jul  8 15:50:47 2009
    @@ -20,6 +20,7 @@
     #include "llvm/GlobalAlias.h"
     #include "llvm/GlobalVariable.h"
     #include "llvm/Function.h"
    +#include "llvm/LLVMContext.h"
     #include "llvm/Support/ConstantFolder.h"
     
     namespace llvm {
    @@ -42,12 +43,20 @@
       BasicBlock *BB;
       BasicBlock::iterator InsertPt;
       T Folder;
    +  LLVMContext &Context;
     public:
    -  IRBuilder(const T& F = T()) : Folder(F) { ClearInsertionPoint(); }
    +  IRBuilder(LLVMContext &C, const T& F = T()) :
    +    Folder(F), Context(C) { ClearInsertionPoint(); }
    +  
       explicit IRBuilder(BasicBlock *TheBB, const T& F = T())
    -    : Folder(F) { SetInsertPoint(TheBB); }
    +      : Folder(F), Context(*TheBB->getParent()->getContext()) {
    +    SetInsertPoint(TheBB);
    +  }
    +  
       IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F = T())
    -    : Folder(F) { SetInsertPoint(TheBB, IP); }
    +      : Folder(F), Context(*TheBB->getParent()->getContext()) {
    +    SetInsertPoint(TheBB, IP);
    +  }
     
       /// getFolder - Get the constant folder being used.
       const T& getFolder() { return Folder; }
    @@ -125,7 +134,7 @@
       ///
       ReturnInst *CreateAggregateRet(Value * const* retVals, unsigned N) {
         const Type *RetType = BB->getParent()->getReturnType();
    -    Value *V = UndefValue::get(RetType);
    +    Value *V = Context.getUndef(RetType);
         for (unsigned i = 0; i != N; ++i)
           V = CreateInsertValue(V, retVals[i], i, "mrv");
         return Insert(ReturnInst::Create(V));
    @@ -349,7 +358,7 @@
         return Insert(GetElementPtrInst::Create(Ptr, Idx), Name);
       }
       Value *CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const char *Name = "") {
    -    Value *Idx = ConstantInt::get(Type::Int32Ty, Idx0);
    +    Value *Idx = Context.getConstantInt(Type::Int32Ty, Idx0);
     
         if (Constant *PC = dyn_cast(Ptr))
           return Folder.CreateGetElementPtr(PC, &Idx, 1);
    @@ -359,8 +368,8 @@
       Value *CreateConstGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1, 
                         const char *Name = "") {
         Value *Idxs[] = {
    -      ConstantInt::get(Type::Int32Ty, Idx0),
    -      ConstantInt::get(Type::Int32Ty, Idx1)
    +      Context.getConstantInt(Type::Int32Ty, Idx0),
    +      Context.getConstantInt(Type::Int32Ty, Idx1)
         };
     
         if (Constant *PC = dyn_cast(Ptr))
    @@ -369,7 +378,7 @@
         return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name);    
       }
       Value *CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const char *Name = "") {
    -    Value *Idx = ConstantInt::get(Type::Int64Ty, Idx0);
    +    Value *Idx = Context.getConstantInt(Type::Int64Ty, Idx0);
     
         if (Constant *PC = dyn_cast(Ptr))
           return Folder.CreateGetElementPtr(PC, &Idx, 1);
    @@ -379,8 +388,8 @@
       Value *CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, 
                         const char *Name = "") {
         Value *Idxs[] = {
    -      ConstantInt::get(Type::Int64Ty, Idx0),
    -      ConstantInt::get(Type::Int64Ty, Idx1)
    +      Context.getConstantInt(Type::Int64Ty, Idx0),
    +      Context.getConstantInt(Type::Int64Ty, Idx1)
         };
     
         if (Constant *PC = dyn_cast(Ptr))
    @@ -392,7 +401,7 @@
         return CreateConstGEP2_32(Ptr, 0, Idx, Name);
       }
       Value *CreateGlobalString(const char *Str = "", const char *Name = "") {
    -    Constant *StrConstant = ConstantArray::get(Str, true);
    +    Constant *StrConstant = Context.getConstantArray(Str, true);
         GlobalVariable *gv = new GlobalVariable(*BB->getParent()->getParent(),
                                                 StrConstant->getType(),
                                                 true,
    @@ -406,7 +415,7 @@
       }
       Value *CreateGlobalStringPtr(const char *Str = "", const char *Name = "") {
         Value *gv = CreateGlobalString(Str, Name);
    -    Value *zero = ConstantInt::get(Type::Int32Ty, 0);
    +    Value *zero = Context.getConstantInt(Type::Int32Ty, 0);
         Value *Args[] = { zero, zero };
         return CreateGEP(gv, Args, Args+2, Name);
       }
    @@ -683,13 +692,13 @@
     
       /// CreateIsNull - Return an i1 value testing if \arg Arg is null.
       Value *CreateIsNull(Value *Arg, const char *Name = "") {
    -    return CreateICmpEQ(Arg, Constant::getNullValue(Arg->getType()),
    +    return CreateICmpEQ(Arg, Context.getNullValue(Arg->getType()),
                             Name);
       }
     
       /// CreateIsNotNull - Return an i1 value testing if \arg Arg is not null.
       Value *CreateIsNotNull(Value *Arg, const char *Name = "") {
    -    return CreateICmpNE(Arg, Constant::getNullValue(Arg->getType()),
    +    return CreateICmpNE(Arg, Context.getNullValue(Arg->getType()),
                             Name);
       }
     
    @@ -704,7 +713,7 @@
         Value *RHS_int = CreatePtrToInt(RHS, Type::Int64Ty);
         Value *Difference = CreateSub(LHS_int, RHS_int);
         return CreateSDiv(Difference,
    -                      ConstantExpr::getSizeOf(ArgType->getElementType()),
    +                      Context.getConstantExprSizeOf(ArgType->getElementType()),
                           Name);
       }
     };
    
    Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original)
    +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Wed Jul  8 15:50:47 2009
    @@ -301,7 +301,7 @@
     /// the bits are returned in inverse order. 
     /// @brief Lowering of llvm.part.select intrinsic.
     static Instruction *LowerPartSelect(CallInst *CI) {
    -  IRBuilder<> Builder;
    +  IRBuilder<> Builder(*CI->getParent()->getContext());
     
       // Make sure we're dealing with a part select intrinsic here
       Function *F = CI->getCalledFunction();
    @@ -472,7 +472,7 @@
     /// greater than %High then the inverse set of bits are replaced.
     /// @brief Lowering of llvm.bit.part.set intrinsic.
     static Instruction *LowerPartSet(CallInst *CI) {
    -  IRBuilder<> Builder;
    +  IRBuilder<> Builder(*CI->getParent()->getContext());
     
       // Make sure we're dealing with a part select intrinsic here
       Function *F = CI->getCalledFunction();
    
    Modified: llvm/trunk/lib/CodeGen/ShadowStackGC.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShadowStackGC.cpp?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/CodeGen/ShadowStackGC.cpp (original)
    +++ llvm/trunk/lib/CodeGen/ShadowStackGC.cpp Wed Jul  8 15:50:47 2009
    @@ -93,7 +93,7 @@
     
       public:
         EscapeEnumerator(Function &F, const char *N = "cleanup")
    -      : F(F), CleanupBBName(N), State(0) {}
    +      : F(F), CleanupBBName(N), State(0), Builder(*F.getContext()) {}
     
         IRBuilder<> *Next() {
           switch (State) {
    
    Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original)
    +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Wed Jul  8 15:50:47 2009
    @@ -1639,7 +1639,7 @@
       
       const TargetData &TD = getAnalysis();
       
    -  IRBuilder<> Builder;
    +  IRBuilder<> Builder(*Context);
     
       bool Changed = false;
       for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
    
    Modified: llvm/trunk/lib/VMCore/Core.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=75040&r1=75039&r2=75040&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/VMCore/Core.cpp (original)
    +++ llvm/trunk/lib/VMCore/Core.cpp Wed Jul  8 15:50:47 2009
    @@ -1132,7 +1132,7 @@
     /*===-- Instruction builders ----------------------------------------------===*/
     
     LLVMBuilderRef LLVMCreateBuilder(void) {
    -  return wrap(new IRBuilder<>());
    +  return wrap(new IRBuilder<>(getGlobalContext()));
     }
     
     void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
    
    
    
    
    From clattner at apple.com  Wed Jul  8 15:52:22 2009
    From: clattner at apple.com (Chris Lattner)
    Date: Wed, 8 Jul 2009 13:52:22 -0700
    Subject: [llvm-commits] [llvm] r75027 - in /llvm/trunk:
    	include/llvm/CodeGen/ include/llvm/Support/ lib/Target/Alpha/
    	lib/Target/Alpha/AsmPrinter/ lib/Target/IA64/
    	lib/Target/IA64/AsmPrinter/ lib/Target/MSP430/
    	lib/Target/Mips/AsmPrinter/ lib/Target/PIC16/
    	lib/Target/Sparc/AsmPrinter/ lib/Target/X86/
    	lib/Target/XCore/ utils/TableGen/
    In-Reply-To: <4A5505C2.6050706@gmail.com>
    References: <200907081905.n68J5D0L022265@zion.cs.uiuc.edu>
    	<1D0FF115-7457-4C11-97B9-14450DD66259@apple.com>
    	<4A5505C2.6050706@gmail.com>
    Message-ID: 
    
    On Jul 8, 2009, at 1:46 PM, T?r?k Edwin wrote:
    > Thanks for reviewing my commit, looks like I got it wrong in many  
    > places.
    > At least error handling should be more consistent now, asserts that  
    > are
    > meant to be assert are ;)
    
    Well I only listed the ones I disagreed with, you got many more right :)
    
    >
    >>
    >>> +++ llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h Wed Jul  8
    >>> 14:04:27 2009
    >>> @@ -18,6 +18,8 @@
    >>> #define LLVM_CODEGEN_MACHINECODEEMITTER_H
    >>>
    >>> #include "llvm/Support/DataTypes.h"
    >>> +#include "llvm/Support/ErrorHandling.h"
    >>> +#include "llvm/Support/raw_ostream.h"
    >>>
    >>
    >> Please don't include headers in other headers unless you cannot avoid
    >> it.
    >>
    >>
    >
    > I included it because then I don't need to include it in all the
    > *ISelDAGToDAG.cpp files.
    > I removed it now, and included the necessary headers in each .cpp  
    > file.
    
    Why do they need raw_ostream?
    
    >>>    case GlobalValue::DLLExportLinkage:
    >>> -      cerr << "DLLExport linkage is not supported by this target! 
    >>> \n";
    >>> -      abort();
    >>> +      llvm_report_error("DLLExport linkage is not supported by this
    >>> target!");
    >>>
    >>
    >> assertions. :)
    >>
    >
    > Thanks, I changed them. Quite a lot of copy+pasting between the  
    > targets,
    > isn't it?
    
    Yes, the asmprinters are copy and paste hell, I'm trying to help a bit  
    with the mc stuff.
    >>
    >> Thanks Edwin, most of this looks great.  Several of these below are
    >> assertions that have a message: the preferred style is something  
    >> like:
    >>
    >> #ifndef NDEBUG
    >>   cerr << "WHATEVER\n";
    >> #endif
    >>   unreachable();
    >>
    >
    > Ok, I changed LLVM_UNREACHABLE to do that.
    > I also used this style when a more complicated message was printed.
    
    Sounds good.
    
    Thanks Edwin,
    
    -Chris
    
    
    
    
    From resistor at mac.com  Wed Jul  8 15:53:00 2009
    From: resistor at mac.com (Owen Anderson)
    Date: Wed, 08 Jul 2009 20:53:00 -0000
    Subject: [llvm-commits] [llvm-gcc-4.2] r75042 -
    	/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    Message-ID: <200907082053.n68Kr1fw026382@zion.cs.uiuc.edu>
    
    Author: resistor
    Date: Wed Jul  8 15:52:52 2009
    New Revision: 75042
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75042&view=rev
    Log:
    Update for IRBuilder API change.
    
    Modified:
        llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    
    Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=75042&r1=75041&r2=75042&view=diff
    
    ==============================================================================
    --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
    +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Jul  8 15:52:52 2009
    @@ -151,7 +151,8 @@
       return *TheTarget->getTargetData();
     }
     
    -TreeToLLVM::TreeToLLVM(tree fndecl) : TD(getTargetData()), Builder(*TheFolder) {
    +TreeToLLVM::TreeToLLVM(tree fndecl) :
    +    TD(getTargetData()), Builder(getGlobalContext(), *TheFolder) {
       FnDecl = fndecl;
       Fn = 0;
       ReturnBB = UnwindBB = 0;
    
    
    
    
    From edwintorok at gmail.com  Wed Jul  8 15:53:30 2009
    From: edwintorok at gmail.com (Torok Edwin)
    Date: Wed, 08 Jul 2009 20:53:30 -0000
    Subject: [llvm-commits] [llvm] r75043 - in /llvm/trunk:
     include/llvm/CodeGen/ include/llvm/Support/ lib/Target/ARM/
     lib/Target/Alpha/ lib/Target/Alpha/AsmPrinter/ lib/Target/CBackend/
     lib/Target/CellSPU/ lib/Target/CellSPU/AsmPrinter/ lib/Target/IA64/
     lib/Target/IA64/AsmPrinter/ lib/Target/MSP430/ lib/Target/Mips/
     lib/Target/Mips/AsmPrinter/ lib/Target/PIC16/ lib/Target/PowerPC/
     lib/Target/PowerPC/AsmPrinter/ lib/Target/Sparc/
     lib/Target/Sparc/AsmPrinter/ lib/Target/X86/ lib/Target/X86/AsmPrinter/
     lib/Target/XCore/ lib/VMCore/
    Message-ID: <200907082053.n68KrfAs026473@zion.cs.uiuc.edu>
    
    Author: edwin
    Date: Wed Jul  8 15:53:28 2009
    New Revision: 75043
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75043&view=rev
    Log:
    Implement changes from Chris's feedback.
    Finish converting lib/Target.
    
    Modified:
        llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h
        llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
        llvm/trunk/include/llvm/Support/ErrorHandling.h
        llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp
        llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp
        llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
        llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp
        llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
        llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp
        llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp
        llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp
        llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
        llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp
        llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp
        llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp
        llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
        llvm/trunk/lib/Target/CBackend/CBackend.cpp
        llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
        llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp
        llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp
        llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp
        llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp
        llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
        llvm/trunk/lib/Target/IA64/IA64ISelDAGToDAG.cpp
        llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp
        llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
        llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp
        llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
        llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp
        llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp
        llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
        llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp
        llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
        llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
        llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp
        llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp
        llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp
        llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
        llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp
        llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
        llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
        llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
        llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
        llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
        llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp
        llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp
        llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp
        llvm/trunk/lib/VMCore/AsmWriter.cpp
        llvm/trunk/lib/VMCore/Globals.cpp
        llvm/trunk/lib/VMCore/Instructions.cpp
        llvm/trunk/lib/VMCore/Type.cpp
        llvm/trunk/lib/VMCore/Value.cpp
        llvm/trunk/lib/VMCore/Verifier.cpp
    
    Modified: llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h (original)
    +++ llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h Wed Jul  8 15:53:28 2009
    @@ -18,8 +18,6 @@
     #define LLVM_CODEGEN_MACHINECODEEMITTER_H
     
     #include "llvm/Support/DataTypes.h"
    -#include "llvm/Support/ErrorHandling.h"
    -#include "llvm/Support/raw_ostream.h"
     
     namespace llvm {
     
    
    Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original)
    +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Wed Jul  8 15:53:28 2009
    @@ -19,8 +19,6 @@
     #include "llvm/Pass.h"
     #include "llvm/Constant.h"
     #include "llvm/CodeGen/SelectionDAG.h"
    -#include "llvm/Support/ErrorHandling.h"
    -#include "llvm/Support/raw_ostream.h"
     
     namespace llvm {
       class FastISel;
    
    Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/Support/ErrorHandling.h (original)
    +++ llvm/trunk/include/llvm/Support/ErrorHandling.h Wed Jul  8 15:53:28 2009
    @@ -49,7 +49,11 @@
       void llvm_unreachable(void) NORETURN;
     }
     
    -#define LLVM_UNREACHABLE(msg) do { assert(0 && msg); llvm_unreachable(); } while(0)
    +#ifndef NDEBUG
    +#define LLVM_UNREACHABLE(msg) do {cerr<::emitBranchInstruction(const MachineInstr &MI) {
       const TargetInstrDesc &TID = MI.getDesc();
     
    -  if (TID.Opcode == ARM::TPsoft)
    -    llvm_report_error("ARM::TPsoft FIXME"); // FIXME
    +  if (TID.Opcode == ARM::TPsoft) {
    +    LLVM_UNREACHABLE("ARM::TPsoft FIXME"); // FIXME
    +  }
     
       // Part of binary is determined by TableGn.
       unsigned Binary = getBinaryCodeForInstr(MI);
    
    Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -30,6 +30,9 @@
     #include "llvm/Target/TargetOptions.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
    +
     using namespace llvm;
     
     static const unsigned arm_dsubreg_0 = 5;
    
    Modified: llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -123,12 +123,12 @@
       //   ldr pc, [pc,#-4]
       //   
       if (!sys::Memory::setRangeWritable((void*)StubAddr, 8)) {
    -    llvm_report_error("ERROR: Unable to mark stub writable");
    +    LLVM_UNREACHABLE("ERROR: Unable to mark stub writable");
       }
       *(intptr_t *)StubAddr = 0xe51ff004;  // ldr pc, [pc, #-4]
       *(intptr_t *)(StubAddr+4) = NewVal;
       if (!sys::Memory::setRangeExecutable((void*)StubAddr, 8)) {
    -    llvm_report_error("ERROR: Unable to mark stub executable");
    +    LLVM_UNREACHABLE("ERROR: Unable to mark stub executable");
       }
     }
     
    
    Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Wed Jul  8 15:53:28 2009
    @@ -120,7 +120,7 @@
       case ARM::FSTD:
         NumFSTMGened++;
         return ARM::FSTMD;
    -  default: llvm_report_error("Unhandled opcode!");
    +  default: LLVM_UNREACHABLE("Unhandled opcode!");
       }
       return 0;
     }
    @@ -442,7 +442,7 @@
       case ARM::FLDD: return ARM::FLDMD;
       case ARM::FSTS: return ARM::FSTMS;
       case ARM::FSTD: return ARM::FSTMD;
    -  default: llvm_report_error("Unhandled opcode!");
    +  default: LLVM_UNREACHABLE("Unhandled opcode!");
       }
       return 0;
     }
    @@ -455,7 +455,7 @@
       case ARM::FLDD: return ARM::FLDMD;
       case ARM::FSTS: return ARM::FSTMS;
       case ARM::FSTD: return ARM::FSTMD;
    -  default: llvm_report_error("Unhandled opcode!");
    +  default: LLVM_UNREACHABLE("Unhandled opcode!");
       }
       return 0;
     }
    
    Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -32,6 +32,7 @@
     #include "llvm/ADT/SmallVector.h"
     #include "llvm/Support/CommandLine.h"
     #include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     using namespace llvm;
     
     static cl::opt
    
    Modified: llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -455,8 +455,7 @@
           break;
         }
         default:
    -      llvm_report_error("Unsupported addressing mode!");
    -      break;
    +      LLVM_UNREACHABLE("Unsupported addressing mode!");
         }
     
         Offset += InstrOffs * Scale;
    
    Modified: llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp (original)
    +++ llvm/trunk/lib/Target/Alpha/AlphaCodeEmitter.cpp Wed Jul  8 15:53:28 2009
    @@ -235,10 +235,10 @@
         MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(),
                                                    Alpha::reloc_bsr, MO.getMBB()));
       } else {
    -    std::string msg;
    -    raw_string_ostream Msg(msg);
    -    Msg << "ERROR: Unknown type of MachineOperand: " << MO;
    -    llvm_report_error(Msg.str());
    +#ifndef NDEBUG
    +    cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n";
    +#endif
    +    llvm_unreachable();
       }
     
       return rv;
    
    Modified: llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -28,7 +28,9 @@
     #include "llvm/Intrinsics.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/MathExtras.h"
    +#include "llvm/Support/raw_ostream.h"
     #include 
     using namespace llvm;
     
    
    Modified: llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp (original)
    +++ llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp Wed Jul  8 15:53:28 2009
    @@ -25,6 +25,7 @@
     #include "llvm/Intrinsics.h"
     #include "llvm/Support/CommandLine.h"
     #include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     using namespace llvm;
     
     /// AddLiveIn - This helper function adds the specified physical register to the
    
    Modified: llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp (original)
    +++ llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -201,7 +201,7 @@
           .addReg(SrcReg, getKillRegState(isKill))
           .addFrameIndex(FrameIdx).addReg(Alpha::F31);
       else
    -    llvm_report_error("Unhandled register class");
    +    LLVM_UNREACHABLE("Unhandled register class");
     }
     
     void AlphaInstrInfo::storeRegToAddr(MachineFunction &MF, unsigned SrcReg,
    @@ -217,7 +217,7 @@
       else if (RC == Alpha::GPRCRegisterClass)
         Opc = Alpha::STQ;
       else
    -    llvm_report_error("Unhandled register class");
    +    LLVM_UNREACHABLE("Unhandled register class");
       DebugLoc DL = DebugLoc::getUnknownLoc();
       MachineInstrBuilder MIB = 
         BuildMI(MF, DL, get(Opc)).addReg(SrcReg, getKillRegState(isKill));
    @@ -246,7 +246,7 @@
         BuildMI(MBB, MI, DL, get(Alpha::LDQ), DestReg)
           .addFrameIndex(FrameIdx).addReg(Alpha::F31);
       else
    -    llvm_report_error("Unhandled register class");
    +    LLVM_UNREACHABLE("Unhandled register class");
     }
     
     void AlphaInstrInfo::loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
    @@ -261,7 +261,7 @@
       else if (RC == Alpha::GPRCRegisterClass)
         Opc = Alpha::LDQ;
       else
    -    llvm_report_error("Unhandled register class");
    +    LLVM_UNREACHABLE("Unhandled register class");
       DebugLoc DL = DebugLoc::getUnknownLoc();
       MachineInstrBuilder MIB = 
         BuildMI(MF, DL, get(Opc), DestReg);
    
    Modified: llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp (original)
    +++ llvm/trunk/lib/Target/Alpha/AlphaJITInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -18,6 +18,7 @@
     #include "llvm/CodeGen/JITCodeEmitter.h"
     #include "llvm/Config/alloca.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include 
     using namespace llvm;
     
    
    Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Wed Jul  8 15:53:28 2009
    @@ -101,7 +101,7 @@
         return;
     
       case MachineOperand::MO_Immediate:
    -    llvm_report_error("printOp() does not handle immediate values");
    +    LLVM_UNREACHABLE("printOp() does not handle immediate values");
         return;
     
       case MachineOperand::MO_MachineBasicBlock:
    
    Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
    +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Wed Jul  8 15:53:28 2009
    @@ -35,6 +35,7 @@
     #include "llvm/Target/TargetData.h"
     #include "llvm/Support/CallSite.h"
     #include "llvm/Support/CFG.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/GetElementPtrTypeIterator.h"
     #include "llvm/Support/InstVisitor.h"
     #include "llvm/Support/Mangler.h"
    @@ -321,8 +322,10 @@
         void visitExtractValueInst(ExtractValueInst &I);
     
         void visitInstruction(Instruction &I) {
    +#ifndef NDEBUG
           cerr << "C Writer does not know about " << I;
    -      abort();
    +#endif
    +      llvm_unreachable();
         }
     
         void outputLValue(Instruction *I) {
    @@ -505,8 +508,10 @@
       }
         
       default:
    +#ifndef NDEBUG
         cerr << "Unknown primitive type: " << *Ty << "\n";
    -    abort();
    +#endif
    +    llvm_unreachable();
       }
     }
     
    @@ -550,8 +555,10 @@
       }
         
       default:
    +#ifndef NDEBUG
         cerr << "Unknown primitive type: " << *Ty << "\n";
    -    abort();
    +#endif
    +    llvm_unreachable();
       }
     }
     
    @@ -652,8 +659,7 @@
         return Out << TyName << ' ' << NameSoFar;
       }
       default:
    -    assert(0 && "Unhandled case in getTypeProps!");
    -    abort();
    +    LLVM_UNREACHABLE("Unhandled case in getTypeProps!");
       }
     
       return Out;
    @@ -756,8 +762,7 @@
         return Out << TyName << ' ' << NameSoFar;
       }
       default:
    -    assert(0 && "Unhandled case in getTypeProps!");
    -    abort();
    +    LLVM_UNREACHABLE("Unhandled case in getTypeProps!");
       }
     
       return Out;
    @@ -1104,9 +1109,11 @@
           return;
         }
         default:
    +#ifndef NDEBUG
           cerr << "CWriter Error: Unhandled constant expression: "
                << *CE << "\n";
    -      abort();
    +#endif
    +      llvm_unreachable();
         }
       } else if (isa(CPV) && CPV->getType()->isSingleValueType()) {
         Out << "((";
    @@ -1312,8 +1319,10 @@
         }
         // FALL THROUGH
       default:
    +#ifndef NDEBUG
         cerr << "Unknown constant type: " << *CPV << "\n";
    -    abort();
    +#endif
    +    llvm_unreachable();
       }
     }
     
    @@ -1456,10 +1465,9 @@
       const Type *Ty = I.getType();
       if (Ty->isInteger() && (Ty!=Type::Int1Ty && Ty!=Type::Int8Ty &&
             Ty!=Type::Int16Ty && Ty!=Type::Int32Ty && Ty!=Type::Int64Ty)) {
    -      cerr << "The C backend does not currently support integer "
    -           << "types of widths other than 1, 8, 16, 32, 64.\n";
    -      cerr << "This is being tracked as PR 4158.\n";
    -      abort();
    +      llvm_report_error("The C backend does not currently support integer "
    +                        "types of widths other than 1, 8, 16, 32, 64.\n"
    +                        "This is being tracked as PR 4158.");
       }
     
       // If this is a non-trivial bool computation, make sure to truncate down to
    @@ -2663,7 +2671,11 @@
         case Instruction::Shl : Out << " << "; break;
         case Instruction::LShr:
         case Instruction::AShr: Out << " >> "; break;
    -    default: cerr << "Invalid operator type!" << I; abort();
    +    default: 
    +#ifndef NDEBUG
    +       cerr << "Invalid operator type!" << I;
    +#endif
    +       llvm_unreachable();
         }
     
         writeOperandWithCast(I.getOperand(1), I.getOpcode());
    @@ -2700,7 +2712,11 @@
       case ICmpInst::ICMP_SLT: Out << " < "; break;
       case ICmpInst::ICMP_UGT:
       case ICmpInst::ICMP_SGT: Out << " > "; break;
    -  default: cerr << "Invalid icmp predicate!" << I; abort();
    +  default:
    +#ifndef NDEBUG
    +    cerr << "Invalid icmp predicate!" << I; 
    +#endif
    +    llvm_unreachable();
       }
     
       writeOperandWithCast(I.getOperand(1), I);
    @@ -3020,10 +3036,12 @@
         Out << ", ";
         // Output the last argument to the enclosing function.
         if (I.getParent()->getParent()->arg_empty()) {
    -      cerr << "The C backend does not currently support zero "
    +      std::string msg;
    +      raw_string_ostream Msg(msg);
    +      Msg << "The C backend does not currently support zero "
                << "argument varargs functions, such as '"
    -           << I.getParent()->getParent()->getName() << "'!\n";
    -      abort();
    +           << I.getParent()->getParent()->getName() << "'!";
    +      llvm_report_error(Msg.str());
         }
         writeOperand(--I.getParent()->getParent()->arg_end());
         Out << ')';
    
    Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Wed Jul  8 15:53:28 2009
    @@ -30,6 +30,7 @@
     #include "llvm/Support/MathExtras.h"
     #include "llvm/Support/CommandLine.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/raw_ostream.h"
     #include "llvm/Target/TargetAsmInfo.h"
    @@ -319,8 +320,7 @@
     void SPUAsmPrinter::printOp(const MachineOperand &MO) {
       switch (MO.getType()) {
       case MachineOperand::MO_Immediate:
    -    cerr << "printOp() does not handle immediate values\n";
    -    abort();
    +    llvm_report_error("printOp() does not handle immediate values");
         return;
     
       case MachineOperand::MO_MachineBasicBlock:
    @@ -573,8 +573,7 @@
        case GlobalValue::InternalLinkage:
         break;
        default:
    -    cerr << "Unknown linkage type!";
    -    abort();
    +    llvm_report_error("Unknown linkage type!");
       }
     
       EmitAlignment(Align, GVar);
    
    Modified: llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -31,8 +31,10 @@
     #include "llvm/GlobalValue.h"
     #include "llvm/Intrinsics.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/MathExtras.h"
     #include "llvm/Support/Compiler.h"
    +#include "llvm/Support/raw_ostream.h"
     
     using namespace llvm;
     
    @@ -191,10 +193,11 @@
     
     #ifndef NDEBUG
         if (retval == 0) {
    -      cerr << "SPUISelDAGToDAG.cpp: getValueTypeMapEntry returns NULL for "
    -           << VT.getMVTString()
    -           << "\n";
    -      abort();
    +      std::string msg;
    +      raw_string_ostream Msg(msg);
    +      Msg << "SPUISelDAGToDAG.cpp: getValueTypeMapEntry returns NULL for "
    +           << VT.getMVTString();
    +      llvm_report_error(Msg.str());
         }
     #endif
     
    @@ -437,16 +440,14 @@
       case ISD::Constant:
       case ISD::ConstantPool:
       case ISD::GlobalAddress:
    -    cerr << "SPU SelectAFormAddr: Constant/Pool/Global not lowered.\n";
    -    abort();
    +    llvm_report_error("SPU SelectAFormAddr: Constant/Pool/Global not lowered.");
         /*NOTREACHED*/
     
       case ISD::TargetConstant:
       case ISD::TargetGlobalAddress:
       case ISD::TargetJumpTable:
    -    cerr << "SPUSelectAFormAddr: Target Constant/Pool/Global not wrapped as "
    -         << "A-form address.\n";
    -    abort();
    +    llvm_report_error("SPUSelectAFormAddr: Target Constant/Pool/Global "
    +                      "not wrapped as A-form address.");
         /*NOTREACHED*/
     
       case SPUISD::AFormAddr:
    @@ -730,10 +731,8 @@
     
         switch (Op0VT.getSimpleVT()) {
         default:
    -      cerr << "CellSPU Select: Unhandled zero/any extend MVT\n";
    -      abort();
    +      llvm_report_error("CellSPU Select: Unhandled zero/any extend MVT");
           /*NOTREACHED*/
    -      break;
         case MVT::i32:
           shufMask = CurDAG->getNode(ISD::BUILD_VECTOR, dl, MVT::v4i32,
                                      CurDAG->getConstant(0x80808080, MVT::i32),
    @@ -900,10 +899,11 @@
         const valtype_map_s *vtm = getValueTypeMapEntry(VT);
     
         if (vtm->ldresult_ins == 0) {
    -      cerr << "LDRESULT for unsupported type: "
    -           << VT.getMVTString()
    -           << "\n";
    -      abort();
    +      std::string msg;
    +      raw_string_ostream Msg(msg);
    +      Msg << "LDRESULT for unsupported type: "
    +           << VT.getMVTString();
    +      llvm_report_error(Msg.str());
         }
     
         Opc = vtm->ldresult_ins;
    @@ -1231,8 +1231,8 @@
         return CurDAG->getTargetNode(SPU::ORi64_v2i64, dl, OpVT,
                                      SDValue(emitBuildVector(i64vec), 0));
       } else {
    -    cerr << "SPUDAGToDAGISel::SelectI64Constant: Unhandled i64vec condition\n";
    -    abort();
    +    llvm_report_error("SPUDAGToDAGISel::SelectI64Constant: Unhandled i64vec"
    +                      "condition");
       }
     }
     
    
    Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original)
    +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Wed Jul  8 15:53:28 2009
    @@ -28,7 +28,9 @@
     #include "llvm/Function.h"
     #include "llvm/Intrinsics.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/MathExtras.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "llvm/Target/TargetOptions.h"
     
     #include 
    @@ -70,10 +72,11 @@
     
     #ifndef NDEBUG
         if (retval == 0) {
    -      cerr << "getValueTypeMapEntry returns NULL for "
    -           << VT.getMVTString()
    -           << "\n";
    -      abort();
    +      std::string msg;
    +      raw_string_ostream Msg(msg);
    +      Msg << "getValueTypeMapEntry returns NULL for "
    +           << VT.getMVTString();
    +      llvm_report_error(Msg.str());
         }
     #endif
     
    @@ -665,11 +668,15 @@
       case ISD::POST_INC:
       case ISD::POST_DEC:
       case ISD::LAST_INDEXED_MODE:
    -    cerr << "LowerLOAD: Got a LoadSDNode with an addr mode other than "
    +    {
    +      std::string msg;
    +      raw_string_ostream Msg(msg);
    +      Msg << "LowerLOAD: Got a LoadSDNode with an addr mode other than "
                 "UNINDEXED\n";
    -    cerr << (unsigned) LN->getAddressingMode() << "\n";
    -    abort();
    -    /*NOTREACHED*/
    +      Msg << (unsigned) LN->getAddressingMode();
    +      llvm_report_error(Msg.str());
    +      /*NOTREACHED*/
    +    }
       }
     
       return SDValue();
    @@ -830,11 +837,15 @@
       case ISD::POST_INC:
       case ISD::POST_DEC:
       case ISD::LAST_INDEXED_MODE:
    -    cerr << "LowerLOAD: Got a LoadSDNode with an addr mode other than "
    +    {
    +      std::string msg;
    +      raw_string_ostream Msg(msg);
    +      Msg << "LowerLOAD: Got a LoadSDNode with an addr mode other than "
                 "UNINDEXED\n";
    -    cerr << (unsigned) SN->getAddressingMode() << "\n";
    -    abort();
    -    /*NOTREACHED*/
    +      Msg << (unsigned) SN->getAddressingMode();
    +      llvm_report_error(Msg.str());
    +      /*NOTREACHED*/
    +    }
       }
     
       return SDValue();
    @@ -920,9 +931,8 @@
           return DAG.getNode(SPUISD::IndirectAddr, dl, PtrVT, Hi, Lo);
         }
       } else {
    -    cerr << "LowerGlobalAddress: Relocation model other than static not "
    -         << "supported.\n";
    -    abort();
    +    llvm_report_error("LowerGlobalAddress: Relocation model other than static"
    +                      "not supported.");
         /*NOTREACHED*/
       }
     
    @@ -984,10 +994,11 @@
     
           switch (ObjectVT.getSimpleVT()) {
           default: {
    -        cerr << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
    -             << ObjectVT.getMVTString()
    -             << "\n";
    -        abort();
    +        std::string msg;
    +        raw_string_ostream Msg(msg);
    +        Msg << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
    +             << ObjectVT.getMVTString();
    +        llvm_report_error(Msg.str());
           }
           case MVT::i8:
             ArgRegClass = &SPU::R8CRegClass;
    @@ -1529,12 +1540,14 @@
       uint64_t SplatBits = APSplatBits.getZExtValue();
     
       switch (VT.getSimpleVT()) {
    -  default:
    -    cerr << "CellSPU: Unhandled VT in LowerBUILD_VECTOR, VT = "
    -         << VT.getMVTString()
    -         << "\n";
    -    abort();
    +  default: {
    +    std::string msg;
    +    raw_string_ostream Msg(msg);
    +    Msg << "CellSPU: Unhandled VT in LowerBUILD_VECTOR, VT = "
    +         << VT.getMVTString();
    +    llvm_report_error(Msg.str());
         /*NOTREACHED*/
    +  }
       case MVT::v4f32: {
         uint32_t Value32 = uint32_t(SplatBits);
         assert(SplatBitSize == 32
    @@ -1948,8 +1961,8 @@
         // slot 0 across the vector
         MVT VecVT = N.getValueType();
         if (!VecVT.isSimple() || !VecVT.isVector() || !VecVT.is128BitVector()) {
    -      cerr << "LowerEXTRACT_VECTOR_ELT: Must have a simple, 128-bit vector type!\n";
    -      abort();
    +      llvm_report_error("LowerEXTRACT_VECTOR_ELT: Must have a simple, 128-bit"
    +                        "vector type!");
         }
     
         // Make life easier by making sure the index is zero-extended to i32
    @@ -1976,8 +1989,8 @@
     
         switch (VT.getSimpleVT()) {
         default:
    -      cerr << "LowerEXTRACT_VECTOR_ELT(varable): Unhandled vector type\n";
    -      abort();
    +      llvm_report_error("LowerEXTRACT_VECTOR_ELT(varable): Unhandled vector"
    +                        "type");
           /*NOTREACHED*/
         case MVT::i8: {
           SDValue factor = DAG.getConstant(0x00000000, MVT::i32);
    @@ -2458,9 +2471,7 @@
       case ISD::SETONE:
         compareOp = ISD::SETNE; break;
       default:
    -    cerr << "CellSPU ISel Select: unimplemented f64 condition\n";
    -    abort();
    -    break;
    +    llvm_report_error("CellSPU ISel Select: unimplemented f64 condition");
       }
     
       SDValue result =
    @@ -2568,11 +2579,13 @@
     
       switch (Opc) {
       default: {
    +#ifndef NDEBUG
         cerr << "SPUTargetLowering::LowerOperation(): need to lower this!\n";
         cerr << "Op.getOpcode() = " << Opc << "\n";
         cerr << "*Op.getNode():\n";
         Op.getNode()->dump();
    -    abort();
    +#endif
    +    llvm_unreachable();
       }
       case ISD::LOAD:
       case ISD::EXTLOAD:
    
    Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp (original)
    +++ llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -19,6 +19,7 @@
     #include "llvm/CodeGen/MachineInstrBuilder.h"
     #include "llvm/Support/Streams.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     
     using namespace llvm;
     
    @@ -313,8 +314,7 @@
       } else if (RC == SPU::VECREGRegisterClass) {
         opc = (isValidFrameIdx) ? SPU::STQDv16i8 : SPU::STQXv16i8;
       } else {
    -    assert(0 && "Unknown regclass!");
    -    abort();
    +    LLVM_UNREACHABLE("Unknown regclass!");
       }
     
       DebugLoc DL = DebugLoc::getUnknownLoc();
    @@ -328,8 +328,7 @@
                                       SmallVectorImpl &Addr,
                                       const TargetRegisterClass *RC,
                                       SmallVectorImpl &NewMIs) const {
    -  cerr << "storeRegToAddr() invoked!\n";
    -  abort();
    +  llvm_report_error("storeRegToAddr() invoked!");
     
       if (Addr[0].isFI()) {
         /* do what storeRegToStackSlot does here */
    @@ -348,8 +347,7 @@
         } else if (RC == SPU::VECREGRegisterClass) {
           /* Opc = PPC::STVX; */
         } else {
    -      assert(0 && "Unknown regclass!");
    -      abort();
    +      LLVM_UNREACHABLE("Unknown regclass!");
         }
         DebugLoc DL = DebugLoc::getUnknownLoc();
         MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc))
    @@ -385,8 +383,7 @@
       } else if (RC == SPU::VECREGRegisterClass) {
         opc = (isValidFrameIdx) ? SPU::LQDv16i8 : SPU::LQXv16i8;
       } else {
    -    assert(0 && "Unknown regclass in loadRegFromStackSlot!");
    -    abort();
    +    LLVM_UNREACHABLE("Unknown regclass in loadRegFromStackSlot!");
       }
     
       DebugLoc DL = DebugLoc::getUnknownLoc();
    @@ -402,8 +399,7 @@
                                        const TargetRegisterClass *RC,
                                        SmallVectorImpl &NewMIs)
         const {
    -  cerr << "loadRegToAddr() invoked!\n";
    -  abort();
    +  llvm_report_error("loadRegToAddr() invoked!");
     
       if (Addr[0].isFI()) {
         /* do what loadRegFromStackSlot does here... */
    @@ -424,8 +420,7 @@
         } else if (RC == SPU::GPRCRegisterClass) {
           /* Opc = something else! */
         } else {
    -      assert(0 && "Unknown regclass!");
    -      abort();
    +      LLVM_UNREACHABLE("Unknown regclass!");
         }
         DebugLoc DL = DebugLoc::getUnknownLoc();
         MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc), DestReg);
    
    Modified: llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp (original)
    +++ llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -35,7 +35,9 @@
     #include "llvm/Target/TargetOptions.h"
     #include "llvm/Support/CommandLine.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/MathExtras.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "llvm/ADT/BitVector.h"
     #include "llvm/ADT/STLExtras.h"
     #include 
    @@ -176,8 +178,7 @@
       case SPU::R126: return 126;
       case SPU::R127: return 127;
       default:
    -    cerr << "Unhandled reg in SPURegisterInfo::getRegisterNumbering!\n";
    -    abort();
    +    llvm_report_error("Unhandled reg in SPURegisterInfo::getRegisterNumbering");
       }
     }
     
    @@ -485,8 +486,10 @@
             .addReg(SPU::R2)
             .addReg(SPU::R1);
         } else {
    -      cerr << "Unhandled frame size: " << FrameSize << "\n";
    -      abort();
    +      std::string msg;
    +      raw_string_ostream Msg(msg);
    +      Msg << "Unhandled frame size: " << FrameSize;
    +      llvm_report_error(Msg.str());
         }
     
         if (hasDebugInfo) {
    @@ -577,8 +580,10 @@
             .addReg(SPU::R2)
             .addReg(SPU::R1);
         } else {
    -      cerr << "Unhandled frame size: " << FrameSize << "\n";
    -      abort();
    +      std::string msg;
    +      raw_string_ostream Msg(msg);
    +      Msg << "Unhandled frame size: " << FrameSize;
    +      llvm_report_error(Msg.str());
         }
        }
     }
    
    Modified: llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp Wed Jul  8 15:53:28 2009
    @@ -318,11 +318,11 @@
        case GlobalValue::PrivateLinkage:
         break;
        case GlobalValue::GhostLinkage:
    -    llvm_report_error("GhostLinkage cannot appear in IA64AsmPrinter!");
    +    LLVM_UNREACHABLE("GhostLinkage cannot appear in IA64AsmPrinter!");
        case GlobalValue::DLLImportLinkage:
    -    llvm_report_error("DLLImport linkage is not supported by this target!");
    +    LLVM_UNREACHABLE("DLLImport linkage is not supported by this target!");
        case GlobalValue::DLLExportLinkage:
    -    llvm_report_error("DLLExport linkage is not supported by this target!");
    +    LLVM_UNREACHABLE("DLLExport linkage is not supported by this target!");
        default:
         LLVM_UNREACHABLE("Unknown linkage type!");
       }
    
    Modified: llvm/trunk/lib/Target/IA64/IA64ISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64ISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/IA64/IA64ISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/IA64/IA64ISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -26,7 +26,9 @@
     #include "llvm/Intrinsics.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/MathExtras.h"
    +#include "llvm/Support/raw_ostream.h"
     using namespace llvm;
     
     namespace {
    
    Modified: llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp (original)
    +++ llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp Wed Jul  8 15:53:28 2009
    @@ -20,6 +20,7 @@
     #include "llvm/CodeGen/SelectionDAG.h"
     #include "llvm/CodeGen/MachineRegisterInfo.h"
     #include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "llvm/Constants.h"
     #include "llvm/Function.h"
     using namespace llvm;
    
    Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -28,6 +28,8 @@
     #include "llvm/Target/TargetLowering.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     using namespace llvm;
     
     /// MSP430DAGToDAGISel - MSP430 specific code to select MSP430 machine
    
    Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original)
    +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Wed Jul  8 15:53:28 2009
    @@ -193,11 +193,11 @@
           switch (RegVT.getSimpleVT()) {
           default: 
             {
    -          std::string msg;
    -          raw_string_ostream Msg(msg);
    -          Msg << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
    -            << RegVT.getSimpleVT();
    -          llvm_report_error(Msg.str());
    +#ifndef NDEBUG
    +          cerr << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
    +               << RegVT.getSimpleVT() << "\n";
    +#endif
    +          llvm_unreachable();
             }
           case MVT::i16:
             unsigned VReg =
    
    Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Wed Jul  8 15:53:28 2009
    @@ -406,7 +406,7 @@
           break;
       
         default:
    -      llvm_report_error(""); break;
    +      LLVM_UNREACHABLE("");
       }
     
       if (closeP) O << ")";
    @@ -545,11 +545,11 @@
           printSizeAndType = false;
         break;
        case GlobalValue::GhostLinkage:
    -    llvm_report_error("Should not have any unmaterialized functions!");
    +    LLVM_UNREACHABLE("Should not have any unmaterialized functions!");
        case GlobalValue::DLLImportLinkage:
    -    llvm_report_error("DLLImport linkage is not supported by this target!");
    +    LLVM_UNREACHABLE("DLLImport linkage is not supported by this target!");
        case GlobalValue::DLLExportLinkage:
    -    llvm_report_error("DLLExport linkage is not supported by this target!");
    +    LLVM_UNREACHABLE("DLLExport linkage is not supported by this target!");
        default:
         LLVM_UNREACHABLE("Unknown linkage type!");
       }
    
    Modified: llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -32,6 +32,8 @@
     #include "llvm/Target/TargetMachine.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     using namespace llvm;
     
     //===----------------------------------------------------------------------===//
    
    Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -13,6 +13,8 @@
     
     #define DEBUG_TYPE "pic16-isel"
     
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "PIC16ISelDAGToDAG.h"
     #include "llvm/Support/Debug.h"
     
    
    Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Jul  8 15:53:28 2009
    @@ -36,6 +36,7 @@
     #include "llvm/Support/MathExtras.h"
     #include "llvm/Support/CommandLine.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/raw_ostream.h"
     #include "llvm/Target/TargetAsmInfo.h"
    @@ -70,7 +71,7 @@
     
         unsigned enumRegToMachineReg(unsigned enumReg) {
           switch (enumReg) {
    -      default: assert(0 && "Unhandled register!"); break;
    +      default: LLVM_UNREACHABLE("Unhandled register!");
           case PPC::CR0:  return  0;
           case PPC::CR1:  return  1;
           case PPC::CR2:  return  2;
    @@ -80,7 +81,7 @@
           case PPC::CR6:  return  6;
           case PPC::CR7:  return  7;
           }
    -      abort();
    +      llvm_unreachable();
         }
     
         /// printInstruction - This method is automatically generated by tablegen
    @@ -348,9 +349,7 @@
     void PPCAsmPrinter::printOp(const MachineOperand &MO) {
       switch (MO.getType()) {
       case MachineOperand::MO_Immediate:
    -    cerr << "printOp() does not handle immediate values\n";
    -    abort();
    -    return;
    +    LLVM_UNREACHABLE("printOp() does not handle immediate values");
     
       case MachineOperand::MO_MachineBasicBlock:
         printBasicBlockLabel(MO.getMBB());
    @@ -552,9 +551,7 @@
       if (printInstruction(MI))
         return; // Printer was automatically generated
     
    -  assert(0 && "Unhandled instruction in asm writer!");
    -  abort();
    -  return;
    +  LLVM_UNREACHABLE("Unhandled instruction in asm writer!");
     }
     
     /// runOnMachineFunction - This uses the printMachineInstruction()
    @@ -709,8 +706,7 @@
        case GlobalValue::PrivateLinkage:
         break;
        default:
    -    cerr << "Unknown linkage type!";
    -    abort();
    +    LLVM_UNREACHABLE("Unknown linkage type!");
       }
     
       EmitAlignment(Align, GVar);
    @@ -940,8 +936,7 @@
        case GlobalValue::PrivateLinkage:
         break;
        default:
    -    cerr << "Unknown linkage type!";
    -    abort();
    +    LLVM_UNREACHABLE("Unknown linkage type!");
       }
     
       EmitAlignment(Align, GVar);
    
    Modified: llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp (original)
    +++ llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp Wed Jul  8 15:53:28 2009
    @@ -26,6 +26,8 @@
     #include "llvm/CodeGen/Passes.h"
     #include "llvm/Support/Debug.h"
     #include "llvm/Support/Compiler.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "llvm/Target/TargetOptions.h"
     using namespace llvm;
     
    @@ -263,8 +265,10 @@
         MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(),
                                                    Reloc, MO.getMBB()));
       } else {
    +#ifndef NDEBUG
         cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n";
    -    abort();
    +#endif
    +    llvm_unreachable();
       }
     
       return rv;
    
    Modified: llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -31,6 +31,8 @@
     #include "llvm/Support/Debug.h"
     #include "llvm/Support/MathExtras.h"
     #include "llvm/Support/Compiler.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     using namespace llvm;
     
     namespace {
    @@ -600,8 +602,8 @@
       case ISD::SETONE:
       case ISD::SETOLE:
       case ISD::SETOGE:
    -    assert(0 && "Should be lowered by legalize!");
    -  default: assert(0 && "Unknown condition!"); abort();
    +    LLVM_UNREACHABLE("Should be lowered by legalize!");
    +  default: LLVM_UNREACHABLE("Unknown condition!");
       case ISD::SETOEQ:
       case ISD::SETEQ:  return PPC::PRED_EQ;
       case ISD::SETUNE:
    @@ -632,7 +634,7 @@
       Invert = false;
       Other = -1;
       switch (CC) {
    -  default: assert(0 && "Unknown condition!"); abort();
    +  default: LLVM_UNREACHABLE("Unknown condition!");
       case ISD::SETOLT:
       case ISD::SETLT:  return 0;                  // Bit #0 = SETOLT
       case ISD::SETOGT:
    
    Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
    +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Wed Jul  8 15:53:28 2009
    @@ -32,6 +32,8 @@
     #include "llvm/Support/MathExtras.h"
     #include "llvm/Target/TargetOptions.h"
     #include "llvm/Support/CommandLine.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "llvm/DerivedTypes.h"
     using namespace llvm;
     
    @@ -2584,9 +2586,11 @@
           }
           
           if (Result) {
    +#ifndef NDEBUG
             cerr << "Call operand #" << i << " has unhandled type "
                  << ArgVT.getMVTString() << "\n";
    -        abort();
    +#endif
    +        llvm_unreachable();
           }
         }
       } else {
    @@ -4141,8 +4145,7 @@
         }
         return DAG.getVectorShuffle(MVT::v16i8, dl, EvenParts, OddParts, Ops);
       } else {
    -    assert(0 && "Unknown mul to lower!");
    -    abort();
    +    LLVM_UNREACHABLE("Unknown mul to lower!");
       }
     }
     
    
    Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp (original)
    +++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -20,6 +20,8 @@
     #include "llvm/ADT/STLExtras.h"
     #include "llvm/CodeGen/MachineInstrBuilder.h"
     #include "llvm/Support/CommandLine.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "llvm/Target/TargetAsmInfo.h"
     using namespace llvm;
     
    @@ -485,8 +487,7 @@
                          .addReg(PPC::R0)
                          .addReg(PPC::R0));
       } else {
    -    assert(0 && "Unknown regclass!");
    -    abort();
    +    LLVM_UNREACHABLE("Unknown regclass!");
       }
     
       return false;
    @@ -537,8 +538,7 @@
       } else if (RC == PPC::VRRCRegisterClass) {
         Opc = PPC::STVX;
       } else {
    -    assert(0 && "Unknown regclass!");
    -    abort();
    +    LLVM_UNREACHABLE("Unknown regclass!");
       }
       MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc))
         .addReg(SrcReg, getKillRegState(isKill));
    @@ -634,8 +634,7 @@
         NewMIs.push_back(BuildMI(MF, DL, get(PPC::LVX),DestReg).addReg(PPC::R0)
                          .addReg(PPC::R0));
       } else {
    -    assert(0 && "Unknown regclass!");
    -    abort();
    +    LLVM_UNREACHABLE("Unknown regclass!");
       }
     }
     
    @@ -677,8 +676,7 @@
       } else if (RC == PPC::VRRCRegisterClass) {
         Opc = PPC::LVX;
       } else {
    -    assert(0 && "Unknown regclass!");
    -    abort();
    +    LLVM_UNREACHABLE("Unknown regclass!");
       }
       DebugLoc DL = DebugLoc::getUnknownLoc();
       MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc), DestReg);
    
    Modified: llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp (original)
    +++ llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -18,6 +18,8 @@
     #include "llvm/Function.h"
     #include "llvm/System/Memory.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     using namespace llvm;
     
     static TargetJITInfo::JITCompilerFn JITCompilerFunction;
    @@ -197,8 +199,7 @@
         );
     #else
     void PPC32CompilationCallback() {
    -  assert(0 && "This is not a power pc, you can't execute this!");
    -  abort();
    +  LLVM_UNREACHABLE("This is not a power pc, you can't execute this!");
     }
     #endif
     
    @@ -264,8 +265,7 @@
         );
     #else
     void PPC64CompilationCallback() {
    -  assert(0 && "This is not a power pc, you can't execute this!");
    -  abort();
    +  LLVM_UNREACHABLE("This is not a power pc, you can't execute this!");
     }
     #endif
     
    
    Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original)
    +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -37,7 +37,9 @@
     #include "llvm/Target/TargetOptions.h"
     #include "llvm/Support/CommandLine.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/MathExtras.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "llvm/ADT/BitVector.h"
     #include "llvm/ADT/STLExtras.h"
     #include 
    @@ -111,8 +113,7 @@
       case R30:  case X30:  case F30:  case V30: case CR7EQ: return 30;
       case R31:  case X31:  case F31:  case V31: case CR7UN: return 31;
       default:
    -    cerr << "Unhandled reg in PPCRegisterInfo::getRegisterNumbering!\n";
    -    abort();
    +    LLVM_UNREACHABLE("Unhandled reg in PPCRegisterInfo::getRegisterNumbering!");
       }
     }
     
    
    Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Wed Jul  8 15:53:28 2009
    @@ -185,7 +185,7 @@
           << MO.getIndex();
         break;
       default:
    -    llvm_report_error(""); break;
    +    LLVM_UNREACHABLE("");
       }
       if (CloseParen) O << ")";
     }
    @@ -299,11 +299,11 @@
        case GlobalValue::InternalLinkage:
         break;
        case GlobalValue::GhostLinkage:
    -    llvm_report_error("Should not have any unmaterialized functions!");
    +    LLVM_UNREACHABLE("Should not have any unmaterialized functions!");
        case GlobalValue::DLLImportLinkage:
    -    llvm_report_error("DLLImport linkage is not supported by this target!");
    +    LLVM_UNREACHABLE("DLLImport linkage is not supported by this target!");
        case GlobalValue::DLLExportLinkage:
    -    llvm_report_error("DLLExport linkage is not supported by this target!");
    +    LLVM_UNREACHABLE("DLLExport linkage is not supported by this target!");
        default:
         LLVM_UNREACHABLE("Unknown linkage type!");
       }
    
    Modified: llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -17,6 +17,8 @@
     #include "llvm/CodeGen/SelectionDAGISel.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     using namespace llvm;
     
     //===----------------------------------------------------------------------===//
    
    Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Wed Jul  8 15:53:28 2009
    @@ -104,7 +104,7 @@
         if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
           O << DispVal;
       } else {
    -    llvm_report_error("non-immediate displacement for LEA?");
    +    LLVM_UNREACHABLE("non-immediate displacement for LEA?");
         //assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
         //       DispSpec.isJTI() || DispSpec.isSymbol());
         //printOperand(MI, Op+3, "mem");
    
    Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
    +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Wed Jul  8 15:53:28 2009
    @@ -32,7 +32,6 @@
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/Debug.h"
     #include "llvm/Support/ErrorHandling.h"
    -#include "llvm/Support/raw_ostream.h"
     #include "llvm/Target/TargetOptions.h"
     using namespace llvm;
     
    @@ -806,10 +805,10 @@
       }
     
       if (!Desc->isVariadic() && CurOp != NumOps) {
    -    std::string msg;
    -    raw_string_ostream Msg(msg);
    -    Msg << "Cannot encode: " << MI;
    -    llvm_report_error(Msg.str());
    +#ifndef NDEBUG
    +    cerr << "Cannot encode: " << MI << "\n";
    +#endif
    +    llvm_unreachable();
       }
     }
     
    
    Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -35,8 +35,10 @@
     #include "llvm/Target/TargetOptions.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/MathExtras.h"
     #include "llvm/Support/Streams.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "llvm/ADT/SmallPtrSet.h"
     #include "llvm/ADT/Statistic.h"
     using namespace llvm;
    
    Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
    +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul  8 15:53:28 2009
    @@ -38,6 +38,7 @@
     #include "llvm/ADT/SmallSet.h"
     #include "llvm/ADT/StringExtras.h"
     #include "llvm/Support/CommandLine.h"
    +#include "llvm/Support/raw_ostream.h"
     using namespace llvm;
     
     static cl::opt
    @@ -6054,7 +6055,7 @@
       SDValue SrcPtr = Op.getOperand(1);
       SDValue SrcSV = Op.getOperand(2);
     
    -  LLVM_UNREACHABLE("VAArgInst is not yet implemented for x86-64!");
    +  llvm_report_error("VAArgInst is not yet implemented for x86-64!");
       return SDValue();
     }
     
    
    Modified: llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Wed Jul  8 15:53:28 2009
    @@ -204,13 +204,13 @@
         case GlobalValue::PrivateLinkage:
           break;
         case GlobalValue::GhostLinkage:
    -      llvm_report_error("Should not have any unmaterialized functions!");
    +      LLVM_UNREACHABLE("Should not have any unmaterialized functions!");
         case GlobalValue::DLLImportLinkage:
    -      llvm_report_error("DLLImport linkage is not supported by this target!");
    +      LLVM_UNREACHABLE("DLLImport linkage is not supported by this target!");
         case GlobalValue::DLLExportLinkage:
    -      llvm_report_error("DLLExport linkage is not supported by this target!");
    +      LLVM_UNREACHABLE("DLLExport linkage is not supported by this target!");
         default:
    -      assert(0 && "Unknown linkage type!");
    +      LLVM_UNREACHABLE("Unknown linkage type!");
         }
     
         EmitAlignment(Align, GV, 2);
    
    Modified: llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp Wed Jul  8 15:53:28 2009
    @@ -28,6 +28,8 @@
     #include "llvm/Target/TargetLowering.h"
     #include "llvm/Support/Compiler.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
    +#include "llvm/Support/raw_ostream.h"
     #include 
     #include 
     using namespace llvm;
    
    Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original)
    +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Wed Jul  8 15:53:28 2009
    @@ -32,6 +32,7 @@
     #include "llvm/CodeGen/SelectionDAGISel.h"
     #include "llvm/CodeGen/ValueTypes.h"
     #include "llvm/Support/Debug.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/ADT/VectorExtras.h"
     #include 
     #include 
    @@ -270,8 +271,11 @@
       }
       const Type *Ty = cast(GV->getType())->getElementType();
       if (!Ty->isSized() || isZeroLengthArray(Ty)) {
    -    llvm_report_error("Size of thread local object " + GVar->getName()
    -                      + " is unknown");
    +#ifndef NDEBUG
    +    cerr << "Size of thread local object " << GVar->getName()
    +        << " is unknown\n";
    +#endif
    +    llvm_unreachable();
       }
       SDValue base = getGlobalAddressWrapper(GA, GV, DAG);
       const TargetData *TD = TM.getTargetData();
    @@ -646,11 +650,11 @@
           switch (RegVT.getSimpleVT()) {
           default:
             {
    -          std::string msg;
    -          raw_string_ostream Msg(msg);
    -          Msg << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
    -            << RegVT.getSimpleVT();
    -          llvm_report_error(Msg.str());
    +#ifndef NDEBUG
    +          cerr << "LowerFORMAL_ARGUMENTS Unhandled argument type: "
    +               << RegVT.getSimpleVT() << "\n";
    +#endif
    +          llvm_unreachable();
             }
           case MVT::i32:
             unsigned VReg = RegInfo.createVirtualRegister(
    
    Modified: llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp (original)
    +++ llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp Wed Jul  8 15:53:28 2009
    @@ -144,11 +144,11 @@
           
           if (!isU6 && !isImmU16(Amount)) {
             // FIX could emit multiple instructions in this case.
    -        std::string msg;
    -        raw_string_ostream Msg(msg);
    -        Msg  << "eliminateCallFramePseudoInstr size too big: "
    -             << Amount;
    -        llvm_report_error(Msg.str());
    +#ifndef NDEBUG
    +        cerr << "eliminateCallFramePseudoInstr size too big: "
    +             << Amount << "\n";
    +#endif
    +        llvm_unreachable();
           }
     
           MachineInstr *New;
    
    Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
    +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Wed Jul  8 15:53:28 2009
    @@ -33,6 +33,7 @@
     #include "llvm/Support/CFG.h"
     #include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/MathExtras.h"
    +#include "llvm/Support/Streams.h"
     #include "llvm/Support/raw_ostream.h"
     #include 
     #include 
    @@ -1235,7 +1236,7 @@
       case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break;
       case GlobalValue::ExternalLinkage: break;
       case GlobalValue::GhostLinkage:
    -    llvm_report_error("GhostLinkage not allowed in AsmWriter!");
    +    LLVM_UNREACHABLE("GhostLinkage not allowed in AsmWriter!");
       }
     }
     
    
    Modified: llvm/trunk/lib/VMCore/Globals.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/VMCore/Globals.cpp (original)
    +++ llvm/trunk/lib/VMCore/Globals.cpp Wed Jul  8 15:53:28 2009
    @@ -21,6 +21,7 @@
     #include "llvm/ADT/SmallPtrSet.h"
     #include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/LeakDetector.h"
    +#include "llvm/Support/Streams.h"
     using namespace llvm;
     
     //===----------------------------------------------------------------------===//
    
    Modified: llvm/trunk/lib/VMCore/Instructions.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/VMCore/Instructions.cpp (original)
    +++ llvm/trunk/lib/VMCore/Instructions.cpp Wed Jul  8 15:53:28 2009
    @@ -20,6 +20,7 @@
     #include "llvm/Support/CallSite.h"
     #include "llvm/Support/ConstantRange.h"
     #include "llvm/Support/MathExtras.h"
    +#include "llvm/Support/Streams.h"
     using namespace llvm;
     
     //===----------------------------------------------------------------------===//
    
    Modified: llvm/trunk/lib/VMCore/Type.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/VMCore/Type.cpp (original)
    +++ llvm/trunk/lib/VMCore/Type.cpp Wed Jul  8 15:53:28 2009
    @@ -265,10 +265,10 @@
     }
     
     void Type::refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
    -  llvm_report_error("Attempting to refine a derived type!");
    +  LLVM_UNREACHABLE("Attempting to refine a derived type!");
     }
     void Type::typeBecameConcrete(const DerivedType *AbsTy) {
    -  llvm_report_error("DerivedType is already a concrete type!");
    +  LLVM_UNREACHABLE("DerivedType is already a concrete type!");
     }
     
     
    
    Modified: llvm/trunk/lib/VMCore/Value.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/VMCore/Value.cpp (original)
    +++ llvm/trunk/lib/VMCore/Value.cpp Wed Jul  8 15:53:28 2009
    @@ -23,6 +23,7 @@
     #include "llvm/Support/LeakDetector.h"
     #include "llvm/Support/ManagedStatic.h"
     #include "llvm/Support/ValueHandle.h"
    +#include "llvm/Support/raw_ostream.h"
     #include "llvm/System/RWMutex.h"
     #include "llvm/System/Threading.h"
     #include "llvm/ADT/DenseMap.h"
    @@ -515,8 +516,8 @@
           cerr << "While deleting: " << *V->getType() << " %" << V->getNameStr()
                << "\n";
     #endif
    -      llvm_report_error("An asserting value handle still pointed to this"
    -                        "value!");
    +      LLVM_UNREACHABLE("An asserting value handle still pointed to this"
    +                       "value!");
         case Weak:
           // Weak just goes to null, which will unlink it from the list.
           ThisNode->operator=(0);
    
    Modified: llvm/trunk/lib/VMCore/Verifier.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=75043&r1=75042&r2=75043&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/VMCore/Verifier.cpp (original)
    +++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Jul  8 15:53:28 2009
    @@ -211,7 +211,9 @@
           default: assert(0 && "Unknown action");
           case AbortProcessAction:
             msgs << "compilation aborted!\n";
    -        llvm_report_error(msgs.str());
    +        cerr << msgs.str();
    +        // Client should choose different reaction if abort is not desired
    +        abort();
           case PrintMessageAction:
             msgs << "verification continues.\n";
             cerr << msgs.str();
    
    
    
    
    From edwintorok at gmail.com  Wed Jul  8 15:54:24 2009
    From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=)
    Date: Wed, 08 Jul 2009 23:54:24 +0300
    Subject: [llvm-commits] [llvm] r75027 - in /llvm/trunk:
     include/llvm/CodeGen/ include/llvm/Support/ lib/Target/Alpha/
     lib/Target/Alpha/AsmPrinter/ lib/Target/IA64/ lib/Target/IA64/AsmPrinter/
     lib/Target/MSP430/ lib/Target/Mips/AsmPrinter/ lib/Target/PIC16/
     lib/Target/Sparc/AsmPrinter/ lib/Target/X86/ lib/Target/XCore/
     utils/TableGen/
    In-Reply-To: 
    References: <200907081905.n68J5D0L022265@zion.cs.uiuc.edu>	<1D0FF115-7457-4C11-97B9-14450DD66259@apple.com>	<4A5505C2.6050706@gmail.com>
    	
    Message-ID: <4A550780.5070002@gmail.com>
    
    On 2009-07-08 23:52, Chris Lattner wrote:
    > On Jul 8, 2009, at 1:46 PM, T?r?k Edwin wrote:
    >   
    >> Thanks for reviewing my commit, looks like I got it wrong in many  
    >> places.
    >> At least error handling should be more consistent now, asserts that  
    >> are
    >> meant to be assert are ;)
    >>     
    >
    > Well I only listed the ones I disagreed with, you got many more right :)
    >
    >   
    >>>> +++ llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h Wed Jul  8
    >>>> 14:04:27 2009
    >>>> @@ -18,6 +18,8 @@
    >>>> #define LLVM_CODEGEN_MACHINECODEEMITTER_H
    >>>>
    >>>> #include "llvm/Support/DataTypes.h"
    >>>> +#include "llvm/Support/ErrorHandling.h"
    >>>> +#include "llvm/Support/raw_ostream.h"
    >>>>
    >>>>         
    >>> Please don't include headers in other headers unless you cannot avoid
    >>> it.
    >>>
    >>>
    >>>       
    >> I included it because then I don't need to include it in all the
    >> *ISelDAGToDAG.cpp files.
    >> I removed it now, and included the necessary headers in each .cpp  
    >> file.
    >>     
    >
    > Why do they need raw_ostream?
    >   
    
    Because of the TableGen change to report and errormessage for a not
    handled instruction/opcode.
    All the .inc files use raw_ostream.
    
    >   
    >>>>    case GlobalValue::DLLExportLinkage:
    >>>> -      cerr << "DLLExport linkage is not supported by this target! 
    >>>> \n";
    >>>> -      abort();
    >>>> +      llvm_report_error("DLLExport linkage is not supported by this
    >>>> target!");
    >>>>
    >>>>         
    >>> assertions. :)
    >>>
    >>>       
    >> Thanks, I changed them. Quite a lot of copy+pasting between the  
    >> targets,
    >> isn't it?
    >>     
    >
    > Yes, the asmprinters are copy and paste hell, I'm trying to help a bit  
    > with the mc stuff.
    >   
    
    :)
    
    >>> Thanks Edwin, most of this looks great.  Several of these below are
    >>> assertions that have a message: the preferred style is something  
    >>> like:
    >>>
    >>> #ifndef NDEBUG
    >>>   cerr << "WHATEVER\n";
    >>> #endif
    >>>   unreachable();
    >>>
    >>>       
    >> Ok, I changed LLVM_UNREACHABLE to do that.
    >> I also used this style when a more complicated message was printed.
    >>     
    >
    > Sounds good.
    >
    > Thanks Edwin,
    >
    >   
    
    Thanks,
    --Edwin
    
    
    From edwintorok at gmail.com  Wed Jul  8 15:55:53 2009
    From: edwintorok at gmail.com (Torok Edwin)
    Date: Wed, 08 Jul 2009 20:55:53 -0000
    Subject: [llvm-commits] [llvm] r75045 - in /llvm/trunk/lib/Target:
     ARM/AsmPrinter/ARMAsmPrinter.cpp CppBackend/CPPBackend.cpp
    Message-ID: <200907082055.n68KtrGc026550@zion.cs.uiuc.edu>
    
    Author: edwin
    Date: Wed Jul  8 15:55:50 2009
    New Revision: 75045
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75045&view=rev
    Log:
    Missed an exit during the conversion.
    Will convert assert(0) that don't have abort() to LLVM_UNREACHABLE in a later
    commit.
    
    Modified:
        llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
        llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
    
    Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=75045&r1=75044&r2=75045&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jul  8 15:55:50 2009
    @@ -35,6 +35,7 @@
     #include "llvm/ADT/StringExtras.h"
     #include "llvm/ADT/StringSet.h"
     #include "llvm/Support/Compiler.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/Mangler.h"
     #include "llvm/Support/MathExtras.h"
     #include "llvm/Support/raw_ostream.h"
    @@ -209,7 +210,7 @@
       // Print out labels for the function.
       const Function *F = MF.getFunction();
       switch (F->getLinkage()) {
    -  default: assert(0 && "Unknown linkage type!");
    +  default: LLVM_UNREACHABLE("Unknown linkage type!");
       case Function::PrivateLinkage:
       case Function::InternalLinkage:
         SwitchToTextSection("\t.text", F);
    @@ -306,7 +307,7 @@
             O << TRI->getAsmName(Reg);
           }
         } else
    -      assert(0 && "not implemented");
    +      LLVM_UNREACHABLE("not implemented");
         break;
       }
       case MachineOperand::MO_Immediate: {
    @@ -1113,8 +1114,7 @@
        case GlobalValue::InternalLinkage:
         break;
        default:
    -    assert(0 && "Unknown linkage type!");
    -    break;
    +    LLVM_UNREACHABLE("Unknown linkage type!");
       }
     
       EmitAlignment(Align, GVar);
    
    Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=75045&r1=75044&r2=75045&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original)
    +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Wed Jul  8 15:55:50 2009
    @@ -28,6 +28,7 @@
     #include "llvm/ADT/STLExtras.h"
     #include "llvm/ADT/SmallPtrSet.h"
     #include "llvm/Support/CommandLine.h"
    +#include "llvm/Support/ErrorHandling.h"
     #include "llvm/Support/Streams.h"
     #include "llvm/Support/raw_ostream.h"
     #include "llvm/Config/config.h"
    @@ -220,8 +221,7 @@
       }
     
       void CppWriter::error(const std::string& msg) {
    -    cerr << msg << "\n";
    -    exit(2);
    +    llvm_report_error(msg);
       }
     
       // printCFP - Print a floating point constant .. very carefully :)
    
    
    
    
    From isanbard at gmail.com  Wed Jul  8 15:57:28 2009
    From: isanbard at gmail.com (Bill Wendling)
    Date: Wed, 08 Jul 2009 20:57:28 -0000
    Subject: [llvm-commits] [llvm] r75046 -
    	/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
    Message-ID: <200907082057.n68KvSji026620@zion.cs.uiuc.edu>
    
    Author: void
    Date: Wed Jul  8 15:57:27 2009
    New Revision: 75046
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75046&view=rev
    Log:
    Use interators instead of counters for loops.
    
    Modified:
        llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
    
    Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=75046&r1=75045&r2=75046&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original)
    +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Wed Jul  8 15:57:27 2009
    @@ -163,25 +163,27 @@
       FFI->setHasCalls(HasCalls);
       FFI->setMaxCallFrameSize(MaxCallFrameSize);
     
    -  for (unsigned i = 0, e = FrameSDOps.size(); i != e; ++i) {
    -    MachineBasicBlock::iterator I = FrameSDOps[i];
    -    // If call frames are not being included as part of the stack frame,
    -    // and there is no dynamic allocation (therefore referencing frame slots
    -    // off sp), leave the pseudo ops alone. We'll eliminate them later.
    +  for (std::vector::iterator
    +         i = FrameSDOps.begin(), e = FrameSDOps.end(); i != e; ++i) {
    +    MachineBasicBlock::iterator I = *i;
    +
    +    // If call frames are not being included as part of the stack frame, and
    +    // there is no dynamic allocation (therefore referencing frame slots off
    +    // sp), leave the pseudo ops alone. We'll eliminate them later.
         if (RegInfo->hasReservedCallFrame(Fn) || RegInfo->hasFP(Fn))
           RegInfo->eliminateCallFramePseudoInstr(Fn, *I->getParent(), I);
       }
     
       // Now figure out which *callee saved* registers are modified by the current
       // function, thus needing to be saved and restored in the prolog/epilog.
    -  //
    -  const TargetRegisterClass* const *CSRegClasses =
    +  const TargetRegisterClass * const *CSRegClasses =
         RegInfo->getCalleeSavedRegClasses(&Fn);
    +
       std::vector CSI;
       for (unsigned i = 0; CSRegs[i]; ++i) {
         unsigned Reg = CSRegs[i];
         if (Fn.getRegInfo().isPhysRegUsed(Reg)) {
    -        // If the reg is modified, save it!
    +      // If the reg is modified, save it!
           CSI.push_back(CalleeSavedInfo(Reg, CSRegClasses[i]));
         } else {
           for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg);
    @@ -203,9 +205,10 @@
     
       // Now that we know which registers need to be saved and restored, allocate
       // stack slots for them.
    -  for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
    -    unsigned Reg = CSI[i].getReg();
    -    const TargetRegisterClass *RC = CSI[i].getRegClass();
    +  for (std::vector::iterator
    +         I = CSI.begin(), E = CSI.end(); I != E; ++I) {
    +    unsigned Reg = I->getReg();
    +    const TargetRegisterClass *RC = I->getRegClass();
     
         // Check to see if this physreg must be spilled to a particular stack slot
         // on this target.
    @@ -215,13 +218,14 @@
           ++FixedSlot;
     
         int FrameIdx;
    -    if (FixedSlot == FixedSpillSlots+NumFixedSpillSlots) {
    +    if (FixedSlot == FixedSpillSlots + NumFixedSpillSlots) {
           // Nope, just spill it anywhere convenient.
           unsigned Align = RC->getAlignment();
           unsigned StackAlign = TFI->getStackAlignment();
    -      // We may not be able to sastify the desired alignment specification of
    -      // the TargetRegisterClass if the stack alignment is smaller.
    -      // Use the min.
    +
    +      // We may not be able to satisfy the desired alignment specification of
    +      // the TargetRegisterClass if the stack alignment is smaller. Use the
    +      // min.
           Align = std::min(Align, StackAlign);
           FrameIdx = FFI->CreateStackObject(RC->getSize(), Align);
           if ((unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx;
    @@ -230,7 +234,8 @@
           // Spill it to the stack where we must.
           FrameIdx = FFI->CreateFixedObject(RC->getSize(), FixedSlot->second);
         }
    -    CSI[i].setFrameIdx(FrameIdx);
    +
    +    I->setFrameIdx(FrameIdx);
       }
     
       FFI->setCalleeSavedInfo(CSI);
    
    
    
    
    From edwintorok at gmail.com  Wed Jul  8 15:59:24 2009
    From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=)
    Date: Wed, 08 Jul 2009 23:59:24 +0300
    Subject: [llvm-commits] [PATCH] New pass: pointer (bounds) tracking!
    In-Reply-To: 
    References: <4A4D0B51.1060302@gmail.com>
    	
    Message-ID: <4A5508AC.4020805@gmail.com>
    
    On 2009-07-08 23:43, Dan Gohman wrote:
    > Hi Edwin,
    >
    > On Jul 2, 2009, at 12:32 PM, T?r?k Edwin wrote:
    >
    >
    >   
    >> Hi,
    >>
    >> The attached patch introduces a new pass that can be queried for
    >> allocation size  of pointers,
    >> and contains a simple solver [*] for (a ult b) inequalities useful in
    >> bounds checking. This is based on the bounds checker tool I developed
    >> for my undergraduate thesis.
    >>     
    >
    > This sounds cool. Thanks for your patience; I'm finally getting around
    > to taking a look.
    >
    >   
    
    Hi Dan,
    
    I am replying to part of your email now, next part will come tomorrow.
    
    >> If this pass is something that would be accepted in LLVM, I will  
    >> cleanup
    >> the code to conform to LLVM coding style, add testcases, and resubmit
    >> the patch. I have just attached the patch now as a preview.
    >>
    >> I've seen that there is a lot of work being done to support SSI/ 
    >> ABCD. I
    >> think my approach is complementary: I try to determine whether the
    >> existing bounds checks are sufficient for the safety of a memory  
    >> access,
    >> and not whether any of the bounds checks are redundant and can be  
    >> removed.
    >>     
    >
    > It may be that the code in your pass could be used for both purposes.
    > It will be interesting to compare different approaches.
    >   
    
    Cool.
    
    >   
    >> I haven't made up  by mind whether all this should be in one pass,  
    >> or I
    >> should split it up further:
    >> PointerTracking for size information and bounds checking, and  
    >> SCEVSolver
    >> for the SCEV inequality solver?
    >> Or maybe the SCEVSolver parts should be integrated directly into
    >> ScalarEvolution?
    >>     
    >
    > It looks like most of this code could be integrated into  
    > ScalarEvolution,
    > and it would help out a number of important optimizations.  However, I
    > think it'd be fine if you wanted to check it in as a separate analysis
    > first and do the integration in separate steps. There are some tricky
    > areas, and this would make it easier to see what's being changed.
    >   
    
    I'll keep it separate from ScalarEvolution if I can.
    
    >   
    >> [*]
    >> The solver uses isLoopGuardedByCond(), but is able to handle more
    >> complicated situations by using
    >> properties of SCEV expressions, and transitivity of ULT/ULE:
    >> - if a SCEVAddRecExpr is monotonic it checks whether the start and  
    >> exit
    >> value is known to be ULT Limit.
    >>     
    >
    > This is cool :-).
    >
    >   
    >> - for PHI nodes that are SCEVUnknowns it checks whether all parts of
    >> the PHI are known to be ULT
    >> - if a value is a constant offset away from a PHI: C + X  X  
    >> > It also looks for predicates among the basic blocks that dominate the
    >> memory access, trying to
    >> find a predicate that is sufficient for the validity of the memory  
    >> access.
    >>
    >> Best regards,
    >> --Edwin
    >>
    >> 
    >>     
    >
    > Here are some comments on the patch.
    >
    >  > namespace llvm {
    >  >   char PointerTracking::ID=0;
    >  >
    >  >   [...]
    >
    > Don't indent namespace contents.
    >
    >  >   void PointerTracking::getAnalysisUsage(AnalysisUsage &AU) const {
    >  >     AU.addRequired();
    >  >     AU.addRequired();
    >  >     AU.addRequired();
    >
    > These should be addRequiredTransitive instead of addRequired, so that  
    > the
    > required analyses are preserved throughout the lifetime of the
    > PointerTracking analysis.
    >
    >  >    callocFunc = M.getFunction("calloc");
    > [...]
    >  >    reallocFunc = M.getFunction("realloc");
    >
    > I don't know what the current prevailing fasion is with respect to
    > passes knowing special things about functions with standard C library
    > names. It would be good to mention that this pass knows about
    > "calloc" and "realloc" in a high-level comment though.
    >   
    
    Ok.
    
    >  >   const SCEV *PointerTracking::getAllocationSize(Value *V)
    >
    > This name is a little confusing. Can you rename this to
    > getAllocationElementCount or something?
    >   
    
    Ok.
    
    >  >   {
    >  >     if (AllocationInst *AI = dyn_cast(V)) {
    >  >       Value *arraySize = AI->getArraySize();
    >  >       if (ConstantInt *C = dyn_cast(arraySize)) {
    >  >         return SE->getConstant(C);
    >  >       }
    >  >       return SE->getSCEVAtScope(arraySize, LI->getLoopFor(AI- 
    >  >getParent()));
    >
    > It isn't actually necessary to check for a ConstantInt specially
    > here. getSCEVAtScope will effectively do this automatically.
    >
    >  >     }
    >  >     if (GlobalVariable *GV = dyn_cast(V)) {
    >  >       if (GV->hasInitializer()) {
    >  >         Constant *C = GV->getInitializer();
    >  >         if (const ArrayType *ATy = dyn_cast(C->getType 
    > ())) {
    >  >           return SE->getConstant(Type::Int32Ty, ATy->getNumElements 
    > ());
    >
    > Hard-coding Int32Ty here may be problematic in some cases.
    >
    >  >         }
    >  >       }
    >  >       return SE->getConstant(Type::Int32Ty, 1);
    >  >     }
    >  >     // TODO: implement more complicated pointer size tracking
    >  >     return 0;
    >  >   }
    >
    >  >   const SCEV *PointerTracking::getAllocationSizeInBytes(Value *V)
    >  >   {
    >  >     assert(TD && "TargetData must be available to calculate size in  
    > bytes!");
    >
    > Would it make sense to postpone this check until TD is actually
    > needed, and then return CouldNotCompute if TD is unavailable?
    >   
    
    Yes.
    >  >     const SCEV *S = getAllocationSize(V);
    >  >     if (isa(S)) {
    >  >       if (CallInst *CI = dyn_cast(V)) {
    >  >         CallSite CS(CI);
    >  >         Function *F = dyn_cast(CS.getCalledValue()- 
    >  >stripPointerCasts());
    >
    > This line exceeds 80 columns.
    >
    >  >         const Loop *L = LI->getLoopFor(CI->getParent());
    >  >         if (F == callocFunc) {
    >  >           return
    >  >             SE->getSCEVAtScope(SE->getMulExpr(SE->getSCEV 
    > (CS.getArgument(0)),
    >  >                                               SE->getSCEV 
    > (CS.getArgument(1))),
    >  >                                L);
    >  >         } else if (F == reallocFunc) {
    >  >           return SE->getSCEVAtScope(CS.getArgument(1), L);
    >  >         }
    >  >       }
    >  >       return S;
    >  >     }
    >  >     uint64_t elementsize = TD->getTypeStoreSize(V->getType());
    >  >     return SE->getMulExpr(SE->getConstant(S->getType(),  
    > elementsize), S);
    >
    > The size of the allocation will be the number of elements multiplied
    > by the "Alloc" size, not the "Store" size.
    >   
    
    Thanks, will fix.
    
    >  >  const SCEV *getStart(const SCEV *A, const Loop *L)
    >  >  {
    >
    > Here and elsewhere, the brace for a function definition goes on the
    > same line as the close paren.
    >   
    
    Ok.
    >  >    if (isa(A))
    >  >      return A;
    >
    > This would be a little stronger as A->isLoopInvariant(L).
    >
    >  >     DomTreeNodeBase *N = DT->getNode(BB);
    >  >     DomTreeNodeBase *D = N->getIDom();
    >  >     while (D) { // D dominates N
    >  >       BasicBlock *dBB = D->getBlock();
    >  >       bool negated;
    >  >       Value *V = getConditionToReach(dBB, BB, negated);
    >  >       if (conditionSufficient(V, negated, I, ICmpInst::ICMP_ULT,  
    > Limit))
    >  >         return AlwaysTrue;
    >  >       BB = dBB;
    >  >       D = D->getIDom();
    >  >     }
    >
    > This doesn't appear correct. Even if D dominates N and has a
    > conditional branch with a successor that reaches N, it's possible
    > that the other successor of the conditional branch reaches N also.
    > See ScalarEvolution's getPredecessorWithUniqueSuccessorForBB for
    > code that solves a similar problem.
    >   
    
    That is quite a serious bug in my dominator predicate handling then,
    I'll have to be more careful.
    I'll have a look at this tomorrow, and try to post an updated patch.
    
    Best regards,
    --Edwin
    
    
    From isanbard at gmail.com  Wed Jul  8 16:03:07 2009
    From: isanbard at gmail.com (Bill Wendling)
    Date: Wed, 08 Jul 2009 21:03:07 -0000
    Subject: [llvm-commits] [llvm] r75047 - in /llvm/trunk/lib/Target/X86:
     X86RegisterInfo.cpp X86RegisterInfo.h
    Message-ID: <200907082103.n68L3AeR026802@zion.cs.uiuc.edu>
    
    Author: void
    Date: Wed Jul  8 16:02:53 2009
    New Revision: 75047
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75047&view=rev
    Log:
    Recommit r74952 with a bug fix:
    
    DWARF requires frame moves be specified at specific times. If you have a
    prologue like this:
    
    __Z3fooi:
    Leh_func_begin1:
    LBB1_0: ## entry
           pushl   %ebp
    Llabel1:
           movl    %esp, %ebp
    Llabel2:
           pushl   %esi
    Llabel3:
           subl    $20, %esp
           call    "L1$pb"
    "L1$pb":
           popl    %esi
    
    The "pushl %ebp" needs a table entry specifying the offset. The "movl %esp,
    %ebp" makes %ebp the new stack frame register, so that needs to be specified in
    DWARF. And "pushl %esi" saves the callee-saved %esi register, which also needs
    to be specified in DWARF.
    
    Before, all of this logic was in one method. This didn't work too well, because
    as you can see there are multiple FDE line entries that need to be created.
    
    This fix creates the "MachineMove" objects directly when they're needed; instead
    of waiting until the end, and losing information.
    
    There is some ugliness where we generate code like this:
    
    
    LBB22_0:	## entry
    	pushl	%ebp
    Llabel280:
    	movl	%esp, %ebp
    Llabel281:
    Llabel284:
    	pushl	%ebp  <----------
    	pushl	%ebx
    	pushl	%edi
    	pushl	%esi
    Llabel282:
    	subl	$328, %esp
    
    Notice the extra "pushl %ebp". If we generate a "machine move" instruction in
    the FDE for that pushl, the linker may get very confused about what value %ebp
    should have when exitting the function. I.e., it'll give it the value %esp
    instead of the %ebp value from the first "pushl". Not to mention that, in this
    case, %ebp isn't modified in the function (that's a separate bug). I put a small
    hack in to get it to work. It might be the only solution, but should be
    revisited once the above case is fixed.
    
    Modified:
        llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
        llvm/trunk/lib/Target/X86/X86RegisterInfo.h
    
    Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=75047&r1=75046&r2=75047&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
    +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Wed Jul  8 16:02:53 2009
    @@ -644,17 +644,20 @@
       return Offset;
     }
     
    -void X86RegisterInfo::emitFrameMoves(MachineFunction &MF,
    -                                     unsigned FrameLabelId,
    -                                     unsigned ReadyLabelId) const {
    +void X86RegisterInfo::emitCalleeSavedFrameMoves(MachineFunction &MF,
    +                                                unsigned LabelId,
    +                                                unsigned FramePtr) const {
       MachineFrameInfo *MFI = MF.getFrameInfo();
       MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
    -  if (!MMI)
    -    return;
    +  if (!MMI) return;
    +
    +  // Add callee saved registers to move list.
    +  const std::vector &CSI = MFI->getCalleeSavedInfo();
    +  if (CSI.empty()) return;
     
    -  uint64_t StackSize = MFI->getStackSize();
       std::vector &Moves = MMI->getFrameMoves();
       const TargetData *TD = MF.getTarget().getTargetData();
    +  bool HasFP = hasFP(MF);
     
       // Calculate amount of bytes used for return address storing
       int stackGrowth =
    @@ -662,62 +665,53 @@
          TargetFrameInfo::StackGrowsUp ?
          TD->getPointerSize() : -TD->getPointerSize());
     
    -  MachineLocation FPDst(hasFP(MF) ? FramePtr : StackPtr);
    -  MachineLocation FPSrc(MachineLocation::VirtualFP);
    -  Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc));
    -
    -  if (StackSize) {
    -    // Show update of SP.
    -    if (hasFP(MF)) {
    -      // Adjust SP
    -      MachineLocation SPDst(MachineLocation::VirtualFP);
    -      MachineLocation SPSrc(MachineLocation::VirtualFP, 2*stackGrowth);
    -      Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc));
    -    } else {
    -      MachineLocation SPDst(MachineLocation::VirtualFP);
    -      MachineLocation SPSrc(MachineLocation::VirtualFP,
    -                            -StackSize+stackGrowth);
    -      Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc));
    -    }
    -  } else {
    -    // FIXME: Verify & implement for FP
    -    MachineLocation SPDst(StackPtr);
    -    MachineLocation SPSrc(StackPtr, stackGrowth);
    -    Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc));
    -  }
    -
    -  // Add callee saved registers to move list.
    -  const std::vector &CSI = MFI->getCalleeSavedInfo();
    -
       // FIXME: This is dirty hack. The code itself is pretty mess right now.
       // It should be rewritten from scratch and generalized sometimes.
     
       // Determine maximum offset (minumum due to stack growth)
       int64_t MaxOffset = 0;
    -  for (unsigned I = 0, E = CSI.size(); I!=E; ++I)
    +  for (std::vector::const_iterator
    +         I = CSI.begin(), E = CSI.end(); I != E; ++I)
         MaxOffset = std::min(MaxOffset,
    -                         MFI->getObjectOffset(CSI[I].getFrameIdx()));
    +                         MFI->getObjectOffset(I->getFrameIdx()));
    +
    +  // Calculate offsets.
    +  int64_t saveAreaOffset = (HasFP ? 3 : 2) * stackGrowth;
    +  for (std::vector::const_iterator
    +         I = CSI.begin(), E = CSI.end(); I != E; ++I) {
    +    int64_t Offset = MFI->getObjectOffset(I->getFrameIdx());
    +    unsigned Reg = I->getReg();
    +    Offset = MaxOffset - Offset + saveAreaOffset;
    +
    +    // Don't output a new machine move if we're re-saving the frame
    +    // pointer. This happens when the PrologEpilogInserter has inserted an extra
    +    // "PUSH" of the frame pointer -- the "emitPrologue" method automatically
    +    // generates one when frame pointers are used. If we generate a "machine
    +    // move" for this extra "PUSH", the linker will lose track of the fact that
    +    // the frame pointer should have the value of the first "PUSH" when it's
    +    // trying to unwind.
    +    // 
    +    // FIXME: This looks inelegant. It's possibly correct, but it's covering up
    +    //        another bug. I.e., one where we generate a prolog like this:
    +    //
    +    //          pushl  %ebp
    +    //          movl   %esp, %ebp
    +    //          pushl  %ebp
    +    //          pushl  %esi
    +    //           ...
    +    //
    +    //        The immediate re-push of EBP is unnecessary. At the least, it's an
    +    //        optimization bug. EBP can be used as a scratch register in certain
    +    //        cases, but probably not when we have a frame pointer.
    +    if (HasFP && FramePtr == Reg)
    +      continue;
     
    -  // Calculate offsets
    -  int64_t saveAreaOffset = (hasFP(MF) ? 3 : 2)*stackGrowth;
    -  for (unsigned I = 0, E = CSI.size(); I!=E; ++I) {
    -    int64_t Offset = MFI->getObjectOffset(CSI[I].getFrameIdx());
    -    unsigned Reg = CSI[I].getReg();
    -    Offset = (MaxOffset-Offset+saveAreaOffset);
         MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
         MachineLocation CSSrc(Reg);
    -    Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc));
    -  }
    -
    -  if (hasFP(MF)) {
    -    // Save FP
    -    MachineLocation FPDst(MachineLocation::VirtualFP, 2*stackGrowth);
    -    MachineLocation FPSrc(FramePtr);
    -    Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc));
    +    Moves.push_back(MachineMove(LabelId, CSDst, CSSrc));
       }
     }
     
    -
     void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
       MachineBasicBlock &MBB = MF.front();   // Prolog goes in entry BB
       MachineFrameInfo *MFI = MF.getFrameInfo();
    @@ -729,11 +723,9 @@
       bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) ||
                               !Fn->doesNotThrow() ||
                               UnwindTablesMandatory;
    +  bool HasFP = hasFP(MF);
       DebugLoc DL;
     
    -  // Prepare for frame info.
    -  unsigned FrameLabelId = 0;
    -
       // Get the number of bytes to allocate from the FrameInfo.
       uint64_t StackSize = MFI->getStackSize();
     
    @@ -757,7 +749,7 @@
           !MFI->hasCalls() &&                          // No calls.
           !Subtarget->isTargetWin64()) {               // Win64 has no Red Zone
         uint64_t MinSize = X86FI->getCalleeSavedFrameSize();
    -    if (hasFP(MF)) MinSize += SlotSize;
    +    if (HasFP) MinSize += SlotSize;
         StackSize = std::max(MinSize,
                              StackSize > 128 ? StackSize - 128 : 0);
         MFI->setStackSize(StackSize);
    @@ -774,8 +766,16 @@
         MI->getOperand(3).setIsDead();
       }
     
    +  //  uint64_t StackSize = MFI->getStackSize();
    +  std::vector &Moves = MMI->getFrameMoves();
    +  const TargetData *TD = MF.getTarget().getTargetData();
    +  int stackGrowth =
    +    (MF.getTarget().getFrameInfo()->getStackGrowthDirection() ==
    +     TargetFrameInfo::StackGrowsUp ?
    +     TD->getPointerSize() : -TD->getPointerSize());
    +
       uint64_t NumBytes = 0;
    -  if (hasFP(MF)) {
    +  if (HasFP) {
         // Calculate required stack adjustment
         uint64_t FrameSize = StackSize - SlotSize;
         if (needsStackRealignment(MF))
    @@ -783,19 +783,38 @@
     
         NumBytes = FrameSize - X86FI->getCalleeSavedFrameSize();
     
    -    // Get the offset of the stack slot for the EBP register... which is
    +    // Get the offset of the stack slot for the EBP register, which is
         // guaranteed to be the last slot by processFunctionBeforeFrameFinalized.
         // Update the frame offset adjustment.
         MFI->setOffsetAdjustment(-NumBytes);
     
    -    // Save EBP into the appropriate stack slot...
    +    // Save EBP/RBP into the appropriate stack slot...
         BuildMI(MBB, MBBI, DL, TII.get(Is64Bit ? X86::PUSH64r : X86::PUSH32r))
           .addReg(FramePtr, RegState::Kill);
     
         if (needsFrameMoves) {
           // Mark effective beginning of when frame pointer becomes valid.
    -      FrameLabelId = MMI->NextLabelID();
    +      unsigned FrameLabelId = MMI->NextLabelID();
           BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(FrameLabelId);
    +
    +      // Define the current CFA rule to use the provided offset.
    +      if (StackSize) {
    +        MachineLocation SPDst(MachineLocation::VirtualFP);
    +        MachineLocation SPSrc(MachineLocation::VirtualFP,
    +                              HasFP ? 2 * stackGrowth : 
    +                                      -StackSize + stackGrowth);
    +        Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc));
    +      } else {
    +        // FIXME: Verify & implement for FP
    +        MachineLocation SPDst(StackPtr);
    +        MachineLocation SPSrc(StackPtr, stackGrowth);
    +        Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc));
    +      }
    +
    +      // Change the rule for the FramePtr to be an "offset" rule.
    +      MachineLocation FPDst(MachineLocation::VirtualFP, 2 * stackGrowth);
    +      MachineLocation FPSrc(FramePtr);
    +      Moves.push_back(MachineMove(FrameLabelId, FPDst, FPSrc));
         }
     
         // Update EBP with the new base value...
    @@ -803,6 +822,16 @@
                 TII.get(Is64Bit ? X86::MOV64rr : X86::MOV32rr), FramePtr)
             .addReg(StackPtr);
     
    +    if (needsFrameMoves) {
    +      unsigned FrameLabelId = MMI->NextLabelID();
    +      BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(FrameLabelId);
    +
    +      // Define the current CFA to use the EBP/RBP register.
    +      MachineLocation FPDst(FramePtr);
    +      MachineLocation FPSrc(MachineLocation::VirtualFP);
    +      Moves.push_back(MachineMove(FrameLabelId, FPDst, FPSrc));
    +    }
    +
         // Mark the FramePtr as live-in in every block except the entry.
         for (MachineFunction::iterator I = next(MF.begin()), E = MF.end();
              I != E; ++I)
    @@ -814,6 +843,7 @@
             BuildMI(MBB, MBBI, DL,
                     TII.get(Is64Bit ? X86::AND64ri32 : X86::AND32ri),
                     StackPtr).addReg(StackPtr).addImm(-MaxAlign);
    +
           // The EFLAGS implicit def is dead.
           MI->getOperand(3).setIsDead();
         }
    @@ -822,10 +852,22 @@
       }
     
       // Skip the callee-saved push instructions.
    +  bool RegsSaved = false;
       while (MBBI != MBB.end() &&
              (MBBI->getOpcode() == X86::PUSH32r ||
    -          MBBI->getOpcode() == X86::PUSH64r))
    +          MBBI->getOpcode() == X86::PUSH64r)) {
    +    RegsSaved = true;
         ++MBBI;
    +  }
    +
    +  if (RegsSaved && needsFrameMoves) {
    +    // Mark end of callee-saved push instructions.
    +    unsigned LabelId = MMI->NextLabelID();
    +    BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(LabelId);
    +
    +    // Emit DWARF info specifying the offsets of the callee-saved registers.
    +    emitCalleeSavedFrameMoves(MF, LabelId, FramePtr);
    +  }
     
       if (MBBI != MBB.end())
         DL = MBBI->getDebugLoc();
    @@ -882,14 +924,6 @@
         if (NumBytes)
           emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit, TII);
       }
    -
    -  if (needsFrameMoves) {
    -    unsigned ReadyLabelId = 0;
    -    // Mark effective beginning of when frame pointer is ready.
    -    ReadyLabelId = MMI->NextLabelID();
    -    BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(ReadyLabelId);
    -    emitFrameMoves(MF, FrameLabelId, ReadyLabelId);
    -  }
     }
     
     void X86RegisterInfo::emitEpilogue(MachineFunction &MF,
    
    Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.h?rev=75047&r1=75046&r2=75047&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/X86/X86RegisterInfo.h (original)
    +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.h Wed Jul  8 16:02:53 2009
    @@ -136,12 +136,11 @@
       void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
                                                 RegScavenger *RS = NULL) const;
     
    +  void emitCalleeSavedFrameMoves(MachineFunction &MF, unsigned LabelId,
    +                                 unsigned FramePtr) const;
       void emitPrologue(MachineFunction &MF) const;
       void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
     
    -  void emitFrameMoves(MachineFunction &MF,
    -                      unsigned FrameLabelId, unsigned ReadyLabelId) const;
    -
       // Debug information queries.
       unsigned getRARegister() const;
       unsigned getFrameRegister(MachineFunction &MF) const;
    
    
    
    
    From evan.cheng at apple.com  Wed Jul  8 16:04:02 2009
    From: evan.cheng at apple.com (Evan Cheng)
    Date: Wed, 08 Jul 2009 21:04:02 -0000
    Subject: [llvm-commits] [llvm] r75048 - in /llvm/trunk/lib/Target/ARM:
     ARMAddressingModes.h ARMBaseInstrInfo.cpp ARMBaseRegisterInfo.cpp
     ARMCodeEmitter.cpp ARMISelDAGToDAG.cpp ARMInstrInfo.td ARMInstrThumb2.td
     ARMLoadStoreOptimizer.cpp AsmPrinter/ARMAsmPrinter.cpp
    Message-ID: <200907082104.n68L4262026850@zion.cs.uiuc.edu>
    
    Author: evancheng
    Date: Wed Jul  8 16:03:57 2009
    New Revision: 75048
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75048&view=rev
    Log:
    Change how so_imm and t2_so_imm are handled. At instruction selection time, the immediates are no longer encoded in the imm8 + rot format, that are left as it is. The encoding is now done in ams printing and code emission time instead.
    
    Modified:
        llvm/trunk/lib/Target/ARM/ARMAddressingModes.h
        llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
        llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp
        llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp
        llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
        llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
        llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td
        llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
        llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
    
    Modified: llvm/trunk/lib/Target/ARM/ARMAddressingModes.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAddressingModes.h?rev=75048&r1=75047&r2=75048&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMAddressingModes.h (original)
    +++ llvm/trunk/lib/Target/ARM/ARMAddressingModes.h Wed Jul  8 16:03:57 2009
    @@ -273,29 +273,6 @@
         return V >> getThumbImmValShift(V);
       }
     
    -  /// getT2SOImmValDecode - Given a 12-bit encoded Thumb-2 modified immediate,
    -  /// return the corresponding 32-bit immediate value.
    -  /// See ARM Reference Manual A6.3.2.
    -  static inline unsigned getT2SOImmValDecode(unsigned Imm) {
    -    unsigned Base = Imm & 0xff;
    -    switch ((Imm >> 8) & 0xf) {
    -    case 0:
    -      return Base;
    -    case 1:
    -      return Base | (Base << 16);
    -    case 2:
    -      return (Base << 8) | (Base << 24);
    -    case 3:
    -      return Base | (Base << 8) | (Base << 16) | (Base << 24);
    -    default:
    -      break;
    -    }
    -    
    -    // shifted immediate
    -    unsigned RotAmount = ((Imm >> 7) & 0x1f) - 8;
    -    return (Base | 0x80) << (24 - RotAmount);
    -  }
    -
       /// getT2SOImmValSplat - Return the 12-bit encoded representation
       /// if the specified value can be obtained by splatting the low 8 bits
       /// into every other byte or every byte of a 32-bit value. i.e.,
    
    Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=75048&r1=75047&r2=75048&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Wed Jul  8 16:03:57 2009
    @@ -91,15 +91,14 @@
         bool isSub = ARM_AM::getAM2Op(OffImm) == ARM_AM::sub;
         unsigned Amt = ARM_AM::getAM2Offset(OffImm);
         if (OffReg == 0) {
    -      int SOImmVal = ARM_AM::getSOImmVal(Amt);
    -      if (SOImmVal == -1)
    +      if (ARM_AM::getSOImmVal(Amt) == -1)
             // Can't encode it in a so_imm operand. This transformation will
             // add more than 1 instruction. Abandon!
             return NULL;
           UpdateMI = BuildMI(MF, MI->getDebugLoc(),
                              get(isSub ? getOpcode(ARMII::SUBri) :
                                  getOpcode(ARMII::ADDri)), WBReg)
    -        .addReg(BaseReg).addImm(SOImmVal)
    +        .addReg(BaseReg).addImm(Amt)
             .addImm(Pred).addReg(0).addReg(0);
         } else if (Amt != 0) {
           ARM_AM::ShiftOpc ShOpc = ARM_AM::getAM2ShiftOpc(OffImm);
    
    Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=75048&r1=75047&r2=75048&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Jul  8 16:03:57 2009
    @@ -942,13 +942,11 @@
         // We will handle these bits from offset, clear them.
         NumBytes &= ~ThisVal;
     
    -    // Get the properly encoded SOImmVal field.
    -    int SOImmVal = ARM_AM::getSOImmVal(ThisVal);
    -    assert(SOImmVal != -1 && "Bit extraction didn't work?");
    +    assert(ARM_AM::getSOImmVal(ThisVal) != -1 && "Bit extraction didn't work?");
     
         // Build the new ADD / SUB.
         BuildMI(MBB, MBBI, dl, TII.get(TII.getOpcode(isSub ? ARMII::SUBri : ARMII::ADDri)), DestReg)
    -      .addReg(BaseReg, RegState::Kill).addImm(SOImmVal)
    +      .addReg(BaseReg, RegState::Kill).addImm(ThisVal)
           .addImm((unsigned)Pred).addReg(PredReg).addReg(0);
         BaseReg = DestReg;
       }
    @@ -1071,11 +1069,10 @@
         }
     
         // Common case: small offset, fits into instruction.
    -    int ImmedOffset = ARM_AM::getSOImmVal(Offset);
    -    if (ImmedOffset != -1) {
    +    if (ARM_AM::getSOImmVal(Offset) != -1) {
           // Replace the FrameIndex with sp / fp
           MI.getOperand(i).ChangeToRegister(FrameReg, false);
    -      MI.getOperand(i+1).ChangeToImmediate(ImmedOffset);
    +      MI.getOperand(i+1).ChangeToImmediate(Offset);
           return;
         }
     
    @@ -1089,9 +1086,9 @@
         Offset &= ~ThisImmVal;
     
         // Get the properly encoded SOImmVal field.
    -    int ThisSOImmVal = ARM_AM::getSOImmVal(ThisImmVal);
    -    assert(ThisSOImmVal != -1 && "Bit extraction didn't work?");
    -    MI.getOperand(i+1).ChangeToImmediate(ThisSOImmVal);
    +    assert(ARM_AM::getSOImmVal(ThisImmVal) != -1 &&
    +           "Bit extraction didn't work?");
    +    MI.getOperand(i+1).ChangeToImmediate(ThisImmVal);
       } else {
         unsigned ImmIdx = 0;
         int InstrOffs = 0;
    
    Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=75048&r1=75047&r2=75048&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Wed Jul  8 16:03:57 2009
    @@ -470,7 +470,8 @@
     void Emitter::emitMOVi2piecesInstruction(const MachineInstr &MI) {
       const MachineOperand &MO0 = MI.getOperand(0);
       const MachineOperand &MO1 = MI.getOperand(1);
    -  assert(MO1.isImm() && "Not a valid so_imm value!");
    +  assert(MO1.isImm() && ARM_AM::getSOImmVal(MO1.isImm()) != -1 &&
    +                                            "Not a valid so_imm value!");
       unsigned V1 = ARM_AM::getSOImmTwoPartFirst(MO1.getImm());
       unsigned V2 = ARM_AM::getSOImmTwoPartSecond(MO1.getImm());
     
    @@ -486,7 +487,7 @@
       // Encode so_imm.
       // Set bit I(25) to identify this is the immediate form of 
       Binary |= 1 << ARMII::I_BitShift;
    -  Binary |= getMachineSoImmOpValue(ARM_AM::getSOImmVal(V1));
    +  Binary |= getMachineSoImmOpValue(V1);
       emitWordLE(Binary);
     
       // Now the 'orr' instruction.
    @@ -504,7 +505,7 @@
       // Encode so_imm.
       // Set bit I(25) to identify this is the immediate form of 
       Binary |= 1 << ARMII::I_BitShift;
    -  Binary |= getMachineSoImmOpValue(ARM_AM::getSOImmVal(V2));
    +  Binary |= getMachineSoImmOpValue(V2);
       emitWordLE(Binary);
     }
     
    @@ -714,12 +715,15 @@
     
     template
     unsigned Emitter::getMachineSoImmOpValue(unsigned SoImm) {
    +  int SoImmVal = ARM_AM::getSOImmVal(SoImm);
    +  assert(SoImmVal != -1 && "Not a valid so_imm value!");
    +
       // Encode rotate_imm.
    -  unsigned Binary = (ARM_AM::getSOImmValRot(SoImm) >> 1)
    +  unsigned Binary = (ARM_AM::getSOImmValRot((unsigned)SoImmVal) >> 1)
         << ARMII::SoRotImmShift;
     
       // Encode immed_8.
    -  Binary |= ARM_AM::getSOImmValImm(SoImm);
    +  Binary |= ARM_AM::getSOImmValImm((unsigned)SoImmVal);
       return Binary;
     }
     
    @@ -796,8 +800,7 @@
       }
     
       // Encode so_imm.
    -  Binary |= 1 << ARMII::I_BitShift;
    -  Binary |= getMachineSoImmOpValue(MO.getImm());
    +  Binary |= getMachineSoImmOpValue((unsigned)MO.getImm());
     
       emitWordLE(Binary);
     }
    
    Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=75048&r1=75047&r2=75048&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Jul  8 16:03:57 2009
    @@ -1071,10 +1071,10 @@
           }
     
           // Pattern: (ARMcmov:i32 GPR:i32:$false,
    -      //             (imm:i32)<><>:$true,
    +      //             (imm:i32)<>:$true,
           //             (imm:i32):$cc)
           // Emits: (MOVCCi:i32 GPR:i32:$false,
    -      //           (so_imm_XFORM:i32 (imm:i32):$true), (imm:i32):$cc)
    +      //           (so_imm:i32 (imm:i32):$true), (imm:i32):$cc)
           // Pattern complexity = 10  cost = 1  size = 0
           if (N3.getOpcode() == ISD::Constant) {
             if (Subtarget->isThumb()) {
    @@ -1082,7 +1082,6 @@
                 SDValue Tmp1 = CurDAG->getTargetConstant(((unsigned)
                                          cast(N1)->getZExtValue()),
                                          MVT::i32);
    -            Tmp1 = Transform_t2_so_imm_XFORM(Tmp1.getNode());
                 SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned)
                                          cast(N2)->getZExtValue()),
                                          MVT::i32);
    @@ -1095,7 +1094,6 @@
                 SDValue Tmp1 = CurDAG->getTargetConstant(((unsigned)
                                          cast(N1)->getZExtValue()),
                                          MVT::i32);
    -            Tmp1 = Transform_so_imm_XFORM(Tmp1.getNode());
                 SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned)
                                          cast(N2)->getZExtValue()),
                                          MVT::i32);
    
    Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=75048&r1=75047&r2=75048&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original)
    +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Jul  8 16:03:57 2009
    @@ -118,25 +118,16 @@
     //  ARM specific transformation functions and pattern fragments.
     //
     
    -// so_imm_XFORM - Return a so_imm value packed into the format described for
    -// so_imm def below.
    -def so_imm_XFORM : SDNodeXFormgetTargetConstant(ARM_AM::getSOImmVal(N->getZExtValue()),
    -                                   MVT::i32);
    -}]>;
    -
     // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
     // so_imm_neg def below.
     def so_imm_neg_XFORM : SDNodeXFormgetTargetConstant(ARM_AM::getSOImmVal(-(int)N->getZExtValue()),
    -                                   MVT::i32);
    +  return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
     }]>;
     
     // so_imm_not_XFORM - Return a so_imm value packed into the format described for
     // so_imm_not def below.
     def so_imm_not_XFORM : SDNodeXFormgetTargetConstant(ARM_AM::getSOImmVal(~(int)N->getZExtValue()),
    -                                   MVT::i32);
    +  return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
     }]>;
     
     // rot_imm predicate - True if the 32-bit immediate is equal to 8, 16, or 24.
    @@ -234,9 +225,9 @@
     // into so_imm instructions: the 8-bit immediate is the least significant bits
     // [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
     def so_imm : Operand,
    -             PatLeaf<(imm),
    -                     [{ return ARM_AM::getSOImmVal(N->getZExtValue()) != -1; }],
    -                     so_imm_XFORM> {
    +             PatLeaf<(imm), [{
    +      return ARM_AM::getSOImmVal(N->getZExtValue()) != -1;
    +    }]> {
       let PrintMethod = "printSOImmOperand";
     }
     
    @@ -252,12 +243,12 @@
     
     def so_imm2part_1 : SDNodeXFormgetZExtValue());
    -  return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
    +  return CurDAG->getTargetConstant(V, MVT::i32);
     }]>;
     
     def so_imm2part_2 : SDNodeXFormgetZExtValue());
    -  return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
    +  return CurDAG->getTargetConstant(V, MVT::i32);
     }]>;
     
     
    @@ -1440,11 +1431,11 @@
                              [(set GPR:$dst, so_imm2part:$src)]>;
     
     def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
    -              (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
    -                     (so_imm2part_2 imm:$RHS))>;
    +             (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
    +                    (so_imm2part_2 imm:$RHS))>;
     def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
    -              (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
    -                     (so_imm2part_2 imm:$RHS))>;
    +             (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
    +                    (so_imm2part_2 imm:$RHS))>;
     
     // TODO: add,sub,and, 3-instr forms?
     
    
    Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=75048&r1=75047&r2=75048&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original)
    +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Wed Jul  8 16:03:57 2009
    @@ -20,23 +20,14 @@
       let MIOperandInfo = (ops GPR, i32imm);
     }
     
    -// t2_so_imm_XFORM - Return a t2_so_imm value packed into the format 
    -// described for t2_so_imm def below.
    -def t2_so_imm_XFORM : SDNodeXFormgetTargetConstant(
    -        ARM_AM::getT2SOImmVal(N->getZExtValue()), MVT::i32);
    -}]>;
    -
     // t2_so_imm_not_XFORM - Return the complement of a t2_so_imm value
     def t2_so_imm_not_XFORM : SDNodeXFormgetTargetConstant(
    -        ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())), MVT::i32);
    +  return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
     }]>;
     
     // t2_so_imm_neg_XFORM - Return the negation of a t2_so_imm value
     def t2_so_imm_neg_XFORM : SDNodeXFormgetTargetConstant(
    -        ARM_AM::getT2SOImmVal(-((int)N->getZExtValue())), MVT::i32);
    +  return CurDAG->getTargetConstant(-((int)N->getZExtValue()), MVT::i32);
     }]>;
     
     // t2_so_imm - Match a 32-bit immediate operand, which is an
    @@ -47,27 +38,21 @@
     // [bits 0-7], the 4-bit shift/splat amount is the next 4 bits [bits 8-11].
     def t2_so_imm : Operand,
                     PatLeaf<(imm), [{
    -       return ARM_AM::getT2SOImmVal((uint32_t)N->getZExtValue()) != -1;
    -     }], t2_so_imm_XFORM> {
    -  let PrintMethod = "printT2SOImmOperand";
    -}
    +  return ARM_AM::getT2SOImmVal((uint32_t)N->getZExtValue()) != -1; 
    +}]>;
     
     // t2_so_imm_not - Match an immediate that is a complement 
     // of a t2_so_imm.
     def t2_so_imm_not : Operand,
                         PatLeaf<(imm), [{
    -       return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1;
    -     }], t2_so_imm_not_XFORM> {
    -  let PrintMethod = "printT2SOImmOperand";
    -}
    +  return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1;
    +}], t2_so_imm_not_XFORM>;
     
     // t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
     def t2_so_imm_neg : Operand,
                         PatLeaf<(imm), [{
    -       return ARM_AM::getT2SOImmVal(-((int)N->getZExtValue())) != -1;
    -     }], t2_so_imm_neg_XFORM> {
    -  let PrintMethod = "printT2SOImmOperand";
    -}
    +  return ARM_AM::getT2SOImmVal(-((int)N->getZExtValue())) != -1;
    +}], t2_so_imm_neg_XFORM>;
     
     /// imm1_31 predicate - True if the 32-bit immediate is in the range [1,31].
     def imm1_31 : PatLeaf<(i32 imm), [{
    
    Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=75048&r1=75047&r2=75048&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Wed Jul  8 16:03:57 2009
    @@ -171,12 +171,11 @@
           BaseOpc = ARM::SUBri;
           Offset = - Offset;
         }
    -    int ImmedOffset = ARM_AM::getSOImmVal(Offset);
    -    if (ImmedOffset == -1)
    +    if (ARM_AM::getSOImmVal(Offset) == -1)
           return false;  // Probably not worth it then.
     
         BuildMI(MBB, MBBI, dl, TII->get(BaseOpc), NewBase)
    -      .addReg(Base, getKillRegState(BaseKill)).addImm(ImmedOffset)
    +      .addReg(Base, getKillRegState(BaseKill)).addImm(Offset)
           .addImm(Pred).addReg(PredReg).addReg(0);
         Base = NewBase;
         BaseKill = true;  // New base is always killed right its use.
    
    Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=75048&r1=75047&r2=75048&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
    +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jul  8 16:03:57 2009
    @@ -119,7 +119,6 @@
         void printThumbAddrModeS4Operand(const MachineInstr *MI, int OpNum);
         void printThumbAddrModeSPOperand(const MachineInstr *MI, int OpNum);
     
    -    void printT2SOImmOperand(const MachineInstr *MI, int OpNum);
         void printT2SOOperand(const MachineInstr *MI, int OpNum);
         void printT2AddrModeImm12Operand(const MachineInstr *MI, int OpNum);
         void printT2AddrModeImm8Operand(const MachineInstr *MI, int OpNum);
    @@ -370,7 +369,10 @@
     
     static void printSOImm(raw_ostream &O, int64_t V, bool VerboseAsm,
                            const TargetAsmInfo *TAI) {
    -  assert(V < (1 << 12) && "Not a valid so_imm value!");
    +  // Break it up into two parts that make up a shifter immediate.
    +  V = ARM_AM::getSOImmVal(V);
    +  assert(V != -1 && "Not a valid so_imm value!");
    +
       unsigned Imm = ARM_AM::getSOImmValImm(V);
       unsigned Rot = ARM_AM::getSOImmValRot(V);
     
    @@ -402,7 +404,7 @@
       assert(MO.isImm() && "Not a valid so_imm value!");
       unsigned V1 = ARM_AM::getSOImmTwoPartFirst(MO.getImm());
       unsigned V2 = ARM_AM::getSOImmTwoPartSecond(MO.getImm());
    -  printSOImm(O, ARM_AM::getSOImmVal(V1), VerboseAsm, TAI);
    +  printSOImm(O, V1, VerboseAsm, TAI);
       O << "\n\torr";
       printPredicateOperand(MI, 2);
       O << " ";
    @@ -410,7 +412,7 @@
       O << ", ";
       printOperand(MI, 0); 
       O << ", ";
    -  printSOImm(O, ARM_AM::getSOImmVal(V2), VerboseAsm, TAI);
    +  printSOImm(O, V2, VerboseAsm, TAI);
     }
     
     // so_reg is a 4-operand unit corresponding to register forms of the A5.1
    @@ -687,20 +689,6 @@
     
     //===--------------------------------------------------------------------===//
     
    -/// printT2SOImmOperand - T2SOImm is:
    -///  1. a 4-bit splat control value and 8 bit immediate value
    -///  2. a 5-bit rotate amount and a non-zero 8-bit immediate value
    -///     represented by a normalizedin 7-bit value (msb is always 1)
    -void ARMAsmPrinter::printT2SOImmOperand(const MachineInstr *MI, int OpNum) {
    -  const MachineOperand &MO = MI->getOperand(OpNum);
    -  assert(MO.isImm() && "Not a valid so_imm value!");
    -
    -  unsigned Imm = ARM_AM::getT2SOImmValDecode(MO.getImm());  
    -  // Always print the immediate directly, as the "rotate" form
    -  // is deprecated in some contexts.
    -  O << "#" << Imm;
    -}
    -
     // Constant shifts t2_so_reg is a 2-operand unit corresponding to the Thumb2
     // register with shift forms.
     // REG 0   0           - e.g. R5
    
    
    
    
    From dag at cray.com  Wed Jul  8 16:09:05 2009
    From: dag at cray.com (David Greene)
    Date: Wed, 8 Jul 2009 16:09:05 -0500
    Subject: [llvm-commits] PATCH: remove VICmp and VFCmp.
    In-Reply-To: 
    References: <4A518899.80806@mxc.ca>
    	<05085D11-65C9-478A-B854-1EAC52FD9E42@apple.com>
    	
    Message-ID: <200907081609.06193.dag@cray.com>
    
    On Tuesday 07 July 2009 15:16, Chris Lattner wrote:
    
    > > Work has been one to support vector [fi]cmp in the IR, however no
    > > work has been done to support it in CodeGen yet. Adding support in
    > > CodeGen will require a variety of fairly straight-forward
    > > changes, plus finding a solution for vectors of i1 in CodeGen.
    >
    > I don't see a need to fix the "vector of i1" issue right now.  In
    > fact, I don't see an issue at all.
    >
    > There are two things we care about: making compare+sext turn into the
    > current nice code that v*cmp produces, and eventually handling compare
    > +select.  Both of these idioms are trivial enough that they could be
    > handled by pre-legalize dag combine, forming (e.g.) ISD::VSETCC
    > nodes.  Then legalize won't ever see vectors of i1 in code that we
    > care about.
    
    I haven't been tracking this, so can someone explain what the "vectors of
    i1 problem" is?  Is it a problem of how to generate code on architectures
    that don't have a mask concept?
    
    compare+select is not enough for architectures like Larrabee.  We are very
    soon going to want to support full vector predication, so it would seem like
    solving the vectors of i1 problem is moderately important.
    
                                    -Dave
    
    
    From baldrick at free.fr  Wed Jul  8 16:34:20 2009
    From: baldrick at free.fr (Duncan Sands)
    Date: Wed, 08 Jul 2009 21:34:20 -0000
    Subject: [llvm-commits] [llvm] r75050 - in
     /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeTypes.cpp LegalizeTypes.h
     LegalizeTypesGeneric.cpp LegalizeVectorTypes.cpp
    Message-ID: <200907082134.n68LYMd1027775@zion.cs.uiuc.edu>
    
    Author: baldrick
    Date: Wed Jul  8 16:34:03 2009
    New Revision: 75050
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75050&view=rev
    Log:
    Nowadays vectors are only split if they have an even
    number of elements.  Make some simplifications based
    on this (in particular SplitVecRes_SETCC).  Tighten
    up some checking while there.
    
    Modified:
        llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
        llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
        llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
        llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
    
    Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=75050&r1=75049&r2=75050&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original)
    +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Wed Jul  8 16:34:03 2009
    @@ -732,6 +732,8 @@
     }
     
     void DAGTypeLegalizer::SetPromotedInteger(SDValue Op, SDValue Result) {
    +  assert(Result.getValueType() == TLI.getTypeToTransformTo(Op.getValueType()) &&
    +         "Invalid type for promoted integer");
       AnalyzeNewValue(Result);
     
       SDValue &OpEntry = PromotedIntegers[Op];
    @@ -740,6 +742,8 @@
     }
     
     void DAGTypeLegalizer::SetSoftenedFloat(SDValue Op, SDValue Result) {
    +  assert(Result.getValueType() == TLI.getTypeToTransformTo(Op.getValueType()) &&
    +         "Invalid type for softened float");
       AnalyzeNewValue(Result);
     
       SDValue &OpEntry = SoftenedFloats[Op];
    @@ -748,6 +752,8 @@
     }
     
     void DAGTypeLegalizer::SetScalarizedVector(SDValue Op, SDValue Result) {
    +  assert(Result.getValueType() == Op.getValueType().getVectorElementType() &&
    +         "Invalid type for scalarized vector");
       AnalyzeNewValue(Result);
     
       SDValue &OpEntry = ScalarizedVectors[Op];
    @@ -767,6 +773,9 @@
     
     void DAGTypeLegalizer::SetExpandedInteger(SDValue Op, SDValue Lo,
                                               SDValue Hi) {
    +  assert(Lo.getValueType() == TLI.getTypeToTransformTo(Op.getValueType()) &&
    +         Hi.getValueType() == Lo.getValueType() &&
    +         "Invalid type for expanded integer");
       // Lo/Hi may have been newly allocated, if so, add nodeid's as relevant.
       AnalyzeNewValue(Lo);
       AnalyzeNewValue(Hi);
    @@ -790,6 +799,9 @@
     
     void DAGTypeLegalizer::SetExpandedFloat(SDValue Op, SDValue Lo,
                                             SDValue Hi) {
    +  assert(Lo.getValueType() == TLI.getTypeToTransformTo(Op.getValueType()) &&
    +         Hi.getValueType() == Lo.getValueType() &&
    +         "Invalid type for expanded float");
       // Lo/Hi may have been newly allocated, if so, add nodeid's as relevant.
       AnalyzeNewValue(Lo);
       AnalyzeNewValue(Hi);
    @@ -813,6 +825,12 @@
     
     void DAGTypeLegalizer::SetSplitVector(SDValue Op, SDValue Lo,
                                           SDValue Hi) {
    +  assert(Lo.getValueType().getVectorElementType() ==
    +         Op.getValueType().getVectorElementType() &&
    +         2*Lo.getValueType().getVectorNumElements() ==
    +         Op.getValueType().getVectorNumElements() &&
    +         Hi.getValueType() == Lo.getValueType() &&
    +         "Invalid type for split vector");
       // Lo/Hi may have been newly allocated, if so, add nodeid's as relevant.
       AnalyzeNewValue(Lo);
       AnalyzeNewValue(Hi);
    @@ -825,6 +843,8 @@
     }
     
     void DAGTypeLegalizer::SetWidenedVector(SDValue Op, SDValue Result) {
    +  assert(Result.getValueType() == TLI.getTypeToTransformTo(Op.getValueType()) &&
    +         "Invalid type for widened vector");
       AnalyzeNewValue(Result);
     
       SDValue &OpEntry = WidenedVectors[Op];
    @@ -901,20 +921,13 @@
     /// GetSplitDestVTs - Compute the VTs needed for the low/hi parts of a type
     /// which is split into two not necessarily identical pieces.
     void DAGTypeLegalizer::GetSplitDestVTs(MVT InVT, MVT &LoVT, MVT &HiVT) {
    +  // Currently all types are split in half.
       if (!InVT.isVector()) {
         LoVT = HiVT = TLI.getTypeToTransformTo(InVT);
       } else {
    -    MVT NewEltVT = InVT.getVectorElementType();
         unsigned NumElements = InVT.getVectorNumElements();
    -    if ((NumElements & (NumElements-1)) == 0) {  // Simple power of two vector.
    -      NumElements >>= 1;
    -      LoVT = HiVT =  MVT::getVectorVT(NewEltVT, NumElements);
    -    } else {                                     // Non-power-of-two vectors.
    -      unsigned NewNumElts_Lo = 1 << Log2_32(NumElements);
    -      unsigned NewNumElts_Hi = NumElements - NewNumElts_Lo;
    -      LoVT = MVT::getVectorVT(NewEltVT, NewNumElts_Lo);
    -      HiVT = MVT::getVectorVT(NewEltVT, NewNumElts_Hi);
    -    }
    +    assert(!(NumElements & 1) && "Splitting vector, but not in half!");
    +    LoVT = HiVT = MVT::getVectorVT(InVT.getVectorElementType(), NumElements/2);
       }
     }
     
    
    Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=75050&r1=75049&r2=75050&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original)
    +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Wed Jul  8 16:34:03 2009
    @@ -64,7 +64,7 @@
         SoftenFloat,     // Convert this float type to a same size integer type.
         ExpandFloat,     // Split this float type into two of half the size.
         ScalarizeVector, // Replace this one-element vector with its element type.
    -    SplitVector,     // This vector type should be split into smaller vectors.
    +    SplitVector,     // Split this vector type into two of half the size.
         WidenVector      // This vector type should be widened into a larger vector.
       };
     
    @@ -533,8 +533,8 @@
       // Vector Splitting Support: LegalizeVectorTypes.cpp
       //===--------------------------------------------------------------------===//
     
    -  /// GetSplitVector - Given a processed vector Op which was split into smaller
    -  /// vectors, this method returns the smaller vectors.  The first elements of
    +  /// GetSplitVector - Given a processed vector Op which was split into vectors
    +  /// of half the size, this method returns the halves.  The first elements of
       /// Op coincide with the elements of Lo; the remaining elements of Op coincide
       /// with the elements of Hi: Op is what you would get by concatenating Lo and
       /// Hi.  For example, if Op is a v8i32 that was split into two v4i32's, then
    
    Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp?rev=75050&r1=75049&r2=75050&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp (original)
    +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Wed Jul  8 16:34:03 2009
    @@ -11,9 +11,11 @@
     // The routines here perform legalization when the details of the type (such as
     // whether it is an integer or a float) do not matter.
     // Expansion is the act of changing a computation in an illegal type to be a
    -// computation in two identical registers of a smaller type.
    +// computation in two identical registers of a smaller type.  The Lo/Hi part
    +// is required to be stored first in memory on little/big-endian machines.
     // Splitting is the act of changing a computation in an illegal type to be a
     // computation in two not necessarily identical registers of a smaller type.
    +// There are no requirements on how the type is represented in memory.
     //
     //===----------------------------------------------------------------------===//
     
    @@ -59,16 +61,12 @@
           Hi = DAG.getNode(ISD::BIT_CONVERT, dl, NOutVT, Hi);
           return;
         case SplitVector:
    -      // Convert the split parts of the input if it was split in two.
           GetSplitVector(InOp, Lo, Hi);
    -      if (Lo.getValueType() == Hi.getValueType()) {
    -        if (TLI.isBigEndian())
    -          std::swap(Lo, Hi);
    -        Lo = DAG.getNode(ISD::BIT_CONVERT, dl, NOutVT, Lo);
    -        Hi = DAG.getNode(ISD::BIT_CONVERT, dl, NOutVT, Hi);
    -        return;
    -      }
    -      break;
    +      if (TLI.isBigEndian())
    +        std::swap(Lo, Hi);
    +      Lo = DAG.getNode(ISD::BIT_CONVERT, dl, NOutVT, Lo);
    +      Hi = DAG.getNode(ISD::BIT_CONVERT, dl, NOutVT, Hi);
    +      return;
         case ScalarizeVector:
           // Convert the element instead.
           SplitInteger(BitConvertToInteger(GetScalarizedVector(InOp)), Lo, Hi);
    
    Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=75050&r1=75049&r2=75050&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original)
    +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Wed Jul  8 16:34:03 2009
    @@ -15,8 +15,8 @@
     // eventually decomposes to scalars if the target doesn't support v4f32 or v2f32
     // types.
     // Splitting is the act of changing a computation in an invalid vector type to
    -// be a computation in multiple vectors of a smaller type.  For example,
    -// implementing <128 x f32> operations in terms of two <64 x f32> operations.
    +// be a computation in two vectors of half the size.  For example, implementing
    +// <128 x f32> operations in terms of two <64 x f32> operations.
     //
     //===----------------------------------------------------------------------===//
     
    @@ -575,7 +575,6 @@
       switch (getTypeAction(InVT)) {
       default: assert(0 && "Unexpected type action!");
       case Legal: {
    -    assert(LoVT == HiVT && "Legal non-power-of-two vector type?");
         MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(),
                                      LoVT.getVectorNumElements());
         VLo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, N->getOperand(0),
    @@ -591,7 +590,6 @@
         // If the result needs to be split and the input needs to be widened,
         // the two types must have different lengths. Use the widened result
         // and extract from it to do the split.
    -    assert(LoVT == HiVT && "Legal non-power-of-two vector type?");
         SDValue InOp = GetWidenedVector(N->getOperand(0));
         MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(),
                                      LoVT.getVectorNumElements());
    @@ -621,9 +619,6 @@
     
       MVT LoVT, HiVT;
       GetSplitDestVTs(N->getValueType(0), LoVT, HiVT);
    -  // The indices are not guaranteed to be a multiple of the new vector
    -  // size unless the original vector type was split in two.
    -  assert(LoVT == HiVT && "Non power-of-two vectors not supported!");
     
       Lo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, LoVT, Vec, Idx);
       Idx = DAG.getNode(ISD::ADD, dl, IdxVT, Idx,
    @@ -743,29 +738,17 @@
       // Split the input.
       MVT InVT = N->getOperand(0).getValueType();
       SDValue LL, LH, RL, RH;
    -  switch (getTypeAction(InVT)) {
    -  default: assert(0 && "Unexpected type action!");
    -  case WidenVector: assert(0 && "Unimp");
    -  case Legal: {
    -    assert(LoVT == HiVT && "Legal non-power-of-two vector type?");
    -    MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(),
    -                                 LoVT.getVectorNumElements());
    -    LL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0),
    -                     DAG.getIntPtrConstant(0));
    -    LH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0),
    -                     DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
    -
    -    RL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1),
    -                     DAG.getIntPtrConstant(0));
    -    RH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1),
    -                     DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
    -    break;
    -  }
    -  case SplitVector:
    -    GetSplitVector(N->getOperand(0), LL, LH);
    -    GetSplitVector(N->getOperand(1), RL, RH);
    -    break;
    -  }
    +  MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(),
    +                               LoVT.getVectorNumElements());
    +  LL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0),
    +                   DAG.getIntPtrConstant(0));
    +  LH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0),
    +                   DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
    +
    +  RL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1),
    +                   DAG.getIntPtrConstant(0));
    +  RH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1),
    +                   DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
     
       Lo = DAG.getNode(N->getOpcode(), DL, LoVT, LL, RL, N->getOperand(2));
       Hi = DAG.getNode(N->getOpcode(), DL, HiVT, LH, RH, N->getOperand(2));
    @@ -783,7 +766,6 @@
       switch (getTypeAction(InVT)) {
       default: assert(0 && "Unexpected type action!");
       case Legal: {
    -    assert(LoVT == HiVT && "Legal non-power-of-two vector type?");
         MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(),
                                      LoVT.getVectorNumElements());
         Lo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, N->getOperand(0),
    @@ -799,7 +781,6 @@
         // If the result needs to be split and the input needs to be widened,
         // the two types must have different lengths. Use the widened result
         // and extract from it to do the split.
    -    assert(LoVT == HiVT && "Legal non-power-of-two vector type?");
         SDValue InOp = GetWidenedVector(N->getOperand(0));
         MVT InNVT = MVT::getVectorVT(InVT.getVectorElementType(),
                                      LoVT.getVectorNumElements());
    @@ -824,8 +805,6 @@
       GetSplitVector(N->getOperand(1), Inputs[2], Inputs[3]);
       MVT NewVT = Inputs[0].getValueType();
       unsigned NewElts = NewVT.getVectorNumElements();
    -  assert(NewVT == Inputs[1].getValueType() &&
    -         "Non power-of-two vectors not supported!");
     
       // If Lo or Hi uses elements from at most two of the four input vectors, then
       // express it as a vector shuffle of those two inputs.  Otherwise extract the
    @@ -992,8 +971,6 @@
       SDValue Lo, Hi;
       DebugLoc dl = N->getDebugLoc();
       GetSplitVector(N->getOperand(0), Lo, Hi);
    -  assert(Lo.getValueType() == Hi.getValueType() &&
    -         "Returns legal non-power-of-two vector type?");
       MVT InVT = Lo.getValueType();
     
       MVT OutVT = MVT::getVectorVT(ResVT.getVectorElementType(),
    
    
    
    
    From dpatel at apple.com  Wed Jul  8 16:44:25 2009
    From: dpatel at apple.com (Devang Patel)
    Date: Wed, 08 Jul 2009 21:44:25 -0000
    Subject: [llvm-commits] [llvm] r75053 - in /llvm/trunk:
     lib/VMCore/AsmWriter.cpp test/Feature/mdnode2.ll
     unittests/VMCore/MetadataTest.cpp
    Message-ID: <200907082144.n68LiQ7g028142@zion.cs.uiuc.edu>
    
    Author: dpatel
    Date: Wed Jul  8 16:44:25 2009
    New Revision: 75053
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75053&view=rev
    Log:
    Update SLotTracker to handle MDNode slots.
    Simplify MDNode printing.
    
    
    Modified:
        llvm/trunk/lib/VMCore/AsmWriter.cpp
        llvm/trunk/test/Feature/mdnode2.ll
        llvm/trunk/unittests/VMCore/MetadataTest.cpp
    
    Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=75053&r1=75052&r2=75053&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
    +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Wed Jul  8 16:44:25 2009
    @@ -466,35 +466,44 @@
     ///
     class SlotTracker {
     public:
    -  /// ValueMap - A mapping of Values to slot numbers
    +  /// ValueMap - A mapping of Values to slot numbers.
       typedef DenseMap ValueMap;
       
     private:  
    -  /// TheModule - The module for which we are holding slot numbers
    +  /// TheModule - The module for which we are holding slot numbers.
       const Module* TheModule;
       
    -  /// TheFunction - The function for which we are holding slot numbers
    +  /// TheFunction - The function for which we are holding slot numbers.
       const Function* TheFunction;
       bool FunctionProcessed;
       
    -  /// mMap - The TypePlanes map for the module level data
    +  /// TheMDNode - The MDNode for which we are holding slot numbers.
    +  const MDNode *TheMDNode;
    +
    +  /// mMap - The TypePlanes map for the module level data.
       ValueMap mMap;
       unsigned mNext;
       
    -  /// fMap - The TypePlanes map for the function level data
    +  /// fMap - The TypePlanes map for the function level data.
       ValueMap fMap;
       unsigned fNext;
       
    +  /// mdnMap - Map for MDNodes.
    +  ValueMap mdnMap;
    +  unsigned mdnNext;
     public:
       /// Construct from a module
       explicit SlotTracker(const Module *M);
       /// Construct from a function, starting out in incorp state.
       explicit SlotTracker(const Function *F);
    +  /// Construct from a mdnode.
    +  explicit SlotTracker(const MDNode *N);
     
       /// Return the slot number of the specified value in it's type
       /// plane.  If something is not in the SlotTracker, return -1.
       int getLocalSlot(const Value *V);
       int getGlobalSlot(const GlobalValue *V);
    +  int getMetadataSlot(const MDNode *N);
     
       /// If you'd like to deal with a function instead of just a module, use
       /// this method to get its data into the SlotTracker.
    @@ -508,14 +517,22 @@
       /// will reset the state of the machine back to just the module contents.
       void purgeFunction();
     
    -  // Implementation Details
    -private:
    +  /// MDNode map iterators.
    +  ValueMap::iterator mdnBegin() { return mdnMap.begin(); }
    +  ValueMap::iterator mdnEnd() { return mdnMap.end(); }
    +  unsigned mdnSize() { return mdnMap.size(); }
    +
       /// This function does the actual initialization.
       inline void initialize();
     
    +  // Implementation Details
    +private:
       /// CreateModuleSlot - Insert the specified GlobalValue* into the slot table.
       void CreateModuleSlot(const GlobalValue *V);
    -  
    +
    +  /// CreateMetadataSlot - Insert the specified MDNode* into the slot table.
    +  void CreateMetadataSlot(const MDNode *N);
    +
       /// CreateFunctionSlot - Insert the specified Value* into the slot table.
       void CreateFunctionSlot(const Value *V);
     
    @@ -523,9 +540,12 @@
       /// and function declarations, but not the contents of those functions.
       void processModule();
     
    -  /// Add all of the functions arguments, basic blocks, and instructions
    +  /// Add all of the functions arguments, basic blocks, and instructions.
       void processFunction();
     
    +  /// Add all MDNode operands.
    +  void processMDNode();
    +
       SlotTracker(const SlotTracker &);  // DO NOT IMPLEMENT
       void operator=(const SlotTracker &);  // DO NOT IMPLEMENT
     };
    @@ -564,14 +584,21 @@
     // Module level constructor. Causes the contents of the Module (sans functions)
     // to be added to the slot table.
     SlotTracker::SlotTracker(const Module *M)
    -  : TheModule(M), TheFunction(0), FunctionProcessed(false), mNext(0), fNext(0) {
    +  : TheModule(M), TheFunction(0), FunctionProcessed(false), TheMDNode(0),
    +    mNext(0), fNext(0),  mdnNext(0) {
     }
     
     // Function level constructor. Causes the contents of the Module and the one
     // function provided to be added to the slot table.
     SlotTracker::SlotTracker(const Function *F)
       : TheModule(F ? F->getParent() : 0), TheFunction(F), FunctionProcessed(false),
    -    mNext(0), fNext(0) {
    +    TheMDNode(0), mNext(0), fNext(0) {
    +}
    +
    +// Constructor to handle single MDNode.
    +SlotTracker::SlotTracker(const MDNode *C)
    +  : TheModule(0), TheFunction(0), FunctionProcessed(false), TheMDNode(C),
    +    mNext(0), fNext(0),  mdnNext(0) {
     }
     
     inline void SlotTracker::initialize() {
    @@ -582,6 +609,9 @@
       
       if (TheFunction && !FunctionProcessed)
         processFunction();
    +
    +  if (TheMDNode)
    +    processMDNode();
     }
     
     // Iterate through all the global variables, functions, and global
    @@ -591,9 +621,14 @@
       
       // Add all of the unnamed global variables to the value table.
       for (Module::const_global_iterator I = TheModule->global_begin(),
    -       E = TheModule->global_end(); I != E; ++I)
    +         E = TheModule->global_end(); I != E; ++I) {
         if (!I->hasName()) 
           CreateModuleSlot(I);
    +    if (I->hasInitializer()) {
    +      if (MDNode *N = dyn_cast(I->getInitializer())) 
    +        CreateMetadataSlot(N);
    +    }
    +  }
       
       // Add all the unnamed functions to the table.
       for (Module::const_iterator I = TheModule->begin(), E = TheModule->end();
    @@ -604,7 +639,6 @@
       ST_DEBUG("end processModule!\n");
     }
     
    -
     // Process the arguments, basic blocks, and instructions  of a function.
     void SlotTracker::processFunction() {
       ST_DEBUG("begin processFunction!\n");
    @@ -623,9 +657,14 @@
            E = TheFunction->end(); BB != E; ++BB) {
         if (!BB->hasName())
           CreateFunctionSlot(BB);
    -    for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
    +    for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; 
    +         ++I) {
           if (I->getType() != Type::VoidTy && !I->hasName())
             CreateFunctionSlot(I);
    +      for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) 
    +        if (MDNode *N = dyn_cast(I->getOperand(i))) 
    +          CreateMetadataSlot(N);
    +    }
       }
       
       FunctionProcessed = true;
    @@ -633,6 +672,15 @@
       ST_DEBUG("end processFunction!\n");
     }
     
    +/// processMDNode - Process TheMDNode.
    +void SlotTracker::processMDNode() {
    +  ST_DEBUG("begin processMDNode!\n");
    +  mdnNext = 0;
    +  CreateMetadataSlot(TheMDNode);
    +  TheMDNode = 0;
    +  ST_DEBUG("end processMDNode!\n");
    +}
    +
     /// Clean up after incorporating a function. This is the only way to get out of
     /// the function incorporation state that affects get*Slot/Create*Slot. Function
     /// incorporation state is indicated by TheFunction != 0.
    @@ -654,6 +702,16 @@
       return MI == mMap.end() ? -1 : (int)MI->second;
     }
     
    +/// getGlobalSlot - Get the slot number of a MDNode.
    +int SlotTracker::getMetadataSlot(const MDNode *N) {
    +  // Check for uninitialized state and do lazy initialization.
    +  initialize();
    +  
    +  // Find the type plane in the module map
    +  ValueMap::iterator MI = mdnMap.find(N);
    +  return MI == mdnMap.end() ? -1 : (int)MI->second;
    +}
    +
     
     /// getLocalSlot - Get the slot number for a value that is local to a function.
     int SlotTracker::getLocalSlot(const Value *V) {
    @@ -684,7 +742,6 @@
                  (isa(V) ? 'A' : 'o'))) << "]\n");
     }
     
    -
     /// CreateSlot - Create a new slot for the specified value if it has no name.
     void SlotTracker::CreateFunctionSlot(const Value *V) {
       assert(V->getType() != Type::VoidTy && !V->hasName() &&
    @@ -698,7 +755,25 @@
                DestSlot << " [o]\n");
     }  
     
    +/// CreateModuleSlot - Insert the specified MDNode* into the slot table.
    +void SlotTracker::CreateMetadataSlot(const MDNode *N) {
    +  assert(N && "Can't insert a null Value into SlotTracker!");
    +  
    +  ValueMap::iterator I = mdnMap.find(N);
    +  if (I != mdnMap.end())
    +    return;
    +
    +  unsigned DestSlot = mdnNext++;
    +  mdnMap[N] = DestSlot;
     
    +  for (MDNode::const_elem_iterator MDI = N->elem_begin(), 
    +         MDE = N->elem_end(); MDI != MDE; ++MDI) {
    +    const Value *TV = *MDI;
    +    if (TV)
    +      if (const MDNode *N2 = dyn_cast(TV)) 
    +        CreateMetadataSlot(N2);
    +  }
    +}
     
     //===----------------------------------------------------------------------===//
     // AsmWriter Implementation
    @@ -743,6 +818,39 @@
       return pred;
     }
     
    +static void WriteMDNodes(raw_ostream &Out, TypePrinting &TypePrinter,
    +                         SlotTracker &Machine) {
    +  SmallVector Nodes;
    +  Nodes.resize(Machine.mdnSize());
    +  for (SlotTracker::ValueMap::iterator I = 
    +         Machine.mdnBegin(), E = Machine.mdnEnd(); I != E; ++I) 
    +    Nodes[I->second] = cast(I->first);
    +
    +  for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
    +    Out << '!' << i << " = constant metadata ";
    +    const MDNode *Node = Nodes[i];
    +    Out << "!{";
    +    for (MDNode::const_elem_iterator NI = Node->elem_begin(), 
    +           NE = Node->elem_end(); NI != NE;) {
    +      const Value *V = *NI;
    +      if (!V)
    +        Out << "null";
    +      else if (const MDNode *N = dyn_cast(V)) {
    +        Out << "metadata ";
    +        Out << '!' << Machine.getMetadataSlot(N);
    +      }
    +      else {
    +        TypePrinter.print((*NI)->getType(), Out);
    +        Out << ' ';
    +        WriteAsOperandInternal(Out, *NI, TypePrinter, &Machine);
    +      }
    +      if (++NI != NE)
    +        Out << ", ";
    +    }
    +    Out << "}\n";
    +  }
    +}
    +
     static void WriteConstantInt(raw_ostream &Out, const Constant *CV,
                                  TypePrinting &TypePrinter, SlotTracker *Machine) {
       if (const ConstantInt *CI = dyn_cast(CV)) {
    @@ -948,6 +1056,11 @@
         return;
       }
     
    +  if (const MDNode *Node = dyn_cast(CV)) {
    +    Out << "!" << Machine->getMetadataSlot(Node);
    +    return;
    +  }
    +
       if (const ConstantExpr *CE = dyn_cast(CV)) {
         Out << CE->getOpcodeName();
         if (CE->isCompare())
    @@ -1105,7 +1218,6 @@
     
       void writeOperand(const Value *Op, bool PrintType);
       void writeParamOperand(const Value *Operand, Attributes Attrs);
    -  void printMDNode(const MDNode *Node, bool StandAlone);
     
       const Module* getModule() { return TheModule; }
     
    @@ -1216,6 +1328,8 @@
       // Output all of the functions.
       for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
         printFunction(I);
    +
    +  WriteMDNodes(Out, TypePrinter, Machine);
     }
     
     static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) {
    @@ -1252,28 +1366,6 @@
     }
     
     void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
    -  if (GV->hasInitializer())
    -    // If GV is initialized using Metadata then separate out metadata
    -    // operands used by the initializer. Note, MDNodes are not cyclic.
    -    if (MDNode *N = dyn_cast(GV->getInitializer())) {
    -      SmallVector WorkList;
    -      // Collect MDNodes used by the initializer.
    -      for (MDNode::const_elem_iterator I = N->elem_begin(), E = N->elem_end();
    -	   I != E; ++I) {
    -	const Value *TV = *I;
    -	if (TV)
    -	  if (const MDNode *NN = dyn_cast(TV))
    -	    WorkList.push_back(NN);
    -      }
    -
    -      // Print MDNodes used by the initializer.
    -      while (!WorkList.empty()) {
    -	const MDNode *N = WorkList.back(); WorkList.pop_back();
    -	printMDNode(N, true);
    -	Out << '\n';
    -      }
    -    }
    -
       if (GV->hasName()) {
         PrintLLVMName(Out, GV);
         Out << " = ";
    @@ -1293,10 +1385,7 @@
     
       if (GV->hasInitializer()) {
         Out << ' ';
    -    if (MDNode *N = dyn_cast(GV->getInitializer()))
    -      printMDNode(N, false);
    -    else
    -      writeOperand(GV->getInitializer(), false);
    +    writeOperand(GV->getInitializer(), false);
       }
         
       if (GV->hasSection())
    @@ -1308,47 +1397,6 @@
       Out << '\n';
     }
     
    -void AssemblyWriter::printMDNode(const MDNode *Node,
    -				 bool StandAlone) {
    -  std::map::iterator MI = MDNodes.find(Node);
    -  // If this node is already printed then just refer it using its Metadata
    -  // id number.
    -  if (MI != MDNodes.end()) {
    -    if (!StandAlone)
    -      Out << "!" << MI->second;
    -    return;
    -  }
    -  
    -  if (StandAlone) {
    -    // Print standalone MDNode.
    -    // !42 = !{ ... }
    -    Out << "!" << MetadataIDNo << " = ";
    -    Out << "constant metadata ";
    -  }
    -
    -  Out << "!{";
    -  for (MDNode::const_elem_iterator I = Node->elem_begin(), E = Node->elem_end();
    -       I != E;) {
    -    const Value *TV = *I;
    -    if (!TV)
    -      Out << "null";
    -    else if (const MDNode *N = dyn_cast(TV)) {
    -      TypePrinter.print(N->getType(), Out);
    -      Out << ' ';
    -      printMDNode(N, StandAlone);
    -    }
    -    else if (!*I)
    -      Out << "null";
    -    else 
    -      writeOperand(*I, true);
    -    if (++I != E)
    -      Out << ", ";
    -  }
    -  Out << "}";
    -
    -  MDNodes[Node] = MetadataIDNo++;
    -}
    -
     void AssemblyWriter::printAlias(const GlobalAlias *GA) {
       // Don't crash when dumping partially built GA
       if (!GA->hasName())
    @@ -1891,7 +1939,6 @@
         OS << "printing a  value\n";
         return;
       }
    -
       if (const Instruction *I = dyn_cast(this)) {
         const Function *F = I->getParent() ? I->getParent()->getParent() : 0;
         SlotTracker SlotTable(F);
    @@ -1907,13 +1954,10 @@
         AssemblyWriter W(OS, SlotTable, GV->getParent(), AAW);
         W.write(GV);
       } else if (const MDNode *N = dyn_cast(this)) {
    +    SlotTracker SlotTable(N);
         TypePrinting TypePrinter;
    -    TypePrinter.print(N->getType(), OS);
    -    OS << ' ';
    -    // FIXME: Do we need a slot tracker for metadata ?
    -    SlotTracker SlotTable((const Function *)NULL);
    -    AssemblyWriter W(OS, SlotTable, NULL, AAW);
    -    W.printMDNode(N, false);
    +    SlotTable.initialize();
    +    WriteMDNodes(OS, TypePrinter, SlotTable);
       } else if (const Constant *C = dyn_cast(this)) {
         TypePrinting TypePrinter;
         TypePrinter.print(C->getType(), OS);
    
    Modified: llvm/trunk/test/Feature/mdnode2.ll
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/mdnode2.ll?rev=75053&r1=75052&r2=75053&view=diff
    
    ==============================================================================
    --- llvm/trunk/test/Feature/mdnode2.ll (original)
    +++ llvm/trunk/test/Feature/mdnode2.ll Wed Jul  8 16:44:25 2009
    @@ -1,7 +1,8 @@
    +; Test standalone metadata
     ; RUN: llvm-as < %s | llvm-dis > %t.ll
    -; RUN: grep "!0 = constant metadata !{i32 21, i32 22}" %t.ll
    -; RUN: grep "!1 = constant metadata !{i32 23, i32 24}" %t.ll
    -; RUN: grep "@llvm.blah = constant metadata !{i32 1000, i16 200, metadata !1, metadata !0}" %t.ll
    +; RUN: grep "metadata !{i32 21, i32 22}" %t.ll
    +; RUN: grep "metadata !{i32 23, i32 24}" %t.ll
    +
     !0 = constant metadata !{i32 21, i32 22}
     !1 = constant metadata !{i32 23, i32 24}
     @llvm.blah = constant metadata !{i32 1000, i16 200, metadata !1, metadata !0}
    
    Modified: llvm/trunk/unittests/VMCore/MetadataTest.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/MetadataTest.cpp?rev=75053&r1=75052&r2=75053&view=diff
    
    ==============================================================================
    --- llvm/trunk/unittests/VMCore/MetadataTest.cpp (original)
    +++ llvm/trunk/unittests/VMCore/MetadataTest.cpp Wed Jul  8 16:44:25 2009
    @@ -94,10 +94,10 @@
       std::ostringstream oss1, oss2;
       n1->print(oss1);
       n2->print(oss2);
    -  EXPECT_STREQ("metadata !{metadata !\"abc\", i8 0, metadata !\"123\"}",
    +  EXPECT_STREQ("!0 = constant metadata !{metadata !\"abc\", i8 0, metadata !\"123\"}\n",
                    oss1.str().c_str());
    -  EXPECT_STREQ("metadata !{metadata !{metadata !\"abc\", i8 0, "
    -                                     "metadata !\"123\"}}",
    +  EXPECT_STREQ("!0 = constant metadata !{metadata !1}\n"
    +               "!1 = constant metadata !{metadata !\"abc\", i8 0, metadata !\"123\"}\n",
                    oss2.str().c_str());
     }
     
    @@ -134,6 +134,6 @@
     
       std::ostringstream oss;
       wvh->print(oss);
    -  EXPECT_STREQ("metadata !{null}", oss.str().c_str());
    +  EXPECT_STREQ("!0 = constant metadata !{null}\n", oss.str().c_str());
     }
     }
    
    
    
    
    From greened at obbligato.org  Wed Jul  8 16:46:41 2009
    From: greened at obbligato.org (David Greene)
    Date: Wed, 08 Jul 2009 21:46:41 -0000
    Subject: [llvm-commits] [llvm] r75055 - in /llvm/trunk:
     include/llvm/System/Program.h lib/System/Unix/Program.inc
     lib/System/Win32/Program.inc
    Message-ID: <200907082146.n68LkfGv028251@zion.cs.uiuc.edu>
    
    Author: greened
    Date: Wed Jul  8 16:46:40 2009
    New Revision: 75055
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75055&view=rev
    Log:
    
    Add an ExecuteNoWait interface to support asynchronous process spawning.
    
    Modified:
        llvm/trunk/include/llvm/System/Program.h
        llvm/trunk/lib/System/Unix/Program.inc
        llvm/trunk/lib/System/Win32/Program.inc
    
    Modified: llvm/trunk/include/llvm/System/Program.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Program.h?rev=75055&r1=75054&r2=75055&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/System/Program.h (original)
    +++ llvm/trunk/include/llvm/System/Program.h Wed Jul  8 16:46:40 2009
    @@ -87,6 +87,43 @@
           static bool ChangeStdinToBinary();
           static bool ChangeStdoutToBinary();
         /// @}
    +
    +     /// This function executes the program using the \p arguments provided and
    +     /// waits for the program to exit. This function will block the current
    +     /// program until the invoked program exits. The invoked program will
    +     /// inherit the stdin, stdout, and stderr file descriptors, the
    +     /// environment and other configuration settings of the invoking program.
    +     /// If Path::executable() does not return true when this function is
    +     /// called then a std::string is thrown.
    +     /// @returns an integer result code indicating the status of the program.
    +     /// A zero or positive value indicates the result code of the program. A
    +     /// negative value is the signal number on which it terminated. 
    +     /// @see FindProgrambyName
    +     /// @brief Executes the program with the given set of \p args.
    +     static void ExecuteNoWait(
    +        const Path& path,  ///< sys::Path object providing the path of the 
    +        ///< program to be executed. It is presumed this is the result of 
    +        ///< the FindProgramByName method.
    +        const char** args, ///< A vector of strings that are passed to the
    +        ///< program.  The first element should be the name of the program.
    +        ///< The list *must* be terminated by a null char* entry.
    +        const char ** env = 0, ///< An optional vector of strings to use for
    +        ///< the program's environment. If not provided, the current program's
    +        ///< environment will be used.
    +        const sys::Path** redirects = 0, ///< An optional array of pointers to
    +        ///< Paths. If the array is null, no redirection is done. The array
    +        ///< should have a size of at least three. If the pointer in the array
    +        ///< are not null, then the inferior process's stdin(0), stdout(1),
    +        ///< and stderr(2) will be redirected to the corresponding Paths.
    +        unsigned memoryLimit = 0, ///< If non-zero, this specifies max. amount
    +        ///< of memory can be allocated by process. If memory usage will be
    +        ///< higher limit, the child is killed and this call returns. If zero -
    +        ///< no memory limit.
    +        std::string* ErrMsg = 0 ///< If non-zero, provides a pointer to a string
    +        ///< instance in which error messages will be returned. If the string 
    +        ///< is non-empty upon return an error occurred while invoking the
    +        ///< program.
    +        );
       };
     }
     }
    
    Modified: llvm/trunk/lib/System/Unix/Program.inc
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Program.inc?rev=75055&r1=75054&r2=75055&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/System/Unix/Program.inc (original)
    +++ llvm/trunk/lib/System/Unix/Program.inc Wed Jul  8 16:46:40 2009
    @@ -274,6 +274,78 @@
         
     }
     
    +void
    +Program::ExecuteNoWait(const Path& path, 
    +                       const char** args,
    +                       const char** envp,
    +                       const Path** redirects,
    +                       unsigned memoryLimit,
    +                       std::string* ErrMsg) 
    +{
    +  if (!path.canExecute()) {
    +    if (ErrMsg)
    +      *ErrMsg = path.toString() + " is not executable";
    +    return;
    +  }
    +
    +  // Create a child process.
    +  int child = fork();
    +  switch (child) {
    +    // An error occured:  Return to the caller.
    +    case -1:
    +      MakeErrMsg(ErrMsg, "Couldn't fork");
    +      return;
    +
    +    // Child process: Execute the program.
    +    case 0: {
    +      // Redirect file descriptors...
    +      if (redirects) {
    +        // Redirect stdin
    +        if (RedirectIO(redirects[0], 0, ErrMsg)) { return; }
    +        // Redirect stdout
    +        if (RedirectIO(redirects[1], 1, ErrMsg)) { return; }
    +        if (redirects[1] && redirects[2] && 
    +            *(redirects[1]) == *(redirects[2])) {
    +          // If stdout and stderr should go to the same place, redirect stderr
    +          // to the FD already open for stdout.
    +          if (-1 == dup2(1,2)) {
    +            MakeErrMsg(ErrMsg, "Can't redirect stderr to stdout");
    +            return;
    +          }
    +        } else {
    +          // Just redirect stderr
    +          if (RedirectIO(redirects[2], 2, ErrMsg)) { return; }
    +        }
    +      }
    +
    +      // Set memory limits
    +      if (memoryLimit!=0) {
    +        SetMemoryLimits(memoryLimit);
    +      }
    +      
    +      // Execute!
    +      if (envp != 0)
    +        execve (path.c_str(), (char**)args, (char**)envp);
    +      else
    +        execv (path.c_str(), (char**)args);
    +      // If the execve() failed, we should exit and let the parent pick up
    +      // our non-zero exit status.
    +      exit (errno);
    +    }
    +
    +    // Parent process: Break out of the switch to do our processing.
    +    default:
    +      break;
    +  }
    +
    +  // Make sure stderr and stdout have been flushed
    +  std::cerr << std::flush;
    +  std::cout << std::flush;
    +  fsync(1);
    +  fsync(2);
    +
    +}
    +
     bool Program::ChangeStdinToBinary(){
       // Do nothing, as Unix doesn't differentiate between text and binary.
       return false;
    
    Modified: llvm/trunk/lib/System/Win32/Program.inc
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Program.inc?rev=75055&r1=75054&r2=75055&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/System/Win32/Program.inc (original)
    +++ llvm/trunk/lib/System/Win32/Program.inc Wed Jul  8 16:46:40 2009
    @@ -303,6 +303,171 @@
       return status;
     }
     
    +void
    +Program::ExecuteNoWait(const Path& path,
    +                       const char** args,
    +                       const char** envp,
    +                       const Path** redirects,
    +                       unsigned memoryLimit,
    +                       std::string* ErrMsg) {
    +  if (!path.canExecute()) {
    +    if (ErrMsg)
    +      *ErrMsg = "program not executable";
    +    return;
    +  }
    +
    +  // Windows wants a command line, not an array of args, to pass to the new
    +  // process.  We have to concatenate them all, while quoting the args that
    +  // have embedded spaces.
    +
    +  // First, determine the length of the command line.
    +  unsigned len = 0;
    +  for (unsigned i = 0; args[i]; i++) {
    +    len += strlen(args[i]) + 1;
    +    if (strchr(args[i], ' '))
    +      len += 2;
    +  }
    +
    +  // Now build the command line.
    +  char *command = reinterpret_cast(_alloca(len+1));
    +  char *p = command;
    +
    +  for (unsigned i = 0; args[i]; i++) {
    +    const char *arg = args[i];
    +    size_t len = strlen(arg);
    +    bool needsQuoting = strchr(arg, ' ') != 0;
    +    if (needsQuoting)
    +      *p++ = '"';
    +    memcpy(p, arg, len);
    +    p += len;
    +    if (needsQuoting)
    +      *p++ = '"';
    +    *p++ = ' ';
    +  }
    +
    +  *p = 0;
    +
    +  // The pointer to the environment block for the new process.
    +  char *envblock = 0;
    +
    +  if (envp) {
    +    // An environment block consists of a null-terminated block of
    +    // null-terminated strings. Convert the array of environment variables to
    +    // an environment block by concatenating them.
    +
    +    // First, determine the length of the environment block.
    +    len = 0;
    +    for (unsigned i = 0; envp[i]; i++)
    +      len += strlen(envp[i]) + 1;
    +
    +    // Now build the environment block.
    +    envblock = reinterpret_cast(_alloca(len+1));
    +    p = envblock;
    +
    +    for (unsigned i = 0; envp[i]; i++) {
    +      const char *ev = envp[i];
    +      size_t len = strlen(ev) + 1;
    +      memcpy(p, ev, len);
    +      p += len;
    +    }
    +
    +    *p = 0;
    +  }
    +
    +  // Create a child process.
    +  STARTUPINFO si;
    +  memset(&si, 0, sizeof(si));
    +  si.cb = sizeof(si);
    +  si.hStdInput = INVALID_HANDLE_VALUE;
    +  si.hStdOutput = INVALID_HANDLE_VALUE;
    +  si.hStdError = INVALID_HANDLE_VALUE;
    +
    +  if (redirects) {
    +    si.dwFlags = STARTF_USESTDHANDLES;
    +
    +    si.hStdInput = RedirectIO(redirects[0], 0, ErrMsg);
    +    if (si.hStdInput == INVALID_HANDLE_VALUE) {
    +      MakeErrMsg(ErrMsg, "can't redirect stdin");
    +      return;
    +    }
    +    si.hStdOutput = RedirectIO(redirects[1], 1, ErrMsg);
    +    if (si.hStdOutput == INVALID_HANDLE_VALUE) {
    +      CloseHandle(si.hStdInput);
    +      MakeErrMsg(ErrMsg, "can't redirect stdout");
    +      return;
    +    }
    +    if (redirects[1] && redirects[2] && *(redirects[1]) == *(redirects[2])) {
    +      // If stdout and stderr should go to the same place, redirect stderr
    +      // to the handle already open for stdout.
    +      DuplicateHandle(GetCurrentProcess(), si.hStdOutput,
    +                      GetCurrentProcess(), &si.hStdError,
    +                      0, TRUE, DUPLICATE_SAME_ACCESS);
    +    } else {
    +      // Just redirect stderr
    +      si.hStdError = RedirectIO(redirects[2], 2, ErrMsg);
    +      if (si.hStdError == INVALID_HANDLE_VALUE) {
    +        CloseHandle(si.hStdInput);
    +        CloseHandle(si.hStdOutput);
    +        MakeErrMsg(ErrMsg, "can't redirect stderr");
    +        return;
    +      }
    +    }
    +  }
    +
    +  PROCESS_INFORMATION pi;
    +  memset(&pi, 0, sizeof(pi));
    +
    +  fflush(stdout);
    +  fflush(stderr);
    +  BOOL rc = CreateProcess(path.c_str(), command, NULL, NULL, TRUE, 0,
    +                          envblock, NULL, &si, &pi);
    +  DWORD err = GetLastError();
    +
    +  // Regardless of whether the process got created or not, we are done with
    +  // the handles we created for it to inherit.
    +  CloseHandle(si.hStdInput);
    +  CloseHandle(si.hStdOutput);
    +  CloseHandle(si.hStdError);
    +
    +  // Now return an error if the process didn't get created.
    +  if (!rc)
    +  {
    +    SetLastError(err);
    +    MakeErrMsg(ErrMsg, std::string("Couldn't execute program '") +
    +               path.toString() + "'");
    +    return;
    +  }
    +
    +  // Make sure these get closed no matter what.
    +  AutoHandle hProcess(pi.hProcess);
    +  AutoHandle hThread(pi.hThread);
    +
    +  // Assign the process to a job if a memory limit is defined.
    +  AutoHandle hJob(0);
    +  if (memoryLimit != 0) {
    +    hJob = CreateJobObject(0, 0);
    +    bool success = false;
    +    if (hJob != 0) {
    +      JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli;
    +      memset(&jeli, 0, sizeof(jeli));
    +      jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_PROCESS_MEMORY;
    +      jeli.ProcessMemoryLimit = uintptr_t(memoryLimit) * 1048576;
    +      if (SetInformationJobObject(hJob, JobObjectExtendedLimitInformation,
    +                                  &jeli, sizeof(jeli))) {
    +        if (AssignProcessToJobObject(hJob, pi.hProcess))
    +          success = true;
    +      }
    +    }
    +    if (!success) {
    +      SetLastError(GetLastError());
    +      MakeErrMsg(ErrMsg, std::string("Unable to set memory limit"));
    +      TerminateProcess(pi.hProcess, 1);
    +      WaitForSingleObject(pi.hProcess, INFINITE);
    +      return;
    +    }
    +  }
    +}
    +
     bool Program::ChangeStdinToBinary(){
       int result = _setmode( _fileno(stdin), _O_BINARY );
       return result == -1;
    
    
    
    
    From greened at obbligato.org  Wed Jul  8 16:53:53 2009
    From: greened at obbligato.org (David Greene)
    Date: Wed, 08 Jul 2009 21:53:53 -0000
    Subject: [llvm-commits] [llvm] r75056 - in /llvm/trunk:
     include/llvm/Support/GraphWriter.h lib/Support/GraphWriter.cpp
    Message-ID: <200907082153.n68Lrtuu028520@zion.cs.uiuc.edu>
    
    Author: greened
    Date: Wed Jul  8 16:53:41 2009
    New Revision: 75056
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75056&view=rev
    Log:
    
    Allow users of GraphWriter to display graphs asynchronously.  This
    provides a way to quickly dump a bunch of graph information to dot files
    and display them.  It's a timesaver when working on large systems.
    
    Modified:
        llvm/trunk/include/llvm/Support/GraphWriter.h
        llvm/trunk/lib/Support/GraphWriter.cpp
    
    Modified: llvm/trunk/include/llvm/Support/GraphWriter.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=75056&r1=75055&r2=75056&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/Support/GraphWriter.h (original)
    +++ llvm/trunk/include/llvm/Support/GraphWriter.h Wed Jul  8 16:53:41 2009
    @@ -29,6 +29,7 @@
     #include "llvm/System/Path.h"
     #include 
     #include 
    +#include 
     
     namespace llvm {
     
    @@ -66,7 +67,7 @@
       }
     }
     
    -void DisplayGraph(const sys::Path& Filename);
    +void DisplayGraph(const sys::Path& Filename, bool wait=true);
     
     template
     class GraphWriter {
    
    Modified: llvm/trunk/lib/Support/GraphWriter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/GraphWriter.cpp?rev=75056&r1=75055&r2=75056&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Support/GraphWriter.cpp (original)
    +++ llvm/trunk/lib/Support/GraphWriter.cpp Wed Jul  8 16:53:41 2009
    @@ -18,7 +18,7 @@
     #include "llvm/Config/config.h"
     using namespace llvm;
     
    -void llvm::DisplayGraph(const sys::Path &Filename) {
    +void llvm::DisplayGraph(const sys::Path &Filename, bool wait) {
       std::string ErrMsg;
     #if HAVE_GRAPHVIZ
       sys::Path Graphviz(LLVM_PATH_GRAPHVIZ);
    @@ -30,16 +30,24 @@
       
       cerr << "Running 'Graphviz' program... " << std::flush;
       if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,0,&ErrMsg)) {
    -    cerr << "Error viewing graph: " << ErrMsg << "\n";
    +     cerr << "Error viewing graph " << Filename << ": " << ErrMsg << "\n";
       }
    -#elif (HAVE_GV && HAVE_DOT)
    +  else {
    +     Filename.eraseFromDisk();
    +  }
    +  
    +#elif (HAVE_GV && (HAVE_DOT || HAVE_FDP))
       sys::Path PSFilename = Filename;
       PSFilename.appendSuffix("ps");
    -  
    -  sys::Path dot(LLVM_PATH_DOT);
    +
    +#if HAVE_FDP
    +  sys::Path prog(LLVM_PATH_FDP);
    +#else
    +  sys::Path prog(LLVM_PATH_DOT);
    +#endif
     
       std::vector args;
    -  args.push_back(dot.c_str());
    +  args.push_back(prog.c_str());
       args.push_back("-Tps");
       args.push_back("-Nfontname=Courier");
       args.push_back("-Gsize=7.5,10");
    @@ -48,9 +56,10 @@
       args.push_back(PSFilename.c_str());
       args.push_back(0);
       
    -  cerr << "Running 'dot' program... " << std::flush;
    -  if (sys::Program::ExecuteAndWait(dot, &args[0],0,0,0,0,&ErrMsg)) {
    -    cerr << "Error viewing graph: '" << ErrMsg << "\n";
    +  cerr << "Running '" << prog << "' program... " << std::flush;
    +
    +  if (sys::Program::ExecuteAndWait(prog, &args[0],0,0,0,0,&ErrMsg)) {
    +     cerr << "Error viewing graph " << Filename << ": '" << ErrMsg << "\n";
       } else {
         cerr << " done. \n";
     
    @@ -62,11 +71,18 @@
         args.push_back(0);
         
         ErrMsg.clear();
    -    if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,0,&ErrMsg)) {
    -      cerr << "Error viewing graph: " << ErrMsg << "\n";
    +    if (wait) {
    +       if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,0,&ErrMsg)) {
    +          cerr << "Error viewing graph: " << ErrMsg << "\n";
    +       }
    +       Filename.eraseFromDisk();
    +       PSFilename.eraseFromDisk();
    +    }
    +    else {
    +       sys::Program::ExecuteNoWait(gv, &args[0],0,0,0,&ErrMsg);
    +       cerr << "Remember to erase graph files: " << Filename << " " << PSFilename << "\n";
         }
       }
    -  PSFilename.eraseFromDisk();
     #elif HAVE_DOTTY
       sys::Path dotty(LLVM_PATH_DOTTY);
     
    @@ -77,13 +93,12 @@
       
       cerr << "Running 'dotty' program... " << std::flush;
       if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,0,&ErrMsg)) {
    -    cerr << "Error viewing graph: " << ErrMsg << "\n";
    +     cerr << "Error viewing graph " << Filename << ": " << ErrMsg << "\n";
       } else {
     #ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns
         return;
     #endif
    +    Filename.eraseFromDisk();
       }
     #endif
    -  
    -  Filename.eraseFromDisk();
     }
    
    
    
    
    From dpatel at apple.com  Wed Jul  8 16:57:18 2009
    From: dpatel at apple.com (Devang Patel)
    Date: Wed, 08 Jul 2009 21:57:18 -0000
    Subject: [llvm-commits] [llvm] r75057 - in /llvm/trunk:
     lib/AsmParser/LLParser.cpp lib/VMCore/AsmWriter.cpp test/Feature/mdnode2.ll
     test/Feature/mdnode3.ll test/Feature/mdnode4.ll
     unittests/VMCore/MetadataTest.cpp
    Message-ID: <200907082157.n68LvKfa028635@zion.cs.uiuc.edu>
    
    Author: dpatel
    Date: Wed Jul  8 16:57:07 2009
    New Revision: 75057
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75057&view=rev
    Log:
    Drop "constant" from 
      !0 = constant metadata !{...}
    
    Modified:
        llvm/trunk/lib/AsmParser/LLParser.cpp
        llvm/trunk/lib/VMCore/AsmWriter.cpp
        llvm/trunk/test/Feature/mdnode2.ll
        llvm/trunk/test/Feature/mdnode3.ll
        llvm/trunk/test/Feature/mdnode4.ll
        llvm/trunk/unittests/VMCore/MetadataTest.cpp
    
    Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=75057&r1=75056&r2=75057&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
    +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Jul  8 16:57:07 2009
    @@ -377,10 +377,8 @@
         return true;
     
       LocTy TyLoc;
    -  bool IsConstant;    
       PATypeHolder Ty(Type::VoidTy);
    -  if (ParseGlobalType(IsConstant) ||
    -      ParseType(Ty, TyLoc))
    +  if (ParseType(Ty, TyLoc))
         return true;
       
       Constant *Init = 0;
    
    Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=75057&r1=75056&r2=75057&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
    +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Wed Jul  8 16:57:07 2009
    @@ -827,7 +827,7 @@
         Nodes[I->second] = cast(I->first);
     
       for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
    -    Out << '!' << i << " = constant metadata ";
    +    Out << '!' << i << " = metadata ";
         const MDNode *Node = Nodes[i];
         Out << "!{";
         for (MDNode::const_elem_iterator NI = Node->elem_begin(), 
    
    Modified: llvm/trunk/test/Feature/mdnode2.ll
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/mdnode2.ll?rev=75057&r1=75056&r2=75057&view=diff
    
    ==============================================================================
    --- llvm/trunk/test/Feature/mdnode2.ll (original)
    +++ llvm/trunk/test/Feature/mdnode2.ll Wed Jul  8 16:57:07 2009
    @@ -3,6 +3,6 @@
     ; RUN: grep "metadata !{i32 21, i32 22}" %t.ll
     ; RUN: grep "metadata !{i32 23, i32 24}" %t.ll
     
    -!0 = constant metadata !{i32 21, i32 22}
    -!1 = constant metadata !{i32 23, i32 24}
    +!0 = metadata !{i32 21, i32 22}
    +!1 = metadata !{i32 23, i32 24}
     @llvm.blah = constant metadata !{i32 1000, i16 200, metadata !1, metadata !0}
    
    Modified: llvm/trunk/test/Feature/mdnode3.ll
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/mdnode3.ll?rev=75057&r1=75056&r2=75057&view=diff
    
    ==============================================================================
    --- llvm/trunk/test/Feature/mdnode3.ll (original)
    +++ llvm/trunk/test/Feature/mdnode3.ll Wed Jul  8 16:57:07 2009
    @@ -1,3 +1,3 @@
     ; RUN: llvm-as < %s | llvm-dis | llvm-as -f -o /dev/null
    -!0 = constant metadata !{i32 21, i32 22}
    +!0 = metadata !{i32 21, i32 22}
     @llvm.blah = constant metadata !{i32 1000, i16 200, metadata !0, metadata !0}
    
    Modified: llvm/trunk/test/Feature/mdnode4.ll
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/mdnode4.ll?rev=75057&r1=75056&r2=75057&view=diff
    
    ==============================================================================
    --- llvm/trunk/test/Feature/mdnode4.ll (original)
    +++ llvm/trunk/test/Feature/mdnode4.ll Wed Jul  8 16:57:07 2009
    @@ -2,4 +2,5 @@
     ; RUN: llvm-as < %s | llvm-dis -f -o /dev/null
     
     @llvm.blah = constant metadata !{metadata !1}
    -!1 = constant metadata !{i32 23, i32 24}
    +!1 = metadata !{i32 23, i32 24}
    +
    
    Modified: llvm/trunk/unittests/VMCore/MetadataTest.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/MetadataTest.cpp?rev=75057&r1=75056&r2=75057&view=diff
    
    ==============================================================================
    --- llvm/trunk/unittests/VMCore/MetadataTest.cpp (original)
    +++ llvm/trunk/unittests/VMCore/MetadataTest.cpp Wed Jul  8 16:57:07 2009
    @@ -94,10 +94,10 @@
       std::ostringstream oss1, oss2;
       n1->print(oss1);
       n2->print(oss2);
    -  EXPECT_STREQ("!0 = constant metadata !{metadata !\"abc\", i8 0, metadata !\"123\"}\n",
    +  EXPECT_STREQ("!0 = metadata !{metadata !\"abc\", i8 0, metadata !\"123\"}\n",
                    oss1.str().c_str());
    -  EXPECT_STREQ("!0 = constant metadata !{metadata !1}\n"
    -               "!1 = constant metadata !{metadata !\"abc\", i8 0, metadata !\"123\"}\n",
    +  EXPECT_STREQ("!0 = metadata !{metadata !1}\n"
    +               "!1 = metadata !{metadata !\"abc\", i8 0, metadata !\"123\"}\n",
                    oss2.str().c_str());
     }
     
    @@ -134,6 +134,6 @@
     
       std::ostringstream oss;
       wvh->print(oss);
    -  EXPECT_STREQ("!0 = constant metadata !{null}\n", oss.str().c_str());
    +  EXPECT_STREQ("!0 = metadata !{null}\n", oss.str().c_str());
     }
     }
    
    
    
    
    From greened at obbligato.org  Wed Jul  8 16:57:47 2009
    From: greened at obbligato.org (David Greene)
    Date: Wed, 08 Jul 2009 21:57:47 -0000
    Subject: [llvm-commits] [llvm] r75058 -
    	/llvm/trunk/include/llvm/CodeGen/RegAllocRegistry.h
    Message-ID: <200907082157.n68LvlVa028658@zion.cs.uiuc.edu>
    
    Author: greened
    Date: Wed Jul  8 16:57:46 2009
    New Revision: 75058
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75058&view=rev
    Log:
    
    Reformat.
    
    Modified:
        llvm/trunk/include/llvm/CodeGen/RegAllocRegistry.h
    
    Modified: llvm/trunk/include/llvm/CodeGen/RegAllocRegistry.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RegAllocRegistry.h?rev=75058&r1=75057&r2=75058&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/CodeGen/RegAllocRegistry.h (original)
    +++ llvm/trunk/include/llvm/CodeGen/RegAllocRegistry.h Wed Jul  8 16:57:46 2009
    @@ -34,7 +34,9 @@
     
       RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
       : MachinePassRegistryNode(N, D, (MachinePassCtor)C)
    -  { Registry.Add(this); }
    +  { 
    +     Registry.Add(this); 
    +  }
       ~RegisterRegAlloc() { Registry.Remove(this); }
       
     
    
    
    
    
    From jyasskin at google.com  Wed Jul  8 17:00:04 2009
    From: jyasskin at google.com (Jeffrey Yasskin)
    Date: Wed, 08 Jul 2009 22:00:04 -0000
    Subject: [llvm-commits] [llvm] r75059 - in /llvm/trunk:
     include/llvm/CodeGen/ include/llvm/ExecutionEngine/ lib/ExecutionEngine/
     lib/ExecutionEngine/Interpreter/ lib/ExecutionEngine/JIT/
     unittests/ExecutionEngine/JIT/
    Message-ID: <200907082200.n68M0JuK028789@zion.cs.uiuc.edu>
    
    Author: jyasskin
    Date: Wed Jul  8 16:59:57 2009
    New Revision: 75059
    
    URL: http://llvm.org/viewvc/llvm-project?rev=75059&view=rev
    Log:
    Add an option to allocate JITed global data separately from code.  By
    default, this option is not enabled to support clients who rely on
    this behavior.
    
    Fixes http://llvm.org/PR4483
    
    A patch to allocate additional memory for globals after we run out is
    forthcoming.
    
    Patch by Reid Kleckner!
    
    Added:
        llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
    Modified:
        llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h
        llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
        llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h
        llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
        llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.cpp
        llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.h
        llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
        llvm/trunk/lib/ExecutionEngine/JIT/JIT.h
        llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
        llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
        llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp
    
    Modified: llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h?rev=75059&r1=75058&r2=75059&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h (original)
    +++ llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h Wed Jul  8 16:59:57 2009
    @@ -267,6 +267,11 @@
         return Result;
       }
     
    +  /// allocateGlobal - Allocate memory for a global.  Unlike allocateSpace,
    +  /// this method does not allocate memory in the current output buffer,
    +  /// because a global may live longer than the current function.
    +  virtual void *allocateGlobal(uintptr_t Size, unsigned Alignment) = 0;
    +
       /// StartMachineBasicBlock - This should be called by the target when a new
       /// basic block is about to be emitted.  This way the MCE knows where the
       /// start of the block is, and can implement getMachineBasicBlockAddress.
    
    Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=75059&r1=75058&r2=75059&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original)
    +++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Wed Jul  8 16:59:57 2009
    @@ -87,7 +87,8 @@
       // libraries, the JIT and Interpreter set these functions to ctor pointers
       // at startup time if they are linked in.
       typedef ExecutionEngine *(*EECtorFn)(ModuleProvider*, std::string*,
    -                                       CodeGenOpt::Level OptLevel);
    +                                       CodeGenOpt::Level OptLevel,
    +                                       bool GVsWithCode);
       static EECtorFn JITCtor, InterpCtor;
     
       /// LazyFunctionCreator - If an unknown function is needed, this function
    @@ -118,8 +119,18 @@
                                      bool ForceInterpreter = false,
                                      std::string *ErrorStr = 0,
                                      CodeGenOpt::Level OptLevel =
    -                                   CodeGenOpt::Default);
    -  
    +                                   CodeGenOpt::Default,
    +                                 // Allocating globals with code breaks
    +                                 // freeMachineCodeForFunction and is probably
    +                                 // unsafe and bad for performance.  However,
    +                                 // we have clients who depend on this
    +                                 // behavior, so we must support it.
    +                                 // Eventually, when we're willing to break
    +                                 // some backwards compatability, this flag
    +                                 // should be flipped to false, so that by
    +                                 // default freeMachineCodeForFunction works.
    +                                 bool GVsWithCode = true);
    +
       /// create - This is the factory method for creating an execution engine which
       /// is appropriate for the current machine.  This takes ownership of the
       /// module.
    @@ -132,7 +143,8 @@
                                         std::string *ErrorStr = 0,
                                         JITMemoryManager *JMM = 0,
                                         CodeGenOpt::Level OptLevel =
    -                                      CodeGenOpt::Default);
    +                                      CodeGenOpt::Default,
    +                                    bool GVsWithCode = true);
     
       /// addModuleProvider - Add a ModuleProvider to the list of modules that we
       /// can JIT from.  Note that this takes ownership of the ModuleProvider: when
    
    Modified: llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h?rev=75059&r1=75058&r2=75059&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h (original)
    +++ llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h Wed Jul  8 16:59:57 2009
    @@ -28,6 +28,7 @@
       bool HasGOT;
       bool SizeRequired;
     public:
    +
       JITMemoryManager() : HasGOT(false), SizeRequired(false) {}
       virtual ~JITMemoryManager();
       
    @@ -43,6 +44,11 @@
       /// start execution, the code pages may need permissions changed.
       virtual void setMemoryExecutable(void) = 0;
     
    +  /// setPoisonMemory - Setting this flag to true makes the memory manager
    +  /// garbage values over freed memory.  This is useful for testing and
    +  /// debugging, and is be turned on by default in debug mode.
    +  virtual void setPoisonMemory(bool poison) = 0;
    +
       //===--------------------------------------------------------------------===//
       // Global Offset Table Management
       //===--------------------------------------------------------------------===//
    @@ -114,7 +120,10 @@
     
       /// allocateSpace - Allocate a memory block of the given size.
       virtual uint8_t *allocateSpace(intptr_t Size, unsigned Alignment) = 0;
    -  
    +
    +  /// allocateGlobal - Allocate memory for a global.
    +  virtual uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment) = 0;
    +
       /// deallocateMemForFunction - Free JIT memory for the specified function.
       /// This is never called when the JIT is currently emitting a function.
       virtual void deallocateMemForFunction(const Function *F) = 0;
    
    Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=75059&r1=75058&r2=75059&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original)
    +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Wed Jul  8 16:59:57 2009
    @@ -384,7 +384,8 @@
     ExecutionEngine *ExecutionEngine::create(ModuleProvider *MP,
                                              bool ForceInterpreter,
                                              std::string *ErrorStr,
    -                                         CodeGenOpt::Level OptLevel) {
    +                                         CodeGenOpt::Level OptLevel,
    +                                         bool GVsWithCode) {
       ExecutionEngine *EE = 0;
     
       // Make sure we can resolve symbols in the program as well. The zero arg
    @@ -394,11 +395,11 @@
     
       // Unless the interpreter was explicitly selected, try making a JIT.
       if (!ForceInterpreter && JITCtor)
    -    EE = JITCtor(MP, ErrorStr, OptLevel);
    +    EE = JITCtor(MP, ErrorStr, OptLevel, GVsWithCode);
     
       // If we can't make a JIT, make an interpreter instead.
       if (EE == 0 && InterpCtor)
    -    EE = InterpCtor(MP, ErrorStr, OptLevel);
    +    EE = InterpCtor(MP, ErrorStr, OptLevel, GVsWithCode);
     
       return EE;
     }
    
    Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.cpp?rev=75059&r1=75058&r2=75059&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.cpp (original)
    +++ llvm/trunk/lib/ExecutionEngine/Interpreter/Interpreter.cpp Wed Jul  8 16:59:57 2009
    @@ -34,7 +34,8 @@
     /// create - Create a new interpreter object.  This can never fail.
     ///
     ExecutionEngine *Interpreter::create(ModuleProvider *MP, std::string* ErrStr,
    -                                     CodeGenOpt::Level OptLevel /*unused*/) {
    +                                     CodeGenOpt::Level OptLevel, /*unused