[llvm-commits] CVS: llvm/lib/System/Unix/Program.inc
Changes in directory llvm/lib/System/Unix: Program.inc updated: 1.23 - 1.24 --- Log message: Cygwin doesn't have the RSS_LIMIT for get/setrlimit. --- Diffs of the changes: (+2 -0) Program.inc |2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/System/Unix/Program.inc diff -u llvm/lib/System/Unix/Program.inc:1.23 llvm/lib/System/Unix/Program.inc:1.24 --- llvm/lib/System/Unix/Program.inc:1.23 Fri Feb 16 13:11:06 2007 +++ llvm/lib/System/Unix/Program.incMon Apr 23 02:22:51 2007 @@ -119,10 +119,12 @@ getrlimit (RLIMIT_DATA, r); r.rlim_cur = limit; setrlimit (RLIMIT_DATA, r); +#ifndef __CYGWIN__ // Resident set size. getrlimit (RLIMIT_RSS, r); r.rlim_cur = limit; setrlimit (RLIMIT_RSS, r); +#endif // Virtual memory. getrlimit (RLIMIT_AS, r); r.rlim_cur = limit; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/test/lib/llvm.exp
Hi Reid, + if { [ string first $lang $llvmgcc_langs ] = 0 } { won't c match c,c++,objc and objc++; and c++ match both c++ and objc++, etc? Best wishes, Duncan. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/win32/Bitcode/Bitcode.vcproj
Changes in directory llvm/win32/Bitcode: Bitcode.vcproj updated: 1.1 - 1.2 --- Log message: Unbreak VC++ build. --- Diffs of the changes: (+2 -2) Bitcode.vcproj |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/Bitcode/Bitcode.vcproj diff -u llvm/win32/Bitcode/Bitcode.vcproj:1.1 llvm/win32/Bitcode/Bitcode.vcproj:1.2 --- llvm/win32/Bitcode/Bitcode.vcproj:1.1 Sun Apr 22 10:00:52 2007 +++ llvm/win32/Bitcode/Bitcode.vcproj Mon Apr 23 08:55:05 2007 @@ -149,10 +149,10 @@ RelativePath=..\..\include\llvm\Bitcode\BitstreamWriter.h /File File - RelativePath=..\..\include\llvm\Bitcode\ReaderWriter.h + RelativePath=..\..\include\llvm\Bitcode\LLVMBitCodes.h /File File - RelativePath=..\..\lib\Bitcode\LLVMBitCodes.h + RelativePath=..\..\include\llvm\Bitcode\ReaderWriter.h /File /Filter /Files ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-www/ProjectsWithLLVM/index.html
Changes in directory llvm-www/ProjectsWithLLVM: index.html updated: 1.34 - 1.35 --- Log message: add the calysto checker --- Diffs of the changes: (+56 -0) index.html | 56 1 files changed, 56 insertions(+) Index: llvm-www/ProjectsWithLLVM/index.html diff -u llvm-www/ProjectsWithLLVM/index.html:1.34 llvm-www/ProjectsWithLLVM/index.html:1.35 --- llvm-www/ProjectsWithLLVM/index.html:1.34 Mon Mar 26 14:05:37 2007 +++ llvm-www/ProjectsWithLLVM/index.htmlMon Apr 23 10:39:59 2007 @@ -35,6 +35,7 @@ div class=www_text ul +lia href=#CalystoCalysto Static Checker/a/li lia href=#ssa_raImprovements on SSA-Based Register Allocation/a/li lia href=#LENSLENS Project/a/li lia href=#tridentTrident Compiler/a/li @@ -57,6 +58,61 @@ !--=-- div class=www_subsection +a name=CalystoCalysto Static Checker/a +br +/div +!--=-- + +div class=www_subsubsection +By Domagoj Babic, UBC. +/div + +div class=www_text + +p +a href=http://www.cs.ubc.ca/~babic/index_calysto.htm;Calysto/a +is a scalable context- and path-sensitive SSA-based static +assertion checker. Unlike other static +checkers, Calysto analyzes SSA directly, which means that it not only +checks the original code, but also the front-end (including +SSA-optimizations) of the compiler which +was used to compile the code. The advantage of doing static checking on +the SSA is language independency and the fact that the checked code is much +closer to the generated assembly than the source code. +/p + +p +Several main factors contribute to Calysto's scalability: + ul + li A novel SSA symbolic execution algorithm that exploits the + structure of the control flow graph to minimize the number of + paths that need to be considered./li + + li Lazy interprocedural analysis./li + li Tight integration with the + a href=http://www.cs.ubc.ca/~babic/index_spear.htm;Spear/a + automated theorem prover, designed for software static + checking./li + li And, of course, fast implementations of the basic algorithms + in LLVM (dominator trees, postdominance, etc.)./li + /ul +/p + +p +Currently, Calysto is still in the development phase, and the first results +are encouraging. Most likely, the first public release will happen some +time in the fall 2007. +a href=http://www.cs.ubc.ca/~babic/index_spear.htm;Spear/a +and Calysto generated +a href=http://www.cs.ubc.ca/~babic/index_benchmarks.htm;benchmarks/a +are available. +/p + +/div + + +!--=-- +div class=www_subsection a name=ssa_raImprovements on SSA-Based Register Allocation./a /div ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-www/Users.html
Changes in directory llvm-www: Users.html updated: 1.15 - 1.16 --- Log message: Add Abo Akademi University's NECST project per Sebastien Lafond's request. --- Diffs of the changes: (+9 -1) Users.html | 10 +- 1 files changed, 9 insertions(+), 1 deletion(-) Index: llvm-www/Users.html diff -u llvm-www/Users.html:1.15 llvm-www/Users.html:1.16 --- llvm-www/Users.html:1.15Sat Apr 7 11:22:50 2007 +++ llvm-www/Users.html Mon Apr 23 10:44:54 2007 @@ -81,6 +81,14 @@ thDescription/th /tr + !-- Requested by Johan Lilius's Research Group -- + tr +tda href=http://www.abo.fi/;Åbo Akademi University/a/td +tdJohan Lilius's Research Group, ES Lab/td +tda href=http://www.abo.fi/~johan.lilius/research/page12/page0/necst.html;NECST project/a +/td + /tr + !-- http://lists.cs.uiuc.edu/pipermail/llvmdev/2006-July/006246.html -- tr tda href=http://www.ugent.be/;Ghent University/a/td @@ -238,6 +246,6 @@ src=http://www.w3.org/Icons/valid-html401; alt=Valid HTML 4.01!/a br/a href=mailto:[EMAIL PROTECTED]LLVM Development List/abr - Last modified: $Date: 2007/04/07 16:22:50 $ + Last modified: $Date: 2007/04/23 15:44:54 $ /address !--#include virtual=footer.incl -- ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Writer/Writer.cpp
Changes in directory llvm/lib/Bitcode/Writer: Writer.cpp updated: 1.2 - 1.3 --- Log message: first part of implementation of abbrevs. The writer isn't fully there yet and the reader doesn't handle them at all yet. --- Diffs of the changes: (+39 -6) Writer.cpp | 45 +++-- 1 files changed, 39 insertions(+), 6 deletions(-) Index: llvm/lib/Bitcode/Writer/Writer.cpp diff -u llvm/lib/Bitcode/Writer/Writer.cpp:1.2 llvm/lib/Bitcode/Writer/Writer.cpp:1.3 --- llvm/lib/Bitcode/Writer/Writer.cpp:1.2 Sun Apr 22 20:01:37 2007 +++ llvm/lib/Bitcode/Writer/Writer.cpp Mon Apr 23 11:04:05 2007 @@ -200,10 +200,14 @@ WriteStringRecord(bitc::MODULE_CODE_ASM, M-getModuleInlineAsm(), 0/*TODO*/, Stream); - // Emit information about sections. + // Emit information about sections, computing how many there are. Also + // compute the maximum alignment value. std::mapstd::string, unsigned SectionMap; + unsigned MaxAlignment = 0; for (Module::const_global_iterator GV = M-global_begin(),E = M-global_end(); GV != E; ++GV) { +MaxAlignment = std::max(MaxAlignment, GV-getAlignment()); + if (!GV-hasSection()) continue; // Give section names unique ID's. unsigned Entry = SectionMap[GV-getSection()]; @@ -213,6 +217,7 @@ Entry = SectionMap.size(); } for (Module::const_iterator F = M-begin(), E = M-end(); F != E; ++F) { +MaxAlignment = std::max(MaxAlignment, F-getAlignment()); if (!F-hasSection()) continue; // Give section names unique ID's. unsigned Entry = SectionMap[F-getSection()]; @@ -222,13 +227,37 @@ Entry = SectionMap.size(); } - // TODO: Emit abbrev, now that we know # sections. + // Emit abbrev for globals, now that we know # sections and max alignment. + unsigned SimpleGVarAbbrev = 0; + if (!M-global_empty() 0) { +// Add an abbrev for common globals with no visibility or thread localness. +BitCodeAbbrev *Abbv = new BitCodeAbbrev(); +Abbv-Add(BitCodeAbbrevOp(bitc::MODULE_CODE_GLOBALVAR)); +Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, 1)); // Constant. +Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));// Initializer. +Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, 3)); // Linkage. +if (MaxAlignment == 0) // Alignment. + Abbv-Add(BitCodeAbbrevOp(0)); +else { + unsigned MaxEncAlignment = Log2_32(MaxAlignment)+1; + Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, + Log2_32_Ceil(MaxEncAlignment))); +} +if (SectionMap.empty())// Section. + Abbv-Add(BitCodeAbbrevOp(0)); +else + Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, + Log2_32_Ceil(SectionMap.size(; +// Don't bother emitting vis + thread local. +SimpleGVarAbbrev = Stream.EmitAbbrev(Abbv); + } // Emit the global variable information. SmallVectorunsigned, 64 Vals; for (Module::const_global_iterator GV = M-global_begin(),E = M-global_end(); GV != E; ++GV) { - +unsigned AbbrevToUse = 0; + // GLOBALVAR: [type, isconst, initid, // linkage, alignment, section, visibility, threadlocal] Vals.push_back(VE.getTypeID(GV-getType())); @@ -238,10 +267,14 @@ Vals.push_back(getEncodedLinkage(GV)); Vals.push_back(Log2_32(GV-getAlignment())+1); Vals.push_back(GV-hasSection() ? SectionMap[GV-getSection()] : 0); -Vals.push_back(getEncodedVisibility(GV)); -Vals.push_back(GV-isThreadLocal()); +if (GV-isThreadLocal() || +GV-getVisibility() != GlobalValue::DefaultVisibility) { + Vals.push_back(getEncodedVisibility(GV)); + Vals.push_back(GV-isThreadLocal()); +} else { + AbbrevToUse = SimpleGVarAbbrev; +} -unsigned AbbrevToUse = 0; Stream.EmitRecord(bitc::MODULE_CODE_GLOBALVAR, Vals, AbbrevToUse); Vals.clear(); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Bitcode/BitCodes.h BitstreamReader.h BitstreamWriter.h
Changes in directory llvm/include/llvm/Bitcode: BitCodes.h updated: 1.1 - 1.2 BitstreamReader.h updated: 1.3 - 1.4 BitstreamWriter.h updated: 1.2 - 1.3 --- Log message: first part of implementation of abbrevs. The writer isn't fully there yet and the reader doesn't handle them at all yet. --- Diffs of the changes: (+109 -13) BitCodes.h| 65 +++--- BitstreamReader.h |3 -- BitstreamWriter.h | 54 +++- 3 files changed, 109 insertions(+), 13 deletions(-) Index: llvm/include/llvm/Bitcode/BitCodes.h diff -u llvm/include/llvm/Bitcode/BitCodes.h:1.1 llvm/include/llvm/Bitcode/BitCodes.h:1.2 --- llvm/include/llvm/Bitcode/BitCodes.h:1.1Sun Apr 22 01:22:05 2007 +++ llvm/include/llvm/Bitcode/BitCodes.hMon Apr 23 11:04:05 2007 @@ -18,6 +18,10 @@ #ifndef LLVM_BITCODE_BITCODES_H #define LLVM_BITCODE_BITCODES_H +#include llvm/ADT/SmallVector.h +#include llvm/Support/DataTypes.h +#include cassert + namespace llvm { namespace bitc { enum StandardWidths { @@ -31,16 +35,71 @@ enum FixedCodes { END_BLOCK = 0, // Must be zero to guarantee termination for broken bitcode. ENTER_SUBBLOCK = 1, + +/// DEFINE_ABBREV - Defines an abbrev for the current block. It consists +/// of a vbr5 for # operand infos. Each operand info is emitted with a +/// single bit to indicate if it is a literal encoding. If so, the value is +/// emitted with a vbr8. If not, the encoding is emitted as 3 bits followed +/// by the info value as a vbr5 if needed. +DEFINE_ABBREV = 2, -// Two codes are reserved for defining abbrevs and for emitting an -// unabbreviated record. -DEFINE_ABBREVS = 2, +// UNABBREV_RECORDs are emitted with a vbr6 for the record code, followed by +// a vbr6 for the # operands, followed by vbr6's for each operand. UNABBREV_RECORD = 3, // This is not a code, this is a marker for the first abbrev assignment. FIRST_ABBREV = 4 }; } // End bitc namespace + +/// BitCodeAbbrevOp - This describes one or more operands in an abbreviation. +/// This is actually a union of two different things: +/// 1. It could be a literal integer value (the operand is always 17). +/// 2. It could be an encoding specification (this operand encoded like so). +/// +class BitCodeAbbrevOp { + uint64_t Val;// A literal value or data for an encoding. + bool IsLiteral : 1; // Indicate whether this is a literal value or not. + unsigned Enc : 3; // The encoding to use. +public: + enum Encoding { +FixedWidth = 1, // A fixed with field, Val specifies number of bits. +VBR= 2 // A VBR field where Val specifies the width of each chunk. + }; + + BitCodeAbbrevOp(uint64_t V) : Val(V), IsLiteral(true) {} + BitCodeAbbrevOp(Encoding E, uint64_t Data) +: Val(Data), IsLiteral(false), Enc(E) {} + + bool isLiteral() const { return IsLiteral; } + bool isEncoding() const { return !IsLiteral; } + + // Accessors for literals. + uint64_t getLiteralValue() const { assert(isLiteral()); return Val; } + + // Accessors for encoding info. + Encoding getEncoding() const { assert(isEncoding()); return (Encoding)Enc; } + uint64_t getEncodingData() const { assert(isEncoding()); return Val; } + + bool hasEncodingData() const { return hasEncodingData(getEncoding()); } + static bool hasEncodingData(Encoding E) { +return true; + } +}; + +class BitCodeAbbrev { + SmallVectorBitCodeAbbrevOp, 8 OperandList; +public: + + unsigned getNumOperandInfos() const { return OperandList.size(); } + const BitCodeAbbrevOp getOperandInfo(unsigned N) const { +return OperandList[N]; + } + + void Add(const BitCodeAbbrevOp OpInfo) { +OperandList.push_back(OpInfo); + } +}; } // End llvm namespace #endif Index: llvm/include/llvm/Bitcode/BitstreamReader.h diff -u llvm/include/llvm/Bitcode/BitstreamReader.h:1.3 llvm/include/llvm/Bitcode/BitstreamReader.h:1.4 --- llvm/include/llvm/Bitcode/BitstreamReader.h:1.3 Sun Apr 22 11:31:22 2007 +++ llvm/include/llvm/Bitcode/BitstreamReader.h Mon Apr 23 11:04:05 2007 @@ -16,9 +16,6 @@ #define BITSTREAM_READER_H #include llvm/Bitcode/BitCodes.h -#include llvm/ADT/SmallVector.h -#include llvm/Support/DataTypes.h -#include cassert namespace llvm { Index: llvm/include/llvm/Bitcode/BitstreamWriter.h diff -u llvm/include/llvm/Bitcode/BitstreamWriter.h:1.2 llvm/include/llvm/Bitcode/BitstreamWriter.h:1.3 --- llvm/include/llvm/Bitcode/BitstreamWriter.h:1.2 Sun Apr 22 10:00:52 2007 +++ llvm/include/llvm/Bitcode/BitstreamWriter.h Mon Apr 23 11:04:05 2007 @@ -16,9 +16,6 @@ #define BITSTREAM_WRITER_H #include llvm/Bitcode/BitCodes.h -#include llvm/ADT/SmallVector.h -#include llvm/Support/DataTypes.h -#include cassert #include vector namespace llvm { @@ -39,11 +36,14 @@ struct Block { unsigned PrevCodeSize; unsigned StartSizeWord; +
[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Changes in directory llvm/lib/Bitcode/Reader: BitcodeReader.cpp updated: 1.1 - 1.2 --- Log message: first part of implementation of abbrevs. The writer isn't fully there yet and the reader doesn't handle them at all yet. --- Diffs of the changes: (+8 -6) BitcodeReader.cpp | 14 -- 1 files changed, 8 insertions(+), 6 deletions(-) Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.1 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.2 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.1 Sun Apr 22 01:23:29 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 23 11:04:05 2007 @@ -93,7 +93,7 @@ continue; } -if (Code == bitc::DEFINE_ABBREVS) { +if (Code == bitc::DEFINE_ABBREV) { assert(0 Abbrevs not implemented yet!); } @@ -230,7 +230,7 @@ continue; } -if (Code == bitc::DEFINE_ABBREVS) { +if (Code == bitc::DEFINE_ABBREV) { assert(0 Abbrevs not implemented yet!); } @@ -293,7 +293,7 @@ continue; } -if (Code == bitc::DEFINE_ABBREVS) { +if (Code == bitc::DEFINE_ABBREV) { assert(0 Abbrevs not implemented yet!); } @@ -345,7 +345,7 @@ // GLOBALVAR: [type, isconst, initid, // linkage, alignment, section, visibility, threadlocal] case bitc::MODULE_CODE_GLOBALVAR: { - if (Record.size() 8) + if (Record.size() 6) return Error(Invalid MODULE_CODE_GLOBALVAR record); const Type *Ty = getTypeByID(Record[0]); if (!isaPointerType(Ty)) @@ -361,8 +361,10 @@ return Error(Invalid section ID); Section = SectionTable[Record[5]-1]; } - GlobalValue::VisibilityTypes Visibility = GetDecodedVisibility(Record[6]); - bool isThreadLocal = Record[7]; + GlobalValue::VisibilityTypes Visibility = GlobalValue::DefaultVisibility; + if (Record.size() = 6) Visibility = GetDecodedVisibility(Record[6]); + bool isThreadLocal = false; + if (Record.size() = 7) isThreadLocal = Record[7]; GlobalVariable *NewGV = new GlobalVariable(Ty, isConstant, Linkage, 0, , TheModule); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-www/DevMtgMay2007.html
Changes in directory llvm-www: DevMtgMay2007.html updated: 1.112 - 1.113 --- Log message: Add rafael --- Diffs of the changes: (+3 -2) DevMtgMay2007.html |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm-www/DevMtgMay2007.html diff -u llvm-www/DevMtgMay2007.html:1.112 llvm-www/DevMtgMay2007.html:1.113 --- llvm-www/DevMtgMay2007.html:1.112 Thu Apr 19 00:20:43 2007 +++ llvm-www/DevMtgMay2007.html Mon Apr 23 11:58:07 2007 @@ -341,11 +341,12 @@ table class=www trth colspan=2Unconfirmed Attendees/th/tr trthName/ththOrganization/th/tr +trtdRafael Espindola/tdtdGoogle/td/tr trtdLang Hames/tdtdUniversity of Sydney/td/tr trtdMichael McCracken/tdtdUCSD, Ph.D. Candidate/td/tr trtdUnconfirmed 1/tdtdNASA, Ames/td/tr /table - pbTotal unconfirmed: 3/b/p + pbTotal unconfirmed: 4/b/p /div !-- *** -- @@ -355,6 +356,6 @@ src=http://jigsaw.w3.org/css-validator/images/vcss; alt=Valid CSS!/a a href=http://validator.w3.org/check/referer;img src=http://www.w3.org/Icons/valid-html401; alt=Valid HTML 4.01!/a -br/Last modified: $Date: 2007/04/19 05:20:43 $ +br/Last modified: $Date: 2007/04/23 16:58:07 $ /address !--#include virtual=footer.incl -- ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Bitcode/BitstreamWriter.h
Changes in directory llvm/include/llvm/Bitcode: BitstreamWriter.h updated: 1.3 - 1.4 --- Log message: finish implementation of basic abbrev writing. --- Diffs of the changes: (+69 -4) BitstreamWriter.h | 73 +++--- 1 files changed, 69 insertions(+), 4 deletions(-) Index: llvm/include/llvm/Bitcode/BitstreamWriter.h diff -u llvm/include/llvm/Bitcode/BitstreamWriter.h:1.3 llvm/include/llvm/Bitcode/BitstreamWriter.h:1.4 --- llvm/include/llvm/Bitcode/BitstreamWriter.h:1.3 Mon Apr 23 11:04:05 2007 +++ llvm/include/llvm/Bitcode/BitstreamWriter.h Mon Apr 23 12:43:52 2007 @@ -194,11 +194,40 @@ unsigned AbbrevNo = Abbrev-bitc::FIRST_ABBREV; assert(AbbrevNo CurAbbrevs.size() Invalid abbrev #!); BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo]; - assert(0 TODO); - for (unsigned i = 0, e = Abbv-getNumOperandInfos(); i != e; ++i) { - } + EmitCode(Abbrev); + + // Insert the code into Vals to treat it uniformly. + Vals.insert(Vals.begin(), Code); + unsigned RecordIdx = 0; + for (unsigned i = 0, e = Abbv-getNumOperandInfos(); i != e; ++i) { +assert(RecordIdx Vals.size() Invalid abbrev/record); +const BitCodeAbbrevOp Op = Abbv-getOperandInfo(i); +uint64_t RecordVal = Vals[RecordIdx]; + +if (Op.isLiteral()) { + // If the abbrev specifies the literal value to use, don't emit + // anything. + assert(RecordVal == Op.getLiteralValue() + Invalid abbrev for record!); + ++RecordIdx; +} else { + // Encode the value as we are commanded. + switch (Op.getEncoding()) { + default: assert(0 Unknown encoding!); + case BitCodeAbbrevOp::FixedWidth: +Emit64(RecordVal, Op.getEncodingData()); +++RecordIdx; +break; + case BitCodeAbbrevOp::VBR: +EmitVBR64(RecordVal, Op.getEncodingData()); +++RecordIdx; +break; + } +} + } + assert(RecordIdx == Vals.size() Not all record operands emitted!); } else { // If we don't have an abbrev to use, emit this in its fully unabbreviated // form. @@ -215,7 +244,43 @@ void EmitRecord(unsigned Code, SmallVectorImplunsigned Vals, unsigned Abbrev = 0) { if (Abbrev) { - assert(0 abbrevs not implemented yet!); + unsigned AbbrevNo = Abbrev-bitc::FIRST_ABBREV; + assert(AbbrevNo CurAbbrevs.size() Invalid abbrev #!); + BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo]; + + EmitCode(Abbrev); + + // Insert the code into Vals to treat it uniformly. + Vals.insert(Vals.begin(), Code); + + unsigned RecordIdx = 0; + for (unsigned i = 0, e = Abbv-getNumOperandInfos(); i != e; ++i) { +assert(RecordIdx Vals.size() Invalid abbrev/record); +const BitCodeAbbrevOp Op = Abbv-getOperandInfo(i); +unsigned RecordVal = Vals[RecordIdx]; + +if (Op.isLiteral()) { + // If the abbrev specifies the literal value to use, don't emit + // anything. + assert(RecordVal == Op.getLiteralValue() + Invalid abbrev for record!); + ++RecordIdx; +} else { + // Encode the value as we are commanded. + switch (Op.getEncoding()) { + default: assert(0 Unknown encoding!); + case BitCodeAbbrevOp::FixedWidth: +Emit(RecordVal, Op.getEncodingData()); +++RecordIdx; +break; + case BitCodeAbbrevOp::VBR: +EmitVBR(RecordVal, Op.getEncodingData()); +++RecordIdx; +break; + } +} + } + assert(RecordIdx == Vals.size() Not all record operands emitted!); } else { // If we don't have an abbrev to use, emit this in its fully unabbreviated // form. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm-www/Users.html
Hi John, +tda href=http://www.abo.fi/;Åbo Akademi University/a/td Could you use the HTML entity for the Å? I think it's Acirc;. Thanks! -bw ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Bitcode/BitstreamReader.h
Changes in directory llvm/include/llvm/Bitcode: BitstreamReader.h updated: 1.4 - 1.5 --- Log message: implement reading of abbrevs --- Diffs of the changes: (+89 -6) BitstreamReader.h | 95 ++ 1 files changed, 89 insertions(+), 6 deletions(-) Index: llvm/include/llvm/Bitcode/BitstreamReader.h diff -u llvm/include/llvm/Bitcode/BitstreamReader.h:1.4 llvm/include/llvm/Bitcode/BitstreamReader.h:1.5 --- llvm/include/llvm/Bitcode/BitstreamReader.h:1.4 Mon Apr 23 11:04:05 2007 +++ llvm/include/llvm/Bitcode/BitstreamReader.h Mon Apr 23 13:57:58 2007 @@ -34,10 +34,19 @@ // CurCodeSize - This is the declared size of code values used for the current // block, in bits. unsigned CurCodeSize; + + /// CurAbbrevs - Abbrevs installed at in this block. + std::vectorBitCodeAbbrev* CurAbbrevs; - /// BlockScope - This tracks the codesize of parent blocks. - SmallVectorunsigned, 8 BlockScope; + struct Block { +unsigned PrevCodeSize; +std::vectorBitCodeAbbrev* PrevAbbrevs; +explicit Block(unsigned PCS) : PrevCodeSize(PCS) {} + }; + /// BlockScope - This tracks the codesize of parent blocks. + SmallVectorBlock, 8 BlockScope; + public: BitstreamReader(const unsigned char *Start, const unsigned char *End) : NextChar(Start), LastChar(End) { @@ -47,6 +56,19 @@ CurCodeSize = 2; } + ~BitstreamReader() { +// Abbrevs could still exist if the stream was broken. If so, don't leak +// them. +for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) + delete CurAbbrevs[i]; + +for (unsigned S = 0, e = BlockScope.size(); S != e; ++S) { + std::vectorBitCodeAbbrev* Abbrevs = BlockScope[S].PrevAbbrevs; + for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i) +delete Abbrevs[i]; +} + } + bool AtEndOfStream() const { return NextChar == LastChar; } uint32_t Read(unsigned NumBits) { @@ -87,6 +109,13 @@ return R; } + uint64_t Read64(unsigned NumBits) { +if (NumBits = 32) return Read(NumBits); + +uint64_t V = Read(32); +return V | (uint64_t)Read(NumBits-32) 32; + } + uint32_t ReadVBR(unsigned NumBits) { uint32_t Piece = Read(NumBits); if ((Piece (1U (NumBits-1))) == 0) @@ -168,7 +197,8 @@ /// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, read and enter /// the block, returning the BlockID of the block we just entered. bool EnterSubBlock() { -BlockScope.push_back(CurCodeSize); +BlockScope.push_back(Block(CurCodeSize)); +BlockScope.back().PrevAbbrevs.swap(CurAbbrevs); // Get the codesize of this block. CurCodeSize = ReadVBR(bitc::CodeLenWidth); @@ -188,7 +218,13 @@ // Block tail: //[END_BLOCK, align4bytes] SkipToWord(); -CurCodeSize = BlockScope.back(); +CurCodeSize = BlockScope.back().PrevCodeSize; + +// Delete abbrevs from popped scope. +for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) + delete CurAbbrevs[i]; + +BlockScope.back().PrevAbbrevs.swap(CurAbbrevs); BlockScope.pop_back(); return false; } @@ -206,10 +242,57 @@ return Code; } -assert(0 Reading with abbrevs not implemented!); -return 0; +unsigned AbbrevNo = AbbrevID-bitc::FIRST_ABBREV; +assert(AbbrevNo CurAbbrevs.size() Invalid abbrev #!); +BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo]; + +for (unsigned i = 0, e = Abbv-getNumOperandInfos(); i != e; ++i) { + const BitCodeAbbrevOp Op = Abbv-getOperandInfo(i); + if (Op.isLiteral()) { +// If the abbrev specifies the literal value to use, use it. +Vals.push_back(Op.getLiteralValue()); + } else { +// Decode the value as we are commanded. +switch (Op.getEncoding()) { +default: assert(0 Unknown encoding!); +case BitCodeAbbrevOp::FixedWidth: + Vals.push_back(Read(Op.getEncodingData())); + break; +case BitCodeAbbrevOp::VBR: + Vals.push_back(ReadVBR64(Op.getEncodingData())); + break; +} + } +} + +unsigned Code = Vals[0]; +Vals.erase(Vals.begin()); +return Code; } + //======// + // Abbrev Processing + //======// + + void ReadAbbrevRecord() { +BitCodeAbbrev *Abbv = new BitCodeAbbrev(); +unsigned NumOpInfo = ReadVBR(5); +for (unsigned i = 0; i != NumOpInfo; ++i) { + bool IsLiteral = Read(1); + if (IsLiteral) { +Abbv-Add(BitCodeAbbrevOp(ReadVBR64(8))); +continue; + } + + BitCodeAbbrevOp::Encoding E = (BitCodeAbbrevOp::Encoding)Read(3); + if (BitCodeAbbrevOp::hasEncodingData(E)) { +Abbv-Add(BitCodeAbbrevOp(E, ReadVBR64(5))); + } else { +assert(0 unimp); + } +} +CurAbbrevs.push_back(Abbv); + } };
[llvm-commits] CVS: llvm/lib/Bitcode/Writer/Writer.cpp
Changes in directory llvm/lib/Bitcode/Writer: Writer.cpp updated: 1.3 - 1.4 --- Log message: implement reading of abbrevs, and writing of abbreviated global varrs. --- Diffs of the changes: (+7 -3) Writer.cpp | 10 +++--- 1 files changed, 7 insertions(+), 3 deletions(-) Index: llvm/lib/Bitcode/Writer/Writer.cpp diff -u llvm/lib/Bitcode/Writer/Writer.cpp:1.3 llvm/lib/Bitcode/Writer/Writer.cpp:1.4 --- llvm/lib/Bitcode/Writer/Writer.cpp:1.3 Mon Apr 23 11:04:05 2007 +++ llvm/lib/Bitcode/Writer/Writer.cpp Mon Apr 23 13:58:34 2007 @@ -204,9 +204,11 @@ // compute the maximum alignment value. std::mapstd::string, unsigned SectionMap; unsigned MaxAlignment = 0; + unsigned MaxGlobalType = 0; for (Module::const_global_iterator GV = M-global_begin(),E = M-global_end(); GV != E; ++GV) { MaxAlignment = std::max(MaxAlignment, GV-getAlignment()); +MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV-getType())); if (!GV-hasSection()) continue; // Give section names unique ID's. @@ -229,10 +231,12 @@ // Emit abbrev for globals, now that we know # sections and max alignment. unsigned SimpleGVarAbbrev = 0; - if (!M-global_empty() 0) { + if (!M-global_empty()) { // Add an abbrev for common globals with no visibility or thread localness. BitCodeAbbrev *Abbv = new BitCodeAbbrev(); Abbv-Add(BitCodeAbbrevOp(bitc::MODULE_CODE_GLOBALVAR)); +Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, + Log2_32_Ceil(MaxGlobalType+1))); Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, 1)); // Constant. Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));// Initializer. Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, 3)); // Linkage. @@ -241,7 +245,7 @@ else { unsigned MaxEncAlignment = Log2_32(MaxAlignment)+1; Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, - Log2_32_Ceil(MaxEncAlignment))); + Log2_32_Ceil(MaxEncAlignment+1))); } if (SectionMap.empty())// Section. Abbv-Add(BitCodeAbbrevOp(0)); @@ -300,7 +304,7 @@ /// WriteModule - Emit the specified module to the bitstream. static void WriteModule(const Module *M, BitstreamWriter Stream) { - Stream.EnterSubblock(bitc::MODULE_BLOCK_ID, 2); + Stream.EnterSubblock(bitc::MODULE_BLOCK_ID, 3); // Emit the version number if it is non-zero. if (CurVersion) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Changes in directory llvm/lib/Bitcode/Reader: BitcodeReader.cpp updated: 1.2 - 1.3 --- Log message: implement reading of abbrevs, and writing of abbreviated global varrs. --- Diffs of the changes: (+6 -3) BitcodeReader.cpp |9 ++--- 1 files changed, 6 insertions(+), 3 deletions(-) Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.2 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.3 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.2 Mon Apr 23 11:04:05 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 23 13:58:34 2007 @@ -94,7 +94,8 @@ } if (Code == bitc::DEFINE_ABBREV) { - assert(0 Abbrevs not implemented yet!); + Stream.ReadAbbrevRecord(); + continue; } // Read a record. @@ -231,7 +232,8 @@ } if (Code == bitc::DEFINE_ABBREV) { - assert(0 Abbrevs not implemented yet!); + Stream.ReadAbbrevRecord(); + continue; } // Read a record. @@ -294,7 +296,8 @@ } if (Code == bitc::DEFINE_ABBREV) { - assert(0 Abbrevs not implemented yet!); + Stream.ReadAbbrevRecord(); + continue; } // Read a record. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp
Changes in directory llvm/lib/CodeGen: AsmPrinter.cpp updated: 1.154 - 1.155 --- Log message: make EmitAlignment work the way Chris says it should --- Diffs of the changes: (+3 -1) AsmPrinter.cpp |4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.154 llvm/lib/CodeGen/AsmPrinter.cpp:1.155 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.154 Tue Mar 6 13:25:02 2007 +++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Apr 23 14:58:54 2007 @@ -579,8 +579,10 @@ //===--===// // EmitAlignment - Emit an alignment directive to the specified power of two. +// Use the maximum of the specified alignment and the alignment from the +// specified GlobalValue (if any). void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const { - if (GV GV-getAlignment()) + if (GV GV-getAlignment() Log2_32(GV-getAlignment()) NumBits) NumBits = Log2_32(GV-getAlignment()); if (NumBits == 0) return; // No need to emit alignment. if (TAI-getAlignmentIsInBytes()) NumBits = 1 NumBits; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/TargetAsmInfo.cpp
Changes in directory llvm/lib/Target: TargetAsmInfo.cpp updated: 1.22 - 1.23 --- Log message: Fix generic getInlineAsmLength --- Diffs of the changes: (+18 -4) TargetAsmInfo.cpp | 22 ++ 1 files changed, 18 insertions(+), 4 deletions(-) Index: llvm/lib/Target/TargetAsmInfo.cpp diff -u llvm/lib/Target/TargetAsmInfo.cpp:1.22 llvm/lib/Target/TargetAsmInfo.cpp:1.23 --- llvm/lib/Target/TargetAsmInfo.cpp:1.22 Fri Apr 20 16:38:10 2007 +++ llvm/lib/Target/TargetAsmInfo.cpp Mon Apr 23 15:00:17 2007 @@ -13,6 +13,8 @@ //===--===// #include llvm/Target/TargetAsmInfo.h +#include cctype +#include cstring using namespace llvm; @@ -100,15 +102,27 @@ /// Measure the specified inline asm to determine an approximation of its /// length. +/// Comments (which run till the next SeparatorChar or newline) do not +/// count as an instruction. +/// Any other non-whitespace text is considered an instruction, with +/// multiple instructions separated by SeparatorChar or newlines. +/// Variable-length instructions are not handled here; this function +/// may be overloaded in the target code to do that. unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const { // Count the number of instructions in the asm. - unsigned NumInsts = 0; + bool atInsnStart = true; + unsigned Length = 0; for (; *Str; ++Str) { if (*Str == '\n' || *Str == SeparatorChar) - ++NumInsts; + atInsnStart = true; +if (atInsnStart !isspace(*Str)) { + Length += MaxInstLength; + atInsnStart = false; +} +if (atInsnStart strncmp(Str, CommentString, strlen(CommentString))==0) + atInsnStart = false; } - // Multiply by the worst-case length for each instruction. - return NumInsts * MaxInstLength; + return Length; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp ARMTargetAsmInfo.h
Changes in directory llvm/lib/Target/ARM: ARMTargetAsmInfo.cpp updated: 1.13 - 1.14 ARMTargetAsmInfo.h updated: 1.1 - 1.2 --- Log message: add isThumb (unused as yet) --- Diffs of the changes: (+5 -0) ARMTargetAsmInfo.cpp |3 +++ ARMTargetAsmInfo.h |2 ++ 2 files changed, 5 insertions(+) Index: llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp diff -u llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.13 llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.14 --- llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.13 Wed Mar 7 19:25:25 2007 +++ llvm/lib/Target/ARM/ARMTargetAsmInfo.cppMon Apr 23 15:04:35 2007 @@ -13,6 +13,8 @@ #include ARMTargetAsmInfo.h #include ARMTargetMachine.h +#include cstring +#include cctype using namespace llvm; ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine TM) { @@ -80,4 +82,5 @@ InlineAsmStart = @ InlineAsm Start; InlineAsmEnd = @ InlineAsm End; LCOMMDirective = \t.lcomm\t; + isThumb = Subtarget-isThumb(); } Index: llvm/lib/Target/ARM/ARMTargetAsmInfo.h diff -u llvm/lib/Target/ARM/ARMTargetAsmInfo.h:1.1 llvm/lib/Target/ARM/ARMTargetAsmInfo.h:1.2 --- llvm/lib/Target/ARM/ARMTargetAsmInfo.h:1.1 Thu Sep 7 17:05:01 2006 +++ llvm/lib/Target/ARM/ARMTargetAsmInfo.h Mon Apr 23 15:04:35 2007 @@ -23,6 +23,8 @@ struct ARMTargetAsmInfo : public TargetAsmInfo { ARMTargetAsmInfo(const ARMTargetMachine TM); + +bool isThumb; }; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/ARM/ARMMachineFunctionInfo.h ARMAsmPrinter.cpp
Changes in directory llvm/lib/Target/ARM: ARMMachineFunctionInfo.h updated: 1.8 - 1.9 ARMAsmPrinter.cpp updated: 1.65 - 1.66 --- Log message: add Align field, and use when generating function alignment --- Diffs of the changes: (+13 -3) ARMAsmPrinter.cpp|2 +- ARMMachineFunctionInfo.h | 14 -- 2 files changed, 13 insertions(+), 3 deletions(-) Index: llvm/lib/Target/ARM/ARMMachineFunctionInfo.h diff -u llvm/lib/Target/ARM/ARMMachineFunctionInfo.h:1.8 llvm/lib/Target/ARM/ARMMachineFunctionInfo.h:1.9 --- llvm/lib/Target/ARM/ARMMachineFunctionInfo.h:1.8Thu Mar 1 02:26:31 2007 +++ llvm/lib/Target/ARM/ARMMachineFunctionInfo.hMon Apr 23 15:07:25 2007 @@ -27,9 +27,14 @@ class ARMFunctionInfo : public MachineFunctionInfo { /// isThumb - True if this function is compiled under Thumb mode. - /// + /// Used to initialized Align, so must precede it. bool isThumb; + /// Align - required alignment. ARM functions and Thumb functions with + /// constant pools require 4-byte alignment; other Thumb functions + /// require only 2-byte alignment. + unsigned Align; + /// VarArgsRegSaveSize - Size of the register save area for vararg functions. /// unsigned VarArgsRegSaveSize; @@ -84,7 +89,8 @@ public: ARMFunctionInfo() : -isThumb(false), +isThumb(false), +Align(2U), VarArgsRegSaveSize(0), HasStackFrame(false), LRSpilledForFarJump(false), R3IsLiveIn(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), @@ -94,6 +100,7 @@ ARMFunctionInfo(MachineFunction MF) : isThumb(MF.getTarget().getSubtargetARMSubtarget().isThumb()), +Align(isThumb ? 1U : 2U), VarArgsRegSaveSize(0), HasStackFrame(false), LRSpilledForFarJump(false), R3IsLiveIn(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), @@ -104,6 +111,9 @@ bool isThumbFunction() const { return isThumb; } + unsigned getAlign() const { return Align; } + void setAlign(unsigned a) { Align = a; } + unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; } void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; } Index: llvm/lib/Target/ARM/ARMAsmPrinter.cpp diff -u llvm/lib/Target/ARM/ARMAsmPrinter.cpp:1.65 llvm/lib/Target/ARM/ARMAsmPrinter.cpp:1.66 --- llvm/lib/Target/ARM/ARMAsmPrinter.cpp:1.65 Sat Apr 21 19:04:12 2007 +++ llvm/lib/Target/ARM/ARMAsmPrinter.cpp Mon Apr 23 15:07:25 2007 @@ -211,7 +211,7 @@ O Directive CurrentFnName \n; if (AFI-isThumbFunction()) { -EmitAlignment(1, F); +EmitAlignment(AFI-getAlign(), F); O \t.code\t16\n; O \t.thumb_func; if (Subtarget-isTargetDarwin()) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
Changes in directory llvm/lib/Target/ARM: ARMConstantIslandPass.cpp updated: 1.35 - 1.36 --- Log message: Make Thumb funcs containing islands 4-byte aligned. Fix bugs maintaining BBOffsets and BBSizes when adjusting conditional branches. --- Diffs of the changes: (+19 -6) ARMConstantIslandPass.cpp | 25 +++-- 1 files changed, 19 insertions(+), 6 deletions(-) Index: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp diff -u llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.35 llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.36 --- llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.35 Tue Apr 3 18:39:48 2007 +++ llvm/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Apr 23 15:09:04 2007 @@ -121,7 +121,6 @@ bool HasFarJump; const TargetInstrInfo *TII; -const ARMFunctionInfo *AFI; bool isThumb; public: virtual bool runOnMachineFunction(MachineFunction Fn); @@ -173,9 +172,9 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction Fn) { MachineConstantPool MCP = *Fn.getConstantPool(); + ARMFunctionInfo *AFI = Fn.getInfoARMFunctionInfo(); TII = Fn.getTarget().getInstrInfo(); - AFI = Fn.getInfoARMFunctionInfo(); isThumb = AFI-isThumbFunction(); HasFarJump = false; @@ -184,11 +183,18 @@ // the numbers agree with the position of the block in the function. Fn.RenumberBlocks(); + /// Thumb functions containing constant pools get 2-byte alignment. This is so + /// we can keep exact track of where the alignment padding goes. Set default. + AFI-setAlign(isThumb ? 1U : 2U); + // Perform the initial placement of the constant pool entries. To start with, // we put them all at the end of the function. std::vectorMachineInstr* CPEMIs; - if (!MCP.isEmpty()) + if (!MCP.isEmpty()) { DoInitialPlacement(Fn, CPEMIs); +if (isThumb) + AFI-setAlign(2U); + } /// The next UID to take is the first unused one. NextUID = CPEMIs.size(); @@ -1071,6 +1077,9 @@ SplitBlockBeforeInstr(MI); // No need for the branch to the next block. We're adding a unconditional // branch to the destination. +int delta = ARM::GetInstSize(MBB-back()); +BBSizes[MBB-getNumber()] -= delta; +AdjustBBOffsetsAfter(MBB, -delta); MBB-back().eraseFromParent(); } MachineBasicBlock *NextBB = next(MachineFunction::iterator(MBB)); @@ -1079,18 +1088,22 @@ also invert condition and change dest. to BB# NextBB-getNumber() \n; - // Insert a unconditional branch and replace the conditional branch. + // Insert a new conditional branch and a new unconditional branch. // Also update the ImmBranch as well as adding a new entry for the new branch. BuildMI(MBB, TII-get(MI-getOpcode())).addMBB(NextBB).addImm(CC); Br.MI = MBB-back(); + BBSizes[MBB-getNumber()] += ARM::GetInstSize(MBB-back()); BuildMI(MBB, TII-get(Br.UncondBr)).addMBB(DestBB); + BBSizes[MBB-getNumber()] += ARM::GetInstSize(MBB-back()); unsigned MaxDisp = getUnconditionalBrDisp(Br.UncondBr); ImmBranches.push_back(ImmBranch(MBB-back(), MaxDisp, false, Br.UncondBr)); + + // Remove the old conditional branch. It may or may not still be in MBB. + BBSizes[MI-getParent()-getNumber()] -= ARM::GetInstSize(MI); MI-eraseFromParent(); - // Increase the size of MBB to account for the new unconditional branch. + // The net size change is an addition of one unconditional branch. int delta = ARM::GetInstSize(MBB-back()); - BBSizes[MBB-getNumber()] += delta; AdjustBBOffsetsAfter(MBB, delta); return true; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Bitcode/BitstreamWriter.h LLVMBitCodes.h
Changes in directory llvm/include/llvm/Bitcode: BitstreamWriter.h updated: 1.5 - 1.6 LLVMBitCodes.h updated: 1.1 - 1.2 --- Log message: Fix a bug in bitstream writer handling abbrevs, add value symtab --- Diffs of the changes: (+12 -6) BitstreamWriter.h | 11 ++- LLVMBitCodes.h|7 ++- 2 files changed, 12 insertions(+), 6 deletions(-) Index: llvm/include/llvm/Bitcode/BitstreamWriter.h diff -u llvm/include/llvm/Bitcode/BitstreamWriter.h:1.5 llvm/include/llvm/Bitcode/BitstreamWriter.h:1.6 --- llvm/include/llvm/Bitcode/BitstreamWriter.h:1.5 Mon Apr 23 13:57:32 2007 +++ llvm/include/llvm/Bitcode/BitstreamWriter.h Mon Apr 23 15:34:46 2007 @@ -147,12 +147,8 @@ EmitVBR(CodeLen, bitc::CodeLenWidth); FlushToWord(); BlockScope.push_back(Block(CurCodeSize, Out.size()/4)); - -// Delete all abbrevs. -for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) - delete CurAbbrevs[i]; - BlockScope.back().PrevAbbrevs.swap(CurAbbrevs); + // Emit a placeholder, which will be replaced when the block is popped. Emit(0, bitc::BlockSizeWidth); @@ -161,6 +157,11 @@ void ExitBlock() { assert(!BlockScope.empty() Block scope imbalance!); + +// Delete all abbrevs. +for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) + delete CurAbbrevs[i]; + const Block B = BlockScope.back(); // Block tail: Index: llvm/include/llvm/Bitcode/LLVMBitCodes.h diff -u llvm/include/llvm/Bitcode/LLVMBitCodes.h:1.1 llvm/include/llvm/Bitcode/LLVMBitCodes.h:1.2 --- llvm/include/llvm/Bitcode/LLVMBitCodes.h:1.1Sun Apr 22 20:01:15 2007 +++ llvm/include/llvm/Bitcode/LLVMBitCodes.hMon Apr 23 15:34:46 2007 @@ -33,7 +33,7 @@ GLOBALCONSTANTS_BLOCK_ID = 3, FUNCTION_BLOCK_ID= 4, TYPE_SYMTAB_BLOCK_ID = 5, -GLOBAL_SYMTAB_BLOCK_ID = 6 +VALUE_SYMTAB_BLOCK_ID= 6 }; @@ -81,6 +81,11 @@ TST_ENTRY_CODE = 1 // TST_ENTRY: [typeid, namelen, namechar x N] }; + // The value symbol table only has one code (VST_ENTRY_CODE). + enum ValueSymtabCodes { +VST_ENTRY_CODE = 1 // VST_ENTRY: [valid, namelen, namechar x N] + }; + } // End bitc namespace } // End llvm namespace ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Writer/Writer.cpp
Changes in directory llvm/lib/Bitcode/Writer: Writer.cpp updated: 1.4 - 1.5 --- Log message: write out the symtab for globals. --- Diffs of the changes: (+70 -33) Writer.cpp | 103 + 1 files changed, 70 insertions(+), 33 deletions(-) Index: llvm/lib/Bitcode/Writer/Writer.cpp diff -u llvm/lib/Bitcode/Writer/Writer.cpp:1.4 llvm/lib/Bitcode/Writer/Writer.cpp:1.5 --- llvm/lib/Bitcode/Writer/Writer.cpp:1.4 Mon Apr 23 13:58:34 2007 +++ llvm/lib/Bitcode/Writer/Writer.cpp Mon Apr 23 15:35:01 2007 @@ -18,6 +18,7 @@ #include llvm/DerivedTypes.h #include llvm/Module.h #include llvm/TypeSymbolTable.h +#include llvm/ValueSymbolTable.h #include llvm/Support/MathExtras.h using namespace llvm; @@ -126,39 +127,6 @@ Stream.ExitBlock(); } -/// WriteTypeSymbolTable - Emit a block for the specified type symtab. -static void WriteTypeSymbolTable(const TypeSymbolTable TST, - const ValueEnumerator VE, - BitstreamWriter Stream) { - if (TST.empty()) return; - - Stream.EnterSubblock(bitc::TYPE_SYMTAB_BLOCK_ID, 3); - - // FIXME: Set up the abbrev, we know how many types there are! - // FIXME: We know if the type names can use 7-bit ascii. - - SmallVectorunsigned, 64 NameVals; - - for (TypeSymbolTable::const_iterator TI = TST.begin(), TE = TST.end(); - TI != TE; ++TI) { -unsigned AbbrevToUse = 0; - -// TST_ENTRY: [typeid, namelen, namechar x N] -NameVals.push_back(VE.getTypeID(TI-second)); - -const std::string Str = TI-first; -NameVals.push_back(Str.size()); -for (unsigned i = 0, e = Str.size(); i != e; ++i) - NameVals.push_back(Str[i]); - -// Emit the finished record. -Stream.EmitRecord(bitc::TST_ENTRY_CODE, NameVals, AbbrevToUse); -NameVals.clear(); - } - - Stream.ExitBlock(); -} - static unsigned getEncodedLinkage(const GlobalValue *GV) { switch (GV-getLinkage()) { default: assert(0 Invalid linkage!); @@ -302,6 +270,71 @@ } +/// WriteTypeSymbolTable - Emit a block for the specified type symtab. +static void WriteTypeSymbolTable(const TypeSymbolTable TST, + const ValueEnumerator VE, + BitstreamWriter Stream) { + if (TST.empty()) return; + + Stream.EnterSubblock(bitc::TYPE_SYMTAB_BLOCK_ID, 3); + + // FIXME: Set up the abbrev, we know how many types there are! + // FIXME: We know if the type names can use 7-bit ascii. + + SmallVectorunsigned, 64 NameVals; + + for (TypeSymbolTable::const_iterator TI = TST.begin(), TE = TST.end(); + TI != TE; ++TI) { +unsigned AbbrevToUse = 0; + +// TST_ENTRY: [typeid, namelen, namechar x N] +NameVals.push_back(VE.getTypeID(TI-second)); + +const std::string Str = TI-first; +NameVals.push_back(Str.size()); +for (unsigned i = 0, e = Str.size(); i != e; ++i) + NameVals.push_back(Str[i]); + +// Emit the finished record. +Stream.EmitRecord(bitc::TST_ENTRY_CODE, NameVals, AbbrevToUse); +NameVals.clear(); + } + + Stream.ExitBlock(); +} + +// Emit names for globals/functions etc. +static void WriteValueSymbolTable(const ValueSymbolTable VST, + const ValueEnumerator VE, + BitstreamWriter Stream) { + if (VST.empty()) return; + Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3); + + // FIXME: Set up the abbrev, we know how many values there are! + // FIXME: We know if the type names can use 7-bit ascii. + SmallVectorunsigned, 64 NameVals; + + for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end(); + SI != SE; ++SI) { +unsigned AbbrevToUse = 0; + +// VST_ENTRY: [valueid, namelen, namechar x N] +NameVals.push_back(VE.getValueID(SI-getValue())); + +NameVals.push_back(SI-getKeyLength()); +for (const char *P = SI-getKeyData(), + *E = SI-getKeyData()+SI-getKeyLength(); P != E; ++P) + NameVals.push_back((unsigned char)*P); + +// Emit the finished record. +Stream.EmitRecord(bitc::VST_ENTRY_CODE, NameVals, AbbrevToUse); +NameVals.clear(); + } + Stream.ExitBlock(); +} + + + /// WriteModule - Emit the specified module to the bitstream. static void WriteModule(const Module *M, BitstreamWriter Stream) { Stream.EnterSubblock(bitc::MODULE_BLOCK_ID, 3); @@ -327,6 +360,10 @@ // Emit the type symbol table information. WriteTypeSymbolTable(M-getTypeSymbolTable(), VE, Stream); + + // Emit names for globals/functions etc. + WriteValueSymbolTable(M-getValueSymbolTable(), VE, Stream); + Stream.ExitBlock(); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/ADT/SmallString.h
Changes in directory llvm/include/llvm/ADT: SmallString.h updated: 1.1 - 1.2 --- Log message: add a missing operator --- Diffs of the changes: (+5 -0) SmallString.h |5 + 1 files changed, 5 insertions(+) Index: llvm/include/llvm/ADT/SmallString.h diff -u llvm/include/llvm/ADT/SmallString.h:1.1 llvm/include/llvm/ADT/SmallString.h:1.2 --- llvm/include/llvm/ADT/SmallString.h:1.1 Sun Oct 29 21:39:20 2006 +++ llvm/include/llvm/ADT/SmallString.h Mon Apr 23 15:58:14 2007 @@ -49,6 +49,11 @@ this-append(RHS, RHS+strlen(RHS)); return *this; } + SmallString operator+=(char C) { +this-push_back(C); +return *this; + } + }; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/test/lib/llvm.exp
Changes in directory llvm/test/lib: llvm.exp updated: 1.22 - 1.23 --- Log message: Dan is right, using string first would produce false positives. So, devolve the check to a comparison against each component in the string. Fortunately there isn't many of them. --- Diffs of the changes: (+9 -7) llvm.exp | 16 +--- 1 files changed, 9 insertions(+), 7 deletions(-) Index: llvm/test/lib/llvm.exp diff -u llvm/test/lib/llvm.exp:1.22 llvm/test/lib/llvm.exp:1.23 --- llvm/test/lib/llvm.exp:1.22 Sun Apr 22 09:14:11 2007 +++ llvm/test/lib/llvm.exp Mon Apr 23 16:21:53 2007 @@ -207,13 +207,15 @@ fortran { set file fcc1 } default { return 0 } } - if { [ string first $lang $llvmgcc_langs ] = 0 } { -# FIXME: Knowing it is configured is not enough. We should do two more -# checks here. First, we need to run llvm-gcc -print-prog-name=$file to get -# the path to the compiler. If we don't get a path, the language isn't -# properly configured or built. If we do get a path, we should check to make -# sure that it is executable and perhaps even try executing it. -return 1; + foreach supported_lang [split $llvmgcc_langs ,] { +if { $lang == $supported_lang } { + # FIXME: Knowing it is configured is not enough. We should do two more + # checks here. First, we need to run llvm-gcc -print-prog-name=$file to + # get the path to the compiler. If we don't get a path, the language isn't + # properly configured or built. If we do get a path, we should check to + # make sure that it is executable and perhaps even try executing it. + return 1; +} } return 0; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Writer/ValueEnumerator.h
Changes in directory llvm/lib/Bitcode/Writer: ValueEnumerator.h updated: 1.1 - 1.2 --- Log message: fix off-by one --- Diffs of the changes: (+1 -1) ValueEnumerator.h |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Bitcode/Writer/ValueEnumerator.h diff -u llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.1 llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.2 --- llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.1 Sun Apr 22 01:24:45 2007 +++ llvm/lib/Bitcode/Writer/ValueEnumerator.h Mon Apr 23 16:23:41 2007 @@ -54,7 +54,7 @@ unsigned getValueID(const Value *V) const { ValueMapType::const_iterator I = ValueMap.find(V); assert(I != ValueMap.end() Value not in slotcalculator!); -return I-second; +return I-second-1; } unsigned getTypeID(const Type *T) const { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp BitcodeReader.h
Changes in directory llvm/lib/Bitcode/Reader: BitcodeReader.cpp updated: 1.3 - 1.4 BitcodeReader.h updated: 1.3 - 1.4 --- Log message: Read global symtab --- Diffs of the changes: (+59 -3) BitcodeReader.cpp | 59 +++--- BitcodeReader.h |3 ++ 2 files changed, 59 insertions(+), 3 deletions(-) Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.3 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.4 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.3 Mon Apr 23 13:58:34 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 23 16:26:05 2007 @@ -15,12 +15,14 @@ #include llvm/Bitcode/BitstreamReader.h #include llvm/DerivedTypes.h #include llvm/Module.h +#include llvm/ADT/SmallString.h using namespace llvm; /// ConvertToString - Convert a string from a record into an std::string, return /// true on failure. +templatetypename StrTy static bool ConvertToString(SmallVectoruint64_t, 64 Record, unsigned Idx, -std::string Result) { +StrTy Result) { if (Record.size() Idx+1 || Record.size() Record[Idx]+Idx+1) return true; @@ -255,6 +257,52 @@ } } +bool BitcodeReader::ParseValueSymbolTable(BitstreamReader Stream) { + if (Stream.EnterSubBlock()) +return Error(Malformed block record); + + SmallVectoruint64_t, 64 Record; + + // Read all the records for this value table. + SmallString128 ValueName; + while (1) { +unsigned Code = Stream.ReadCode(); +if (Code == bitc::END_BLOCK) + return Stream.ReadBlockEnd(); + +if (Code == bitc::ENTER_SUBBLOCK) { + // No known subblocks, always skip them. + Stream.ReadSubBlockID(); + if (Stream.SkipBlock()) +return Error(Malformed block record); + continue; +} + +if (Code == bitc::DEFINE_ABBREV) { + Stream.ReadAbbrevRecord(); + continue; +} + +// Read a record. +Record.clear(); +switch (Stream.ReadRecord(Code, Record)) { +default: // Default behavior: unknown type. + break; +case bitc::VST_ENTRY_CODE:// VST_ENTRY: [valueid, namelen, namechar x N] + if (ConvertToString(Record, 1, ValueName)) +return Error(Invalid TST_ENTRY record); + unsigned ValueID = Record[0]; + if (ValueID = ValueList.size()) +return Error(Invalid Value ID in VST_ENTRY record); + Value *V = ValueList[ValueID]; + + V-setName(ValueName[0], ValueName.size()); + ValueName.clear(); + break; +} + } +} + bool BitcodeReader::ParseModule(BitstreamReader Stream, const std::string ModuleID) { @@ -291,6 +339,10 @@ if (ParseTypeSymbolTable(Stream)) return true; break; + case bitc::VALUE_SYMTAB_BLOCK_ID: +if (ParseValueSymbolTable(Stream)) + return true; +break; } continue; } @@ -377,7 +429,8 @@ NewGV-setVisibility(Visibility); NewGV-setThreadLocal(isThreadLocal); - // TODO: Add to value table. + ValueList.push_back(NewGV); + // TODO: remember initializer/global pair for later substitution. break; } @@ -407,7 +460,7 @@ } Func-setVisibility(GetDecodedVisibility(Record[6])); - // TODO: Add to value table. + ValueList.push_back(Func); // TODO: remember initializer/global pair for later substitution. break; } Index: llvm/lib/Bitcode/Reader/BitcodeReader.h diff -u llvm/lib/Bitcode/Reader/BitcodeReader.h:1.3 llvm/lib/Bitcode/Reader/BitcodeReader.h:1.4 --- llvm/lib/Bitcode/Reader/BitcodeReader.h:1.3 Sun Apr 22 20:01:37 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.h Mon Apr 23 16:26:05 2007 @@ -21,11 +21,13 @@ namespace llvm { class BitstreamReader; + class Value; class BitcodeReader : public ModuleProvider { const char *ErrorString; std::vectorPATypeHolder TypeList; + std::vectorValue* ValueList; public: virtual ~BitcodeReader() {} @@ -59,6 +61,7 @@ bool ParseModule(BitstreamReader Stream, const std::string ModuleID); bool ParseTypeTable(BitstreamReader Stream); bool ParseTypeSymbolTable(BitstreamReader Stream); + bool ParseValueSymbolTable(BitstreamReader Stream); }; } // End llvm namespace ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [126432] clarify the relation of this file with README.LLVM.
Revision: 126432 Author: clattner Date: 2007-04-23 14:52:56 -0700 (Mon, 23 Apr 2007) Log Message: --- clarify the relation of this file with README.LLVM. Modified Paths: -- apple-local/branches/llvm/README.Apple Modified: apple-local/branches/llvm/README.Apple === --- apple-local/branches/llvm/README.Apple 2007-04-23 20:32:59 UTC (rev 126431) +++ apple-local/branches/llvm/README.Apple 2007-04-23 21:52:56 UTC (rev 126432) @@ -1,5 +1,13 @@ APPLE LOCAL file documentation +//===--===// +NOTE: This file contains a description of the non-llvm GCC that llvm-gcc is +based on. For information on building llvm-gcc for any platform (including +Apple), please follow the directions in README.LLVM. + +//===--===// + + This file describes Apple's version of GCC 4.x modified for Darwin / Mac OS X. Although Apple's stated policy is to contribute all of its GCC work to the FSF GCC mainstream, at any given moment there will be ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [126435] Fix PR 1344
Revision: 126435 Author: dpatel Date: 2007-04-23 15:07:27 -0700 (Mon, 23 Apr 2007) Log Message: --- Fix PR 1344 Modified Paths: -- apple-local/branches/llvm/gcc/llvm-types.cpp Modified: apple-local/branches/llvm/gcc/llvm-types.cpp === --- apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-23 22:06:28 UTC (rev 126434) +++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-23 22:07:27 UTC (rev 126435) @@ -1560,8 +1560,10 @@ bool OldConvertingStruct = ConvertingStruct; ConvertingStruct = true; - // Find the type with the largest size, and if we have multiple things with - // the same size, the thing with the largest alignment. + // Find the type with the largest aligment, and if we have multiple types with + // the same alignment, select one with largest size. If type with max. align + // is smaller then other types then we will add padding later on anyway to + // match union size. const TargetData TD = getTargetData(); const Type *UnionTy = 0; unsigned MaxSize = 0, MaxAlign = 0; @@ -1576,9 +1578,10 @@ const Type *TheTy = ConvertType(TREE_TYPE(Field)); unsigned Size = TD.getTypeSize(TheTy); unsigned Align = TD.getABITypeAlignment(TheTy); -if (UnionTy == 0 || SizeMaxSize || (Size == MaxSize Align MaxAlign)) { +if (UnionTy == 0 || Align MaxAlign +|| (MaxAlign == Align Size MaxSize)) { UnionTy = TheTy; - MaxSize = Size; + MaxSize = MAX(MaxSize, Size); MaxAlign = Align; } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/test/Transforms/LoopStrengthReduce/2007-04-23-UseIterator.ll
Changes in directory llvm/test/Transforms/LoopStrengthReduce: 2007-04-23-UseIterator.ll added (r1.1) --- Log message: New test. --- Diffs of the changes: (+71 -0) 2007-04-23-UseIterator.ll | 71 ++ 1 files changed, 71 insertions(+) Index: llvm/test/Transforms/LoopStrengthReduce/2007-04-23-UseIterator.ll diff -c /dev/null llvm/test/Transforms/LoopStrengthReduce/2007-04-23-UseIterator.ll:1.1 *** /dev/null Mon Apr 23 17:40:03 2007 --- llvm/test/Transforms/LoopStrengthReduce/2007-04-23-UseIterator.ll Mon Apr 23 17:39:53 2007 *** *** 0 --- 1,71 + ; RUN: llvm-as %s | opt -loop-reduce -disable-output + + 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 + + target triple = i686-apple-darwin9 + + define i8* @foo( i8* %ABC) { + entry: + switch i8 0, label %bb129 [ +i8 0, label %UnifiedReturnBlock +i8 9, label %UnifiedReturnBlock +i8 32, label %UnifiedReturnBlock +i8 35, label %UnifiedReturnBlock +i8 37, label %bb16.preheader + ] + + bb16.preheader: ; preds = %entry + br label %bb16 + + bb16: ; preds = %cond_next102, %bb16.preheader + %indvar = phi i32 [ %indvar.next, %cond_next102 ], [ 0, %bb16.preheader ] ; i32 [#uses=2] + %ABC.2146.0.rec = mul i32 %indvar, 3; i32 [#uses=1] + br i1 false, label %UnifiedReturnBlock.loopexit, label %cond_next102 + + cond_next102: ; preds = %bb16 + %tmp138145.rec = add i32 %ABC.2146.0.rec, 3 ; i32 [#uses=1] + %tmp138145 = getelementptr i8* %ABC, i32 %tmp138145.rec ; i8* [#uses=4] + %indvar.next = add i32 %indvar, 1 ; i32 [#uses=1] + switch i8 0, label %bb129.loopexit [ +i8 0, label %UnifiedReturnBlock.loopexit +i8 9, label %UnifiedReturnBlock.loopexit +i8 32, label %UnifiedReturnBlock.loopexit +i8 35, label %UnifiedReturnBlock.loopexit +i8 37, label %bb16 + ] + + bb129.loopexit: ; preds = %cond_next102 + br label %bb129 + + bb129:; preds = %bb129.loopexit, %entry + ret i8* null + + UnifiedReturnBlock.loopexit: ; preds = %cond_next102, %cond_next102, %cond_next102, %cond_next102, %bb16 + %UnifiedRetVal.ph = phi i8* [ %tmp138145, %cond_next102 ], [ %tmp138145, %cond_next102 ], [ %tmp138145, %cond_next102 ], [ %tmp138145, %cond_next102 ], [ null, %bb16 ] ; i8* [#uses=0] + br label %UnifiedReturnBlock + + UnifiedReturnBlock: ; preds = %UnifiedReturnBlock.loopexit, %entry, %entry, %entry, %entry + ret i8* null + } + + define i8* @bar() { + entry: + switch i8 0, label %bb158 [ +i8 37, label %bb74 +i8 58, label %cond_true +i8 64, label %bb11 + ] + + bb11: ; preds = %entry + ret i8* null + + cond_true:; preds = %entry + ret i8* null + + bb74: ; preds = %entry + ret i8* null + + bb158:; preds = %entry + ret i8* null + } + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.130 - 1.131 --- Log message: Fix http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048333.html --- Diffs of the changes: (+9 -5) LoopStrengthReduce.cpp | 14 +- 1 files changed, 9 insertions(+), 5 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.130 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.131 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.130 Sun Apr 15 03:47:27 2007 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon Apr 23 17:42:03 2007 @@ -416,12 +416,16 @@ if (!getSCEVStartAndStride(ISE, L, Start, Stride)) return false; // Non-reducible symbolic expression, bail out. - for (Value::use_iterator UI = I-use_begin(), E = I-use_end(); UI != E;) { -Instruction *User = castInstruction(*UI); + std::vectorInstruction * IUsers; + // Collect all I uses now because IVUseShouldUsePostIncValue may + // invalidate use_iterator. + for (Value::use_iterator UI = I-use_begin(), E = I-use_end(); UI != E; ++UI) +IUsers.push_back(castInstruction(*UI)); -// Increment iterator now because IVUseShouldUsePostIncValue may remove -// User from the list of I users. -++UI; + for (unsigned iused_index = 0, iused_size = IUsers.size(); + iused_index != iused_size; ++iused_index) { + +Instruction *User = IUsers[iused_index]; // Do not infinitely recurse on PHI nodes. if (isaPHINode(User) Processed.count(User)) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/CodeGen/ValueTypes.h
Changes in directory llvm/include/llvm/CodeGen: ValueTypes.h updated: 1.32 - 1.33 --- Log message: Fix bug in isFloatingPoint() --- Diffs of the changes: (+1 -1) ValueTypes.h |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/ValueTypes.h diff -u llvm/include/llvm/CodeGen/ValueTypes.h:1.32 llvm/include/llvm/CodeGen/ValueTypes.h:1.33 --- llvm/include/llvm/CodeGen/ValueTypes.h:1.32 Sun Apr 1 02:17:45 2007 +++ llvm/include/llvm/CodeGen/ValueTypes.h Mon Apr 23 17:50:40 2007 @@ -85,7 +85,7 @@ /// MVT::isFloatingPoint - Return true if this is a simple FP, or a packed /// vector FP type. static inline bool isFloatingPoint(ValueType VT) { -return (VT = f32 VT = f128) || (VT = v4f32 VT = v2f64); +return (VT = f32 VT = f128) || (VT = v2f32 VT = v2f64); } /// MVT::isVector - Return true if this is a packed vector type (i.e. not ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Bitcode/LLVMBitCodes.h
Changes in directory llvm/include/llvm/Bitcode: LLVMBitCodes.h updated: 1.2 - 1.3 --- Log message: add codes for constants table --- Diffs of the changes: (+17 -3) LLVMBitCodes.h | 20 +--- 1 files changed, 17 insertions(+), 3 deletions(-) Index: llvm/include/llvm/Bitcode/LLVMBitCodes.h diff -u llvm/include/llvm/Bitcode/LLVMBitCodes.h:1.2 llvm/include/llvm/Bitcode/LLVMBitCodes.h:1.3 --- llvm/include/llvm/Bitcode/LLVMBitCodes.h:1.2Mon Apr 23 15:34:46 2007 +++ llvm/include/llvm/Bitcode/LLVMBitCodes.hMon Apr 23 18:29:59 2007 @@ -30,7 +30,7 @@ // Module sub-block id's TYPE_BLOCK_ID= 1, MODULEINFO_BLOCK_ID = 2, -GLOBALCONSTANTS_BLOCK_ID = 3, +CONSTANTS_BLOCK_ID = 3, FUNCTION_BLOCK_ID= 4, TYPE_SYMTAB_BLOCK_ID = 5, VALUE_SYMTAB_BLOCK_ID= 6 @@ -78,12 +78,26 @@ // The type symbol table only has one code (TST_ENTRY_CODE). enum TypeSymtabCodes { -TST_ENTRY_CODE = 1 // TST_ENTRY: [typeid, namelen, namechar x N] +TST_CODE_ENTRY = 1 // TST_ENTRY: [typeid, namelen, namechar x N] }; // The value symbol table only has one code (VST_ENTRY_CODE). enum ValueSymtabCodes { -VST_ENTRY_CODE = 1 // VST_ENTRY: [valid, namelen, namechar x N] +VST_CODE_ENTRY = 1 // VST_ENTRY: [valid, namelen, namechar x N] + }; + + // The constants block (CONSTANTS_BLOCK_ID) describes emission for each + // constant and maintains an implicit current type value. + enum ConstantsSymtabCodes { +CST_CODE_SETTYPE = 1, // SETTYPE: [typeid] +CST_CODE_NULL = 2, // NULL +CST_CODE_UNDEF= 3, // UNDEF +CST_CODE_INTEGER = 4, // INTEGER: [intval] +CST_CODE_WIDE_INTEGER = 5, // WIDE_INTEGER: [n, n x intval] +CST_CODE_FLOAT= 6, // FLOAT: [fpval] +CST_CODE_AGGREGATE= 7, // AGGREGATE: [n, n x value number] +CST_CODE_CONSTEXPR= 8 // CONSTEXPR: [opcode, n, n x val#] +// TODO: CE_BINOP ETC }; } // End bitc namespace ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp
Changes in directory llvm/lib/CodeGen: AsmPrinter.cpp updated: 1.155 - 1.156 --- Log message: modify per review commentary --- Diffs of the changes: (+2 -2) AsmPrinter.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.155 llvm/lib/CodeGen/AsmPrinter.cpp:1.156 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.155 Mon Apr 23 14:58:54 2007 +++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Apr 23 18:33:31 2007 @@ -582,8 +582,8 @@ // Use the maximum of the specified alignment and the alignment from the // specified GlobalValue (if any). void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const { - if (GV GV-getAlignment() Log2_32(GV-getAlignment()) NumBits) -NumBits = Log2_32(GV-getAlignment()); + if (GV GV-getAlignment()) +NumBits = std::max(NumBits, Log2_32(GV-getAlignment())); if (NumBits == 0) return; // No need to emit alignment. if (TAI-getAlignmentIsInBytes()) NumBits = 1 NumBits; O TAI-getAlignDirective() NumBits \n; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Writer/ValueEnumerator.cpp ValueEnumerator.h Writer.cpp
Changes in directory llvm/lib/Bitcode/Writer: ValueEnumerator.cpp updated: 1.1 - 1.2 ValueEnumerator.h updated: 1.2 - 1.3 Writer.cpp updated: 1.5 - 1.6 --- Log message: Emit module-level constants. --- Diffs of the changes: (+118 -10) ValueEnumerator.cpp |5 +- ValueEnumerator.h |8 +-- Writer.cpp | 115 ++-- 3 files changed, 118 insertions(+), 10 deletions(-) Index: llvm/lib/Bitcode/Writer/ValueEnumerator.cpp diff -u llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.1 llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.2 --- llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.1 Sun Apr 22 01:24:45 2007 +++ llvm/lib/Bitcode/Writer/ValueEnumerator.cpp Mon Apr 23 19:16:04 2007 @@ -56,9 +56,12 @@ // FIXME: std::partition the type and value tables so that first-class types - // come earlier than aggregates. + // come earlier than aggregates. FIXME: Emit a marker into the module + // indicating which aggregates types AND values can be dropped form the table. // FIXME: Sort type/value tables by frequency. + + // FIXME: Sort constants by type to reduce size. } /// EnumerateTypeSymbolTable - Insert all of the types in the specified symbol Index: llvm/lib/Bitcode/Writer/ValueEnumerator.h diff -u llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.2 llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.3 --- llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.2 Mon Apr 23 16:23:41 2007 +++ llvm/lib/Bitcode/Writer/ValueEnumerator.h Mon Apr 23 19:16:04 2007 @@ -35,15 +35,13 @@ // For each value, we remember its Value* and occurrence frequency. typedef std::vectorstd::pairconst Value*, unsigned ValueList; private: - TypeList Types; - typedef DenseMapconst Type*, unsigned TypeMapType; TypeMapType TypeMap; + TypeList Types; - ValueList Values; - typedef DenseMapconst Value*, unsigned ValueMapType; ValueMapType ValueMap; + ValueList Values; ValueEnumerator(const ValueEnumerator ); // DO NOT IMPLEMENT @@ -63,7 +61,7 @@ return I-second-1; } - + const ValueList getValues() const { return Values; } const TypeList getTypes() const { return Types; } /// incorporateFunction/purgeFunction - If you'd like to deal with a function, Index: llvm/lib/Bitcode/Writer/Writer.cpp diff -u llvm/lib/Bitcode/Writer/Writer.cpp:1.5 llvm/lib/Bitcode/Writer/Writer.cpp:1.6 --- llvm/lib/Bitcode/Writer/Writer.cpp:1.5 Mon Apr 23 15:35:01 2007 +++ llvm/lib/Bitcode/Writer/Writer.cpp Mon Apr 23 19:16:04 2007 @@ -15,6 +15,7 @@ #include llvm/Bitcode/BitstreamWriter.h #include llvm/Bitcode/LLVMBitCodes.h #include ValueEnumerator.h +#include llvm/Constants.h #include llvm/DerivedTypes.h #include llvm/Module.h #include llvm/TypeSymbolTable.h @@ -296,7 +297,7 @@ NameVals.push_back(Str[i]); // Emit the finished record. -Stream.EmitRecord(bitc::TST_ENTRY_CODE, NameVals, AbbrevToUse); +Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse); NameVals.clear(); } @@ -327,13 +328,118 @@ NameVals.push_back((unsigned char)*P); // Emit the finished record. -Stream.EmitRecord(bitc::VST_ENTRY_CODE, NameVals, AbbrevToUse); +Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse); NameVals.clear(); } Stream.ExitBlock(); } +static void WriteConstants(unsigned FirstVal, unsigned LastVal, + const ValueEnumerator VE, + BitstreamWriter Stream) { + if (FirstVal == LastVal) return; + + Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 2); + + // FIXME: Install and use abbrevs to reduce size. + + SmallVectoruint64_t, 64 Record; + + const ValueEnumerator::ValueList Vals = VE.getValues(); + const Type *LastTy = 0; + for (unsigned i = FirstVal; i != LastVal; ++i) { +const Value *V = Vals[i].first; +// If we need to switch types, do so now. +if (V-getType() != LastTy) { + LastTy = V-getType(); + Record.push_back(VE.getTypeID(LastTy)); + Stream.EmitRecord(bitc::CST_CODE_SETTYPE, Record); + Record.clear(); +} + +if (const InlineAsm *IA = dyn_castInlineAsm(V)) { + assert(0 IA FIXME: Inline asm writing unimp!); + continue; +} +const Constant *C = castConstant(V); +unsigned Code = -1U; +unsigned AbbrevToUse = 0; +if (C-isNullValue()) { + Code = bitc::CST_CODE_NULL; +} else if (isaUndefValue(C)) { + Code = bitc::CST_CODE_UNDEF; +} else if (const ConstantInt *IV = dyn_castConstantInt(C)) { + if (IV-getBitWidth() = 64) { +int64_t V = IV-getSExtValue(); +if (V = 0) + Record.push_back(V 1); +else + Record.push_back((-V 1) | 1); +Code = bitc::CST_CODE_INTEGER; + } else { // Wide integers, 64 bits in size. +// We have an arbitrary precision integer value to write whose +// bit width is
[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp BitcodeReader.h
Changes in directory llvm/lib/Bitcode/Reader: BitcodeReader.cpp updated: 1.4 - 1.5 BitcodeReader.h updated: 1.4 - 1.5 --- Log message: track global inits --- Diffs of the changes: (+9 -3) BitcodeReader.cpp | 10 +++--- BitcodeReader.h |2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.4 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.5 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.4 Mon Apr 23 16:26:05 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 23 19:18:21 2007 @@ -243,7 +243,7 @@ switch (Stream.ReadRecord(Code, Record)) { default: // Default behavior: unknown type. break; -case bitc::TST_ENTRY_CODE:// TST_ENTRY: [typeid, namelen, namechar x N] +case bitc::TST_CODE_ENTRY:// TST_ENTRY: [typeid, namelen, namechar x N] if (ConvertToString(Record, 1, TypeName)) return Error(Invalid TST_ENTRY record); unsigned TypeID = Record[0]; @@ -288,7 +288,7 @@ switch (Stream.ReadRecord(Code, Record)) { default: // Default behavior: unknown type. break; -case bitc::VST_ENTRY_CODE:// VST_ENTRY: [valueid, namelen, namechar x N] +case bitc::TST_CODE_ENTRY:// VST_ENTRY: [valueid, namelen, namechar x N] if (ConvertToString(Record, 1, ValueName)) return Error(Invalid TST_ENTRY record); unsigned ValueID = Record[0]; @@ -358,6 +358,8 @@ case bitc::MODULE_CODE_VERSION: // VERSION: [version#] if (Record.size() 1) return Error(Malformed MODULE_CODE_VERSION); + if (!GlobalInits.empty()) +return Error(Malformed global initializer set); // Only version #0 is supported so far. if (Record[0] != 0) return Error(Unknown bitstream version!); @@ -431,7 +433,9 @@ ValueList.push_back(NewGV); - // TODO: remember initializer/global pair for later substitution. + // Remember which value to use for the global initializer. + if (unsigned InitID = Record[2]) +GlobalInits.push_back(std::make_pair(NewGV, InitID-1)); break; } // FUNCTION: [type, callingconv, isproto, linkage, alignment, section, Index: llvm/lib/Bitcode/Reader/BitcodeReader.h diff -u llvm/lib/Bitcode/Reader/BitcodeReader.h:1.4 llvm/lib/Bitcode/Reader/BitcodeReader.h:1.5 --- llvm/lib/Bitcode/Reader/BitcodeReader.h:1.4 Mon Apr 23 16:26:05 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.h Mon Apr 23 19:18:21 2007 @@ -22,12 +22,14 @@ namespace llvm { class BitstreamReader; class Value; + class GlobalValue; class BitcodeReader : public ModuleProvider { const char *ErrorString; std::vectorPATypeHolder TypeList; std::vectorValue* ValueList; + std::vectorstd::pairGlobalValue*, unsigned GlobalInits; public: virtual ~BitcodeReader() {} ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Changes in directory llvm/lib/Bitcode/Reader: BitcodeReader.cpp updated: 1.5 - 1.6 --- Log message: move check to the right place :) --- Diffs of the changes: (+4 -3) BitcodeReader.cpp |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.5 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.6 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.5 Mon Apr 23 19:18:21 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 23 19:21:45 2007 @@ -322,8 +322,11 @@ // Read all the records for this module. while (!Stream.AtEndOfStream()) { unsigned Code = Stream.ReadCode(); -if (Code == bitc::END_BLOCK) +if (Code == bitc::END_BLOCK) { + if (!GlobalInits.empty()) +return Error(Malformed global initializer set); return Stream.ReadBlockEnd(); +} if (Code == bitc::ENTER_SUBBLOCK) { switch (Stream.ReadSubBlockID()) { @@ -358,8 +361,6 @@ case bitc::MODULE_CODE_VERSION: // VERSION: [version#] if (Record.size() 1) return Error(Malformed MODULE_CODE_VERSION); - if (!GlobalInits.empty()) -return Error(Malformed global initializer set); // Only version #0 is supported so far. if (Record[0] != 0) return Error(Unknown bitstream version!); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.424 - 1.425 --- Log message: Use '-1U' where '-1UL' is obvious overkill, eliminating gcc warnings about tests always being true in the process. --- Diffs of the changes: (+2 -2) SelectionDAGISel.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.424 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.425 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.424Sun Apr 22 18:15:29 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 23 20:24:20 2007 @@ -1177,7 +1177,7 @@ /// visitJumpTable - Emit JumpTable node in the current MBB void SelectionDAGLowering::visitJumpTable(SelectionDAGISel::JumpTable JT) { // Emit the code for the jump table - assert(JT.Reg != -1UL Should lower JT Header first!); + assert(JT.Reg != -1U Should lower JT Header first!); MVT::ValueType PTy = TLI.getPointerTy(); SDOperand Index = DAG.getCopyFromReg(getRoot(), JT.Reg, PTy); SDOperand Table = DAG.getJumpTable(JT.JTI, PTy); @@ -1544,7 +1544,7 @@ // Set the jump table information so that we can codegen it as a second // MachineBasicBlock - SelectionDAGISel::JumpTable JT(-1UL, JTI, JumpTableBB, Default); + SelectionDAGISel::JumpTable JT(-1U, JTI, JumpTableBB, Default); SelectionDAGISel::JumpTableHeader JTH(First, Last, SV, CR.CaseBB, (CR.CaseBB == CurMBB)); if (CR.CaseBB == CurMBB) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Writer/Writer.cpp
Changes in directory llvm/lib/Bitcode/Writer: Writer.cpp updated: 1.6 - 1.7 --- Log message: fix off-by-one computing size for section abbrevs --- Diffs of the changes: (+1 -1) Writer.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Bitcode/Writer/Writer.cpp diff -u llvm/lib/Bitcode/Writer/Writer.cpp:1.6 llvm/lib/Bitcode/Writer/Writer.cpp:1.7 --- llvm/lib/Bitcode/Writer/Writer.cpp:1.6 Mon Apr 23 19:16:04 2007 +++ llvm/lib/Bitcode/Writer/Writer.cpp Mon Apr 23 22:29:47 2007 @@ -220,7 +220,7 @@ Abbv-Add(BitCodeAbbrevOp(0)); else Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, - Log2_32_Ceil(SectionMap.size(; + Log2_32_Ceil(SectionMap.size()+1))); // Don't bother emitting vis + thread local. SimpleGVarAbbrev = Stream.EmitAbbrev(Abbv); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp BitcodeReader.h
Changes in directory llvm/lib/Bitcode/Reader: BitcodeReader.cpp updated: 1.6 - 1.7 BitcodeReader.h updated: 1.5 - 1.6 --- Log message: read basic constants: null, undef, integers = 64bits --- Diffs of the changes: (+80 -2) BitcodeReader.cpp | 77 ++ BitcodeReader.h |5 ++- 2 files changed, 80 insertions(+), 2 deletions(-) Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.6 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.7 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.6 Mon Apr 23 19:21:45 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 23 22:30:34 2007 @@ -13,6 +13,7 @@ #include BitcodeReader.h #include llvm/Bitcode/BitstreamReader.h +#include llvm/Constants.h #include llvm/DerivedTypes.h #include llvm/Module.h #include llvm/ADT/SmallString.h @@ -303,6 +304,78 @@ } } +bool BitcodeReader::ParseConstants(BitstreamReader Stream) { + if (Stream.EnterSubBlock()) +return Error(Malformed block record); + + SmallVectoruint64_t, 64 Record; + + // Read all the records for this value table. + const Type *CurTy = Type::Int32Ty; + while (1) { +unsigned Code = Stream.ReadCode(); +if (Code == bitc::END_BLOCK) { + // If there are global var inits to process, do so now. + if (!GlobalInits.empty()) { +while (!GlobalInits.empty()) { + unsigned ValID = GlobalInits.back().second; + if (ValID = ValueList.size()) +return Error(Invalid value ID for global var init!); + if (Constant *C = dyn_castConstant(ValueList[ValID])) +GlobalInits.back().first-setInitializer(C); + else +return Error(Global variable initializer is not a constant!); + GlobalInits.pop_back(); +} + } + + return Stream.ReadBlockEnd(); +} + +if (Code == bitc::ENTER_SUBBLOCK) { + // No known subblocks, always skip them. + Stream.ReadSubBlockID(); + if (Stream.SkipBlock()) +return Error(Malformed block record); + continue; +} + +if (Code == bitc::DEFINE_ABBREV) { + Stream.ReadAbbrevRecord(); + continue; +} + +// Read a record. +Record.clear(); +Value *V = 0; +switch (Stream.ReadRecord(Code, Record)) { +default: // Default behavior: unknown constant +case bitc::CST_CODE_UNDEF: // UNDEF + V = UndefValue::get(CurTy); + break; +case bitc::CST_CODE_SETTYPE: // SETTYPE: [typeid] + if (Record.empty()) +return Error(Malformed CST_SETTYPE record); + if (Record[0] = TypeList.size()) +return Error(Invalid Type ID in CST_SETTYPE record); + CurTy = TypeList[Record[0]]; + continue; +case bitc::CST_CODE_NULL: // NULL + V = Constant::getNullValue(CurTy); + break; +case bitc::CST_CODE_INTEGER: // INTEGER: [intval] + if (!isaIntegerType(CurTy)) +return Error(Invalid type for CST_INTEGER); + if (Record[0] 1) +V = ConstantInt::get(CurTy, -(Record[0]1)); + else +V = ConstantInt::get(CurTy, Record[0]1); + break; +} + +ValueList.push_back(V); + } +} bool BitcodeReader::ParseModule(BitstreamReader Stream, const std::string ModuleID) { @@ -346,6 +419,10 @@ if (ParseValueSymbolTable(Stream)) return true; break; + case bitc::CONSTANTS_BLOCK_ID: +if (ParseConstants(Stream)) + return true; +break; } continue; } Index: llvm/lib/Bitcode/Reader/BitcodeReader.h diff -u llvm/lib/Bitcode/Reader/BitcodeReader.h:1.5 llvm/lib/Bitcode/Reader/BitcodeReader.h:1.6 --- llvm/lib/Bitcode/Reader/BitcodeReader.h:1.5 Mon Apr 23 19:18:21 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.h Mon Apr 23 22:30:34 2007 @@ -22,14 +22,14 @@ namespace llvm { class BitstreamReader; class Value; - class GlobalValue; + class GlobalVariable; class BitcodeReader : public ModuleProvider { const char *ErrorString; std::vectorPATypeHolder TypeList; std::vectorValue* ValueList; - std::vectorstd::pairGlobalValue*, unsigned GlobalInits; + std::vectorstd::pairGlobalVariable*, unsigned GlobalInits; public: virtual ~BitcodeReader() {} @@ -64,6 +64,7 @@ bool ParseTypeTable(BitstreamReader Stream); bool ParseTypeSymbolTable(BitstreamReader Stream); bool ParseValueSymbolTable(BitstreamReader Stream); + bool ParseConstants(BitstreamReader Stream); }; } // End llvm namespace ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Changes in directory llvm/lib/Bitcode/Reader: BitcodeReader.cpp updated: 1.7 - 1.8 --- Log message: add supprot for FP constants, wide integers, and fix the encoding of MININT --- Diffs of the changes: (+40 -8) BitcodeReader.cpp | 48 1 files changed, 40 insertions(+), 8 deletions(-) Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.7 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.8 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.7 Mon Apr 23 22:30:34 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 23 23:04:35 2007 @@ -17,6 +17,7 @@ #include llvm/DerivedTypes.h #include llvm/Module.h #include llvm/ADT/SmallString.h +#include llvm/Support/MathExtras.h using namespace llvm; /// ConvertToString - Convert a string from a record into an std::string, return @@ -204,8 +205,8 @@ const_castOpaqueType*(OldTy)-refineAbstractTypeTo(ResultTy); // This should have replaced the old opaque type with the new type in the - // value table... or with a preexisting type that was already in the system. - // Let's just make sure it did. + // value table... or with a preexisting type that was already in the + // system. Let's just make sure it did. assert(TypeList[NumRecords-1].get() != OldTy refineAbstractType didn't work!); } @@ -304,6 +305,17 @@ } } +/// DecodeSignRotatedValue - Decode a signed value stored with the sign bit in +/// the LSB for dense VBR encoding. +static uint64_t DecodeSignRotatedValue(uint64_t V) { + if ((V 1) == 0) +return V 1; + if (V != 1) +return -(V 1); + // There is no such thing as -0 with integers. -0 really means MININT. + return 1ULL 63; +} + bool BitcodeReader::ParseConstants(BitstreamReader Stream) { if (Stream.EnterSubBlock()) return Error(Malformed block record); @@ -359,17 +371,37 @@ if (Record[0] = TypeList.size()) return Error(Invalid Type ID in CST_SETTYPE record); CurTy = TypeList[Record[0]]; - continue; + continue; // Skip the ValueList manipulation. case bitc::CST_CODE_NULL: // NULL V = Constant::getNullValue(CurTy); break; case bitc::CST_CODE_INTEGER: // INTEGER: [intval] - if (!isaIntegerType(CurTy)) -return Error(Invalid type for CST_INTEGER); - if (Record[0] 1) -V = ConstantInt::get(CurTy, -(Record[0]1)); + if (!isaIntegerType(CurTy) || Record.empty()) +return Error(Invalid CST_INTEGER record); + V = ConstantInt::get(CurTy, DecodeSignRotatedValue(Record[0])); + break; +case bitc::CST_CODE_WIDE_INTEGER: {// WIDE_INTEGER: [n, n x intval] + if (!isaIntegerType(CurTy) || Record.empty() || + Record.size() Record[0]+1) +return Error(Invalid WIDE_INTEGER record); + + unsigned NumWords = Record[0]; + uint64_t *Data = new uint64_t[NumWords]; + for (unsigned i = 0; i != NumWords; ++i) +Data[i] = DecodeSignRotatedValue(Record[i+1]); + V = ConstantInt::get(APInt(castIntegerType(CurTy)-getBitWidth(), + NumWords, Data)); + break; +} +case bitc::CST_CODE_FLOAT: // FLOAT: [fpval] + if (Record.empty()) +return Error(Invalid FLOAT record); + if (CurTy == Type::FloatTy) +V = ConstantFP::get(CurTy, BitsToFloat(Record[0])); + else if (CurTy == Type::DoubleTy) +V = ConstantFP::get(CurTy, BitsToDouble(Record[0])); else -V = ConstantInt::get(CurTy, Record[0]1); +V = UndefValue::get(CurTy); break; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp BitcodeReader.h
Changes in directory llvm/lib/Bitcode/Reader: BitcodeReader.cpp updated: 1.8 - 1.9 BitcodeReader.h updated: 1.6 - 1.7 --- Log message: implement support for reading aggregate constants, including handling forward constant references, etc. --- Diffs of the changes: (+108 -5) BitcodeReader.cpp | 78 +- BitcodeReader.h | 35 +--- 2 files changed, 108 insertions(+), 5 deletions(-) Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.8 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.9 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.8 Mon Apr 23 23:04:35 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Tue Apr 24 00:48:56 2007 @@ -55,6 +55,39 @@ } } +namespace { + /// @brief A class for maintaining the slot number definition + /// as a placeholder for the actual definition for forward constants defs. + class ConstantPlaceHolder : public ConstantExpr { +ConstantPlaceHolder(); // DO NOT IMPLEMENT +void operator=(const ConstantPlaceHolder ); // DO NOT IMPLEMENT +public: + Use Op; + ConstantPlaceHolder(const Type *Ty) +: ConstantExpr(Ty, Instruction::UserOp1, Op, 1), + Op(UndefValue::get(Type::Int32Ty), this) { +} + }; +} + +Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, +const Type *Ty) { + if (Idx = size()) { +// Insert a bunch of null values. +Uses.resize(Idx+1); +OperandList = Uses[0]; +NumOperands = Idx+1; + } + + if (Uses[Idx]) +return castConstant(getOperand(Idx)); + + // Create and return a placeholder, which will later be RAUW'd. + Constant *C = new ConstantPlaceHolder(Ty); + Uses[Idx].init(C, this); + return C; +} + const Type *BitcodeReader::getTypeByID(unsigned ID, bool isTypeTable) { // If the TypeID is in range, return it. @@ -324,6 +357,7 @@ // Read all the records for this value table. const Type *CurTy = Type::Int32Ty; + unsigned NextCstNo = ValueList.size(); while (1) { unsigned Code = Stream.ReadCode(); if (Code == bitc::END_BLOCK) { @@ -341,6 +375,9 @@ } } + if (NextCstNo != ValueList.size()) +return Error(Invalid constant reference!); + return Stream.ReadBlockEnd(); } @@ -403,9 +440,48 @@ else V = UndefValue::get(CurTy); break; + +case bitc::CST_CODE_AGGREGATE: {// AGGREGATE: [n, n x value number] + if (Record.empty() || Record.size() Record[0]+1) +return Error(Invalid CST_AGGREGATE record); + + unsigned Size = Record[0]; + std::vectorConstant* Elts; + + if (const StructType *STy = dyn_castStructType(CurTy)) { +for (unsigned i = 0; i != Size; ++i) + Elts.push_back(ValueList.getConstantFwdRef(Record[i+1], + STy-getElementType(i))); +V = ConstantStruct::get(STy, Elts); + } else if (const ArrayType *ATy = dyn_castArrayType(CurTy)) { +const Type *EltTy = ATy-getElementType(); +for (unsigned i = 0; i != Size; ++i) + Elts.push_back(ValueList.getConstantFwdRef(Record[i+1], EltTy)); +V = ConstantArray::get(ATy, Elts); + } else if (const VectorType *VTy = dyn_castVectorType(CurTy)) { +const Type *EltTy = VTy-getElementType(); +for (unsigned i = 0; i != Size; ++i) + Elts.push_back(ValueList.getConstantFwdRef(Record[i+1], EltTy)); +V = ConstantVector::get(Elts); + } else { +V = UndefValue::get(CurTy); + } +} +} + +if (NextCstNo == ValueList.size()) + ValueList.push_back(V); +else if (ValueList[NextCstNo] == 0) + ValueList.initVal(NextCstNo, V); +else { + // If there was a forward reference to this constant, + Value *OldV = ValueList[NextCstNo]; + ValueList.setOperand(NextCstNo, V); + OldV-replaceAllUsesWith(V); + delete OldV; } -ValueList.push_back(V); +++NextCstNo; } } Index: llvm/lib/Bitcode/Reader/BitcodeReader.h diff -u llvm/lib/Bitcode/Reader/BitcodeReader.h:1.6 llvm/lib/Bitcode/Reader/BitcodeReader.h:1.7 --- llvm/lib/Bitcode/Reader/BitcodeReader.h:1.6 Mon Apr 23 22:30:34 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.h Tue Apr 24 00:48:56 2007 @@ -14,21 +14,48 @@ #ifndef BITCODE_READER_H #define BITCODE_READER_H -#include llvm/Type.h #include llvm/ModuleProvider.h +#include llvm/Type.h +#include llvm/User.h #include llvm/Bitcode/LLVMBitCodes.h #include vector namespace llvm { class BitstreamReader; - class Value; - class GlobalVariable; + +class BitcodeReaderValueList : public User { + std::vectorUse Uses; +public: + BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) {} + + // vector compatibility methods + unsigned size() const { return