[llvm-commits] CVS: llvm/include/llvm/Support/OutputBuffer.h

2007-04-20 Thread Chris Lattner


Changes in directory llvm/include/llvm/Support:

OutputBuffer.h updated: 1.4 -> 1.5
---
Log message:

Fix a very strange assertion message, patch by Christopher Lamb
 CVS: --


---
Diffs of the changes:  (+1 -1)

 OutputBuffer.h |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/include/llvm/Support/OutputBuffer.h
diff -u llvm/include/llvm/Support/OutputBuffer.h:1.4 
llvm/include/llvm/Support/OutputBuffer.h:1.5
--- llvm/include/llvm/Support/OutputBuffer.h:1.4Sun Feb  4 20:37:07 2007
+++ llvm/include/llvm/Support/OutputBuffer.hThu Apr 19 22:27:36 2007
@@ -35,7 +35,7 @@
 // aligned to the specified power of two boundary.
 void align(unsigned Boundary) {
   assert(Boundary && (Boundary & (Boundary - 1)) == 0 &&
- "Must alitypedef std::vector DataBuffer;gn to 2^k 
boundary");
+ "Must align to 2^k boundary");
   size_t Size = Output.size();
   
   if (Size & (Boundary - 1)) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Support/OutputBuffer.h

2007-02-04 Thread Bill Wendling


Changes in directory llvm/include/llvm/Support:

OutputBuffer.h updated: 1.3 -> 1.4
---
Log message:

Use unsigned char& instead of std::vector<>::reference.


---
Diffs of the changes:  (+2 -4)

 OutputBuffer.h |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)


Index: llvm/include/llvm/Support/OutputBuffer.h
diff -u llvm/include/llvm/Support/OutputBuffer.h:1.3 
llvm/include/llvm/Support/OutputBuffer.h:1.4
--- llvm/include/llvm/Support/OutputBuffer.h:1.3Fri Feb  2 20:38:15 2007
+++ llvm/include/llvm/Support/OutputBuffer.hSun Feb  4 20:37:07 2007
@@ -139,12 +139,10 @@
 assert(0 && "Emission of 64-bit data not implemented yet!");
 }
 
-std::vector::reference
-operator [] (unsigned Index) {
+unsigned char &operator[](unsigned Index) {
   return Output[Index];
 }
-std::vector::const_reference
-operator [] (unsigned Index) const {
+const unsigned char &operator[](unsigned Index) const {
   return Output[Index];
 }
   };



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Support/OutputBuffer.h

2007-02-02 Thread Bill Wendling


Changes in directory llvm/include/llvm/Support:

OutputBuffer.h updated: 1.2 -> 1.3
---
Log message:

Added some accessor methods.


---
Diffs of the changes:  (+9 -0)

 OutputBuffer.h |9 +
 1 files changed, 9 insertions(+)


Index: llvm/include/llvm/Support/OutputBuffer.h
diff -u llvm/include/llvm/Support/OutputBuffer.h:1.2 
llvm/include/llvm/Support/OutputBuffer.h:1.3
--- llvm/include/llvm/Support/OutputBuffer.h:1.2Wed Jan 17 19:23:11 2007
+++ llvm/include/llvm/Support/OutputBuffer.hFri Feb  2 20:38:15 2007
@@ -138,6 +138,15 @@
   else
 assert(0 && "Emission of 64-bit data not implemented yet!");
 }
+
+std::vector::reference
+operator [] (unsigned Index) {
+  return Output[Index];
+}
+std::vector::const_reference
+operator [] (unsigned Index) const {
+  return Output[Index];
+}
   };
   
 } // 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/include/llvm/Support/OutputBuffer.h

2007-01-17 Thread Bill Wendling


Changes in directory llvm/include/llvm/Support:

OutputBuffer.h updated: 1.1 -> 1.2
---
Log message:

Have the OutputBuffer take the is64Bit and isLittleEndian booleans.


---
Diffs of the changes:  (+5 -6)

 OutputBuffer.h |   11 +--
 1 files changed, 5 insertions(+), 6 deletions(-)


Index: llvm/include/llvm/Support/OutputBuffer.h
diff -u llvm/include/llvm/Support/OutputBuffer.h:1.1 
llvm/include/llvm/Support/OutputBuffer.h:1.2
--- llvm/include/llvm/Support/OutputBuffer.h:1.1Wed Jan 17 16:17:24 2007
+++ llvm/include/llvm/Support/OutputBuffer.hWed Jan 17 19:23:11 2007
@@ -14,6 +14,7 @@
 #ifndef LLVM_SUPPORT_OUTPUTBUFFER_H
 #define LLVM_SUPPORT_OUTPUTBUFFER_H
 
+#include 
 #include 
 
 namespace llvm {
@@ -26,11 +27,9 @@
 /// machine directly, indicating what header values and flags to set.
 bool is64Bit, isLittleEndian;
   public:
-OutputBuffer(const TargetMachine& TM,
- std::vector &Out) : Output(Out) {
-  is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
-  isLittleEndian = TM.getTargetData()->isLittleEndian();
-}
+OutputBuffer(std::vector &Out,
+ bool is64bit, bool le)
+  : Output(Out), is64Bit(is64bit), isLittleEndian(le) {}
 
 // align - Emit padding into the file until the current output position is
 // aligned to the specified power of two boundary.
@@ -107,7 +106,7 @@
   else
 outxword(X);
 }
-void outstring(std::string &S, unsigned Length) {
+void outstring(const std::string &S, unsigned Length) {
   unsigned len_to_copy = S.length() < Length ? S.length() : Length;
   unsigned len_to_fill = S.length() < Length ? Length - S.length() : 0;
   



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Support/OutputBuffer.h

2007-01-17 Thread Bill Wendling


Changes in directory llvm/include/llvm/Support:

OutputBuffer.h added (r1.1)
---
Log message:

Refactored output buffer methods from MachO and ELF writers.


---
Diffs of the changes:  (+146 -0)

 OutputBuffer.h |  146 +
 1 files changed, 146 insertions(+)


Index: llvm/include/llvm/Support/OutputBuffer.h
diff -c /dev/null llvm/include/llvm/Support/OutputBuffer.h:1.1
*** /dev/null   Wed Jan 17 16:17:34 2007
--- llvm/include/llvm/Support/OutputBuffer.hWed Jan 17 16:17:24 2007
***
*** 0 
--- 1,146 
+ //=== OutputBuffer.h - Output Buffer *- C++ 
-*-===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file was developed by Bill Wendling and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ 
//===--===//
+ //
+ // Methods to output values to a data buffer.
+ //
+ 
//===--===//
+ 
+ #ifndef LLVM_SUPPORT_OUTPUTBUFFER_H
+ #define LLVM_SUPPORT_OUTPUTBUFFER_H
+ 
+ #include 
+ 
+ namespace llvm {
+   
+   class OutputBuffer {
+ /// Output buffer.
+ std::vector &Output;
+ 
+ /// is64Bit/isLittleEndian - This information is inferred from the target
+ /// machine directly, indicating what header values and flags to set.
+ bool is64Bit, isLittleEndian;
+   public:
+ OutputBuffer(const TargetMachine& TM,
+  std::vector &Out) : Output(Out) {
+   is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
+   isLittleEndian = TM.getTargetData()->isLittleEndian();
+ }
+ 
+ // align - Emit padding into the file until the current output position is
+ // aligned to the specified power of two boundary.
+ void align(unsigned Boundary) {
+   assert(Boundary && (Boundary & (Boundary - 1)) == 0 &&
+  "Must alitypedef std::vector DataBuffer;gn to 2^k 
boundary");
+   size_t Size = Output.size();
+   
+   if (Size & (Boundary - 1)) {
+ // Add padding to get alignment to the correct place.
+ size_t Pad = Boundary - (Size & (Boundary - 1));
+ Output.resize(Size + Pad);
+   }
+ }
+ 
+ 
//===--===//
+ // Out Functions - Output the specified value to the data buffer.
+ 
+ void outbyte(unsigned char X) {
+   Output.push_back(X);
+ }
+ void outhalf(unsigned short X) {
+   if (isLittleEndian) {
+ Output.push_back(X & 255);
+ Output.push_back(X >> 8);
+   } else {
+ Output.push_back(X >> 8);
+ Output.push_back(X & 255);
+   }
+ }
+ void outword(unsigned X) {
+   if (isLittleEndian) {
+ Output.push_back((X >>  0) & 255);
+ Output.push_back((X >>  8) & 255);
+ Output.push_back((X >> 16) & 255);
+ Output.push_back((X >> 24) & 255);
+   } else {
+ Output.push_back((X >> 24) & 255);
+ Output.push_back((X >> 16) & 255);
+ Output.push_back((X >>  8) & 255);
+ Output.push_back((X >>  0) & 255);
+   }
+ }
+ void outxword(uint64_t X) {
+   if (isLittleEndian) {
+ Output.push_back(unsigned(X >>  0) & 255);
+ Output.push_back(unsigned(X >>  8) & 255);
+ Output.push_back(unsigned(X >> 16) & 255);
+ Output.push_back(unsigned(X >> 24) & 255);
+ Output.push_back(unsigned(X >> 32) & 255);
+ Output.push_back(unsigned(X >> 40) & 255);
+ Output.push_back(unsigned(X >> 48) & 255);
+ Output.push_back(unsigned(X >> 56) & 255);
+   } else {
+ Output.push_back(unsigned(X >> 56) & 255);
+ Output.push_back(unsigned(X >> 48) & 255);
+ Output.push_back(unsigned(X >> 40) & 255);
+ Output.push_back(unsigned(X >> 32) & 255);
+ Output.push_back(unsigned(X >> 24) & 255);
+ Output.push_back(unsigned(X >> 16) & 255);
+ Output.push_back(unsigned(X >>  8) & 255);
+ Output.push_back(unsigned(X >>  0) & 255);
+   }
+ }
+ void outaddr32(unsigned X) {
+   outword(X);
+ }
+ void outaddr64(uint64_t X) {
+   outxword(X);
+ }
+ void outaddr(uint64_t X) {
+   if (!is64Bit)
+ outword((unsigned)X);
+   else
+ outxword(X);
+ }
+ void outstring(std::string &S, unsigned Length) {
+   unsigned len_to_copy = S.length() < Length ? S.length() : Length;
+   unsigned len_to_fill = S.length() < Length ? Length - S.length() : 0;
+   
+   for (unsigned i = 0; i < len_to_copy; ++i)
+ outbyte(S[i]);
+   
+   for (unsigned i = 0; i < len_to_fill; ++i)
+ outbyte(0);
+ }
+ 
+ 
//===--===//
+ // Fix Functions - Replace an e