
[ARM] generate armv6m eXecute Only (XO) code for immediates, globals Previously eXecute Only (XO) support was implemented for targets that support MOVW/MOVT (~armv7+). See: https://reviews.llvm.org/D27449 XO prevents the compiler from generating data accesses to code sections. This patch implements XO codegen for armv6-M, which does not support MOVW/MOVT, and must resort to the following general pattern to avoid loads: movs r3, :upper8_15:foo lsls r3, #8 adds r3, :upper0_7:foo lsls r3, #8 adds r3, :lower8_15:foo lsls r3, #8 adds r3, :lower0_7:foo ldr r3, [r3] This is equivalent to the code pattern generated by GCC. The above relocations are new to LLVM and have been implemented in a parent patch: https://reviews.llvm.org/D149443. This patch limits itself to implementing codegen for this pattern and enabling XO for armv6-M in the backend. Separate patches will follow for: - switch tables - replacing specific loads from constant islands which are spread out over the ARM backend codebase. Amongst others: FastISel, call lowering, stack frames. Reviewed By: john.brawn Differential Revision: https://reviews.llvm.org/D152795
26 lines
947 B
LLVM
26 lines
947 B
LLVM
; RUN: llc < %s -mtriple=thumbv6m -mattr=+execute-only %s -o - | FileCheck %s
|
|
; RUN: llc < %s -mtriple=thumbv7m -mattr=+execute-only %s -o - | FileCheck %s
|
|
; RUN: llc < %s -mtriple=thumbv8m.base -mattr=+execute-only %s -o - | FileCheck %s
|
|
; RUN: llc < %s -mtriple=thumbv8m.base -mcpu=cortex-m23 -mattr=+execute-only %s -o - | FileCheck %s
|
|
; RUN: llc < %s -mtriple=thumbv8m.main -mattr=+execute-only %s -o - | FileCheck %s
|
|
|
|
; CHECK: .section .text,"axy",%progbits,unique,0
|
|
; CHECK-NOT: .section
|
|
; CHECK-NOT: .text
|
|
; CHECK: .globl test_SectionForGlobal
|
|
; CHECK: .type test_SectionForGlobal,%function
|
|
define void @test_SectionForGlobal() {
|
|
entry:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: .section .test,"axy",%progbits
|
|
; CHECK-NOT: .section
|
|
; CHECK-NOT: .text
|
|
; CHECK: .globl test_ExplicitSectionForGlobal
|
|
; CHECK: .type test_ExplicitSectionForGlobal,%function
|
|
define void @test_ExplicitSectionForGlobal() section ".test" {
|
|
entry:
|
|
ret void
|
|
}
|