From fa36dfeeca7701fa26c578785749a6a3fffc090b Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Tue, 26 Nov 2013 12:45:05 +0000 Subject: [PATCH] Darwin-ARM: use movw/movt for static relocations llvm-svn: 195759 --- llvm/lib/Target/ARM/ARMFastISel.cpp | 8 +++----- llvm/lib/Target/ARM/ARMISelLowering.cpp | 4 +--- llvm/test/CodeGen/ARM/movt-movw-global.ll | 8 ++++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Target/ARM/ARMFastISel.cpp b/llvm/lib/Target/ARM/ARMFastISel.cpp index e04a4ef1a1c8..975417eba0b1 100644 --- a/llvm/lib/Target/ARM/ARMFastISel.cpp +++ b/llvm/lib/Target/ARM/ARMFastISel.cpp @@ -679,14 +679,12 @@ unsigned ARMFastISel::ARMMaterializeGV(const GlobalValue *GV, MVT VT) { if (!Subtarget->isTargetDarwin() && IsThreadLocal) return 0; // Use movw+movt when possible, it avoids constant pool entries. - // Darwin targets don't support movt with Reloc::Static, see - // ARMTargetLowering::LowerGlobalAddressDarwin. Other targets only support - // static movt relocations. + // Non-darwin targets only support static movt relocations in FastISel. if (Subtarget->useMovt() && - Subtarget->isTargetDarwin() == (RelocM != Reloc::Static)) { + (Subtarget->isTargetDarwin() || RelocM == Reloc::Static)) { unsigned Opc; unsigned char TF = 0; - if (Subtarget->isTargetDarwin() && RelocM != Reloc::Static) + if (Subtarget->isTargetDarwin()) TF = ARMII::MO_NONLAZY; switch (RelocM) { diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index f66ff35aaa99..4938c863b6fd 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -2537,9 +2537,7 @@ SDValue ARMTargetLowering::LowerGlobalAddressDarwin(SDValue Op, const GlobalValue *GV = cast(Op)->getGlobal(); Reloc::Model RelocM = getTargetMachine().getRelocationModel(); - // FIXME: Enable this for static codegen when tool issues are fixed. Also - // update ARMFastISel::ARMMaterializeGV. - if (Subtarget->useMovt() && RelocM != Reloc::Static) { + if (Subtarget->useMovt()) { ++NumMovwMovt; // FIXME: Once remat is capable of dealing with instructions with register // operands, expand this into two nodes. diff --git a/llvm/test/CodeGen/ARM/movt-movw-global.ll b/llvm/test/CodeGen/ARM/movt-movw-global.ll index bbedea19d780..1e10af181f30 100644 --- a/llvm/test/CodeGen/ARM/movt-movw-global.ll +++ b/llvm/test/CodeGen/ARM/movt-movw-global.ll @@ -16,8 +16,8 @@ entry: ; IOS-PIC: movw r0, :lower16:(L_foo$non_lazy_ptr-(LPC0_0+8)) ; IOS-PIC-NEXT: movt r0, :upper16:(L_foo$non_lazy_ptr-(LPC0_0+8)) -; IOS-STATIC-NOT: movw r0, :lower16:_foo -; IOS-STATIC-NOT: movt r0, :upper16:_foo +; IOS-STATIC: movw r0, :lower16:_foo +; IOS-STATIC-NEXT: movt r0, :upper16:_foo ret i32* @foo } @@ -32,8 +32,8 @@ entry: ; IOS-PIC: movw r1, :lower16:(L_foo$non_lazy_ptr-(LPC1_0+8)) ; IOS-PIC-NEXT: movt r1, :upper16:(L_foo$non_lazy_ptr-(LPC1_0+8)) -; IOS-STATIC-NOT: movw r1, :lower16:_foo -; IOS-STATIC-NOT: movt r1, :upper16:_foo +; IOS-STATIC: movw r1, :lower16:_foo +; IOS-STATIC-NEXT: movt r1, :upper16:_foo store i32 %baz, i32* @foo, align 4 ret void }