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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28060 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2006-05-02 19:14:47 +00:00
parent 43b429b059
commit d3f0aefc33
7 changed files with 42 additions and 35 deletions
+21 -6
View File
@@ -112,14 +112,29 @@ public:
*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;
}