summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMAsmBackend.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2010-12-08 01:16:55 +0000
committerJim Grosbach <grosbach@apple.com>2010-12-08 01:16:55 +0000
commit87055ed6f4beaa68fb32b3d625bcfc77f58b2a40 (patch)
tree3003f0cda8f37b6ce02a92bfea096215679b94be /llvm/lib/Target/ARM/ARMAsmBackend.cpp
parent0ecec99eb2eb2bd1707498d19deab2fef7b17ef5 (diff)
downloadbcm5719-llvm-87055ed6f4beaa68fb32b3d625bcfc77f58b2a40.tar.gz
bcm5719-llvm-87055ed6f4beaa68fb32b3d625bcfc77f58b2a40.zip
Let target asm backends see assembler flags as they go by. Use that to handle
thumb vs. arm mode differences in WriteNopData(). llvm-svn: 121219
Diffstat (limited to 'llvm/lib/Target/ARM/ARMAsmBackend.cpp')
-rw-r--r--llvm/lib/Target/ARM/ARMAsmBackend.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/llvm/lib/Target/ARM/ARMAsmBackend.cpp b/llvm/lib/Target/ARM/ARMAsmBackend.cpp
index 0bf6dd6e13d..90b181e2cb7 100644
--- a/llvm/lib/Target/ARM/ARMAsmBackend.cpp
+++ b/llvm/lib/Target/ARM/ARMAsmBackend.cpp
@@ -12,6 +12,7 @@
#include "ARMFixupKinds.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAssembler.h"
+#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCObjectFormat.h"
#include "llvm/MC/MCObjectWriter.h"
@@ -27,6 +28,7 @@ using namespace llvm;
namespace {
class ARMAsmBackend : public TargetAsmBackend {
+ bool isThumbMode; // Currently emitting Thumb code.
public:
ARMAsmBackend(const Target &T) : TargetAsmBackend() {}
@@ -36,9 +38,21 @@ public:
bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const;
- unsigned getPointerSize() const {
- return 4;
+ void HandleAssemblerFlag(MCAssemblerFlag Flag) {
+ switch (Flag) {
+ default: break;
+ case MCAF_Code16:
+ setIsThumb(true);
+ break;
+ case MCAF_Code32:
+ setIsThumb(false);
+ break;
+ }
}
+
+ unsigned getPointerSize() const { return 4; }
+ bool isThumb() const { return isThumbMode; }
+ void setIsThumb(bool it) { isThumbMode = it; }
};
} // end anonymous namespace
@@ -53,10 +67,19 @@ void ARMAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
}
bool ARMAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
- // FIXME: Zero fill for now. That's not right, but at least will get the
- // section size right.
+ if (isThumb()) {
+ assert (((Count & 1) == 0) && "Unaligned Nop data fragment!");
+ // FIXME: 0xbf00 is the ARMv7 value. For v6 and before, we'll need to
+ // use 0x46c0 (which is a 'mov r8, r8' insn).
+ Count /= 2;
+ for (uint64_t i = 0; i != Count; ++i)
+ OW->Write16(0xbf00);
+ return true;
+ }
+ // ARM mode
+ Count /= 4;
for (uint64_t i = 0; i != Count; ++i)
- OW->Write8(0);
+ OW->Write32(0xe1a00000);
return true;
}
OpenPOWER on IntegriCloud