mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Fix PR1836: in the interpreter, read and write apints
using the minimum possible number of bytes. For little endian targets run on little endian machines, apints are stored in memory from LSB to MSB as before. For big endian targets on big endian machines they are stored from MSB to LSB which wasn't always the case before (if the target and host endianness doesn't match values are stored according to the host's endianness). Doing this requires knowing the endianness of the host, which is determined when configuring - thanks go to Anton for this. Only having access to little endian machines I was unable to properly test the big endian part, which is also the most complicated... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44796 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Config/config.h"
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
@@ -142,6 +143,16 @@ public:
|
||||
bool isLittleEndian() const { return LittleEndian; }
|
||||
bool isBigEndian() const { return !LittleEndian; }
|
||||
|
||||
/// Host endianness...
|
||||
bool hostIsLittleEndian() const {
|
||||
#ifdef LSB_FIRST
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
bool hostIsBigEndian() const { return !hostIsLittleEndian(); }
|
||||
|
||||
/// getStringRepresentation - Return the string representation of the
|
||||
/// TargetData. This representation is in the same format accepted by the
|
||||
/// string constructor above.
|
||||
|
Reference in New Issue
Block a user