aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineCodeEmitter.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-05-02 19:14:47 +0000
committerChris Lattner <sabre@nondot.org>2006-05-02 19:14:47 +0000
commitd3f0aefc33965d3d0ca6f92af4ebaea354b063c4 (patch)
treea930b341d61cfa8a4c28505803970a2b270946a2 /include/llvm/CodeGen/MachineCodeEmitter.h
parent43b429b05989075b60693d57395c99b0ad789f8d (diff)
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
Diffstat (limited to 'include/llvm/CodeGen/MachineCodeEmitter.h')
-rw-r--r--include/llvm/CodeGen/MachineCodeEmitter.h27
1 files changed, 21 insertions, 6 deletions
diff --git a/include/llvm/CodeGen/MachineCodeEmitter.h b/include/llvm/CodeGen/MachineCodeEmitter.h
index 72002ef897..7f171b6f4d 100644
--- a/include/llvm/CodeGen/MachineCodeEmitter.h
+++ b/include/llvm/CodeGen/MachineCodeEmitter.h
@@ -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 emitWordLE(unsigned W) {
+ if (CurBufferPtr+4 <= BufferEnd) {
+ *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 emitWord(unsigned W) {
- // FIXME: handle endian mismatches for .o file emission.
+ void emitWordBE(unsigned W) {
if (CurBufferPtr+4 <= BufferEnd) {
- *(unsigned*)CurBufferPtr = W;
- CurBufferPtr += 4;
+ *CurBufferPtr++ = (unsigned char)(W >> 24);
+ *CurBufferPtr++ = (unsigned char)(W >> 16);
+ *CurBufferPtr++ = (unsigned char)(W >> 8);
+ *CurBufferPtr++ = (unsigned char)(W >> 0);
} else {
CurBufferPtr = BufferEnd;
}