mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
a66e68bb52
The ldr-pseudo opcode is a convenience for loading 32-bit constants. It is converted into a pc-relative load from a constant pool. For example, ldr r0, =0x10001 ldr r1, =bar will generate this output in the final assembly ldr r0, .Ltmp0 ldr r1, .Ltmp1 ... .Ltmp0: .long 0x10001 .Ltmp1: .long bar Sketch of the LDR pseudo implementation: Keep a map from Section => ConstantPool When parsing ldr r0, =val parse val as an MCExpr get ConstantPool for current Section Label = CreateTempSymbol() remember val in ConstantPool at next free slot add operand to ldr that is MCSymbolRef of Label On finishParse() callback Write out all non-empty constant pools for each Entry in ConstantPool Emit Entry.Label Emit Entry.Value Possible improvements to be added in a later patch: 1. Does not convert load of small constants to mov (e.g. ldr r0, =0x1 => mov r0, 0x1) 2. Does reuse constant pool entries for same constant The implementation was tested for ARM, Thumb1, and Thumb2 targets on linux and darwin. llvm-svn: 197708
18 lines
632 B
ArmAsm
18 lines
632 B
ArmAsm
@RUN: not llvm-mc -triple=armv7-unknown-linux-gnueabi -filetype=obj %s -o %t1 2> %t2
|
|
@RUN: cat %t2 | FileCheck %s
|
|
@RUN: not llvm-mc -triple=armv7-darwin-apple -filetype=obj %s -o %t1_darwin 2> %t2_darwin
|
|
@RUN: cat %t2_darwin | FileCheck %s
|
|
|
|
@These tests look for errors that should be reported for invalid object layout
|
|
@with the ldr pseudo. They are tested separately from parse errors because they
|
|
@only trigger when the file has successfully parsed and the object file is about
|
|
@to be written out.
|
|
|
|
.text
|
|
foo:
|
|
ldr r0, =0x101
|
|
.space 8000
|
|
@ CHECK: error: out of range pc-relative fixup value
|
|
@ CHECK: ldr r0, =0x101
|
|
@ CHECK: ^
|