[llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineCodeEmitter.h
Chris Lattner
lattner at cs.uiuc.edu
Tue May 2 12:15:02 PDT 2006
Changes in directory llvm/include/llvm/CodeGen:
MachineCodeEmitter.h updated: 1.33 -> 1.34
---
Log message:
Fix a purely hypothetical problem (for now): emitWord emits in the host
byte format. This doesn't work when using the code emitter in a cross target
environment. Since the code emitter is only really used by the JIT, this
isn't a current problem, but if we ever start emitting .o files, it would be.
---
Diffs of the changes: (+21 -6)
MachineCodeEmitter.h | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
Index: llvm/include/llvm/CodeGen/MachineCodeEmitter.h
diff -u llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.33 llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.34
--- llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.33 Tue May 2 13:27:26 2006
+++ llvm/include/llvm/CodeGen/MachineCodeEmitter.h Tue May 2 14:14:47 2006
@@ -112,14 +112,29 @@
*CurBufferPtr++ = B;
}
- /// emitWord - This callback is invoked when a word needs to be written to the
- /// output stream.
+ /// emitWordLE - This callback is invoked when a 32-bit word needs to be
+ /// written to the output stream in little-endian format.
///
- void emitWord(unsigned W) {
- // FIXME: handle endian mismatches for .o file emission.
+ void emitWordLE(unsigned W) {
if (CurBufferPtr+4 <= BufferEnd) {
- *(unsigned*)CurBufferPtr = W;
- CurBufferPtr += 4;
+ *CurBufferPtr++ = (unsigned char)(W >> 0);
+ *CurBufferPtr++ = (unsigned char)(W >> 8);
+ *CurBufferPtr++ = (unsigned char)(W >> 16);
+ *CurBufferPtr++ = (unsigned char)(W >> 24);
+ } else {
+ CurBufferPtr = BufferEnd;
+ }
+ }
+
+ /// emitWordBE - This callback is invoked when a 32-bit word needs to be
+ /// written to the output stream in big-endian format.
+ ///
+ void emitWordBE(unsigned W) {
+ if (CurBufferPtr+4 <= BufferEnd) {
+ *CurBufferPtr++ = (unsigned char)(W >> 24);
+ *CurBufferPtr++ = (unsigned char)(W >> 16);
+ *CurBufferPtr++ = (unsigned char)(W >> 8);
+ *CurBufferPtr++ = (unsigned char)(W >> 0);
} else {
CurBufferPtr = BufferEnd;
}
More information about the llvm-commits
mailing list