mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
Add PIC load and store patterns for Thumb-2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74577 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -419,6 +419,18 @@ multiclass T2I_st<string opc, PatFrag opnode> {
|
|||||||
[(opnode GPR:$src, t2addrmode_so_reg:$addr)]>;
|
[(opnode GPR:$src, t2addrmode_so_reg:$addr)]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// T2I_picld - Defines the PIC load pattern.
|
||||||
|
class T2I_picld<string opc, PatFrag opnode> :
|
||||||
|
T2I<(outs GPR:$dst), (ins addrmodepc:$addr),
|
||||||
|
!strconcat("${addr:label}:\n\t", opc), " $dst, $addr",
|
||||||
|
[(set GPR:$dst, (opnode addrmodepc:$addr))]>;
|
||||||
|
|
||||||
|
/// T2I_picst - Defines the PIC store pattern.
|
||||||
|
class T2I_picst<string opc, PatFrag opnode> :
|
||||||
|
T2I<(outs), (ins GPR:$src, addrmodepc:$addr),
|
||||||
|
!strconcat("${addr:label}:\n\t", opc), " $src, $addr",
|
||||||
|
[(opnode GPR:$src, addrmodepc:$addr)]>;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Instructions
|
// Instructions
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -539,6 +551,22 @@ let mayLoad = 1 in
|
|||||||
def t2STRDi8 : T2Ii8s4<(outs), (ins GPR:$src, t2addrmode_imm8s4:$addr),
|
def t2STRDi8 : T2Ii8s4<(outs), (ins GPR:$src, t2addrmode_imm8s4:$addr),
|
||||||
"strd", " $src, $addr", []>;
|
"strd", " $src, $addr", []>;
|
||||||
|
|
||||||
|
|
||||||
|
// Address computation and loads and stores in PIC mode.
|
||||||
|
let isNotDuplicable = 1, AddedComplexity = 10 in {
|
||||||
|
let canFoldAsLoad = 1 in
|
||||||
|
def t2PICLDR : T2I_picld<"ldr", UnOpFrag<(load node:$Src)>>;
|
||||||
|
|
||||||
|
def t2PICLDRH : T2I_picld<"ldrh", UnOpFrag<(zextloadi16 node:$Src)>>;
|
||||||
|
def t2PICLDRB : T2I_picld<"ldrb", UnOpFrag<(zextloadi8 node:$Src)>>;
|
||||||
|
def t2PICLDRSH : T2I_picld<"ldrsh", UnOpFrag<(sextloadi16 node:$Src)>>;
|
||||||
|
def t2PICLDRSB : T2I_picld<"ldrsb", UnOpFrag<(sextloadi8 node:$Src)>>;
|
||||||
|
|
||||||
|
def t2PICSTR : T2I_picst<"str", BinOpFrag<(store node:$LHS, node:$RHS)>>;
|
||||||
|
def t2PICSTRH : T2I_picst<"strh", BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
|
||||||
|
def t2PICSTRB : T2I_picst<"strb", BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
|
||||||
|
} // isNotDuplicable = 1, AddedComplexity = 10
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Move Instructions.
|
// Move Instructions.
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
; RUN: llvm-as < %s | llc -mtriple=thumbv7-apple-darwin
|
; RUN: llvm-as < %s | \
|
||||||
; RUN: llvm-as < %s | llc -mtriple=thumbv7-apple-darwin -relocation-model=pic | grep add | grep pc
|
; RUN: llc -mtriple=thumbv7-apple-darwin -relocation-model=static | \
|
||||||
|
; RUN: not grep {L_G\$non_lazy_ptr}
|
||||||
|
; RUN: llvm-as < %s | \
|
||||||
|
; RUN: llc -mtriple=thumbv7-apple-darwin -relocation-model=dynamic-no-pic | \
|
||||||
|
; RUN: grep {L_G\$non_lazy_ptr} | count 2
|
||||||
|
; RUN: llvm-as < %s | \
|
||||||
|
; RUN: llc -mtriple=thumbv7-apple-darwin -relocation-model=pic | \
|
||||||
|
; RUN: grep {ldr.*pc} | count 1
|
||||||
|
; RUN: llvm-as < %s | \
|
||||||
|
; RUN: llc -mtriple=thumbv7-linux-gnueabi -relocation-model=pic | \
|
||||||
|
; RUN: grep {GOT} | count 1
|
||||||
|
|
||||||
@G = external global i32
|
@G = external global i32
|
||||||
|
|
||||||
|
20
test/CodeGen/Thumb2/tls1.ll
Normal file
20
test/CodeGen/Thumb2/tls1.ll
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
; RUN: llvm-as < %s | llc -mtriple=thumbv7-linux-gnueabi | \
|
||||||
|
; RUN: grep {i(tpoff)}
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=thumbv7-linux-gnueabi | \
|
||||||
|
; RUN: grep {__aeabi_read_tp}
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=thumbv7-linux-gnueabi \
|
||||||
|
; RUN: -relocation-model=pic | grep {__tls_get_addr}
|
||||||
|
|
||||||
|
|
||||||
|
@i = thread_local global i32 15 ; <i32*> [#uses=2]
|
||||||
|
|
||||||
|
define i32 @f() {
|
||||||
|
entry:
|
||||||
|
%tmp1 = load i32* @i ; <i32> [#uses=1]
|
||||||
|
ret i32 %tmp1
|
||||||
|
}
|
||||||
|
|
||||||
|
define i32* @g() {
|
||||||
|
entry:
|
||||||
|
ret i32* @i
|
||||||
|
}
|
19
test/CodeGen/Thumb2/tls2.ll
Normal file
19
test/CodeGen/Thumb2/tls2.ll
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
; RUN: llvm-as < %s | llc -mtriple=thumbv7-linux-gnueabi | \
|
||||||
|
; RUN: grep {i(gottpoff)}
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=thumbv7-linux-gnueabi | \
|
||||||
|
; RUN: grep {ldr r., \[pc, r.\]}
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=thumbv7-linux-gnueabi \
|
||||||
|
; RUN: -relocation-model=pic | grep {__tls_get_addr}
|
||||||
|
|
||||||
|
@i = external thread_local global i32 ; <i32*> [#uses=2]
|
||||||
|
|
||||||
|
define i32 @f() {
|
||||||
|
entry:
|
||||||
|
%tmp1 = load i32* @i ; <i32> [#uses=1]
|
||||||
|
ret i32 %tmp1
|
||||||
|
}
|
||||||
|
|
||||||
|
define i32* @g() {
|
||||||
|
entry:
|
||||||
|
ret i32* @i
|
||||||
|
}
|
Reference in New Issue
Block a user