mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user