mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
741830615d
When writing a unit test on replacing standard epilogue sequences with `BR __mspabi_func_epilog_<N>`, by manually asm-clobbering `rN` - `r10` for N = 4..10, everything worked well except for seeming inability to clobber r4. The problem was that MSP430 code generator of LLVM used an obsolete name FP for that register. Things were worse because when `llc` read an unknown register name, it silently ignored it. That is, I cannot use `fp` register name from the C code because Clang does not accept it (exactly like GCC). But the accepted name `r4` is not recognised by `llc` (it can be used in listings passed to `llvm-mc` and even `fp` is replace to `r4` by `llvm-mc`). So I can specify any of `fp` or `r4` for the string literal of `asm(...)` but nothing in the clobber list. This patch replaces `MSP430::FP` with `MSP430::R4` in the backend code (even [MSP430 EABI](http://www.ti.com/lit/an/slaa534/slaa534.pdf) doesn't mention FP as a register name). The R0 - R3 registers, on the other hand, are left as is in the backend code (after all, they have some special meaning on the ISA level). It is just ensured clang is renaming them as expected by the downstream tools. There is probably not much sense in **marking them clobbered** but rename them //just in case// for use at potentially different contexts. Differential Revision: https://reviews.llvm.org/D82184
57 lines
1.1 KiB
LLVM
57 lines
1.1 KiB
LLVM
; RUN: llc < %s | FileCheck %s
|
|
|
|
target datalayout = "e-m:e-p:16:16-i32:16:32-a:16-n8:16"
|
|
target triple = "msp430---elf"
|
|
|
|
define void @test_no_clobber() {
|
|
entry:
|
|
; CHECK-LABEL: test_no_clobber
|
|
; CHECK-NOT: push
|
|
call void asm sideeffect "", ""()
|
|
; CHECK-NOT: pop
|
|
ret void
|
|
; CHECK: -- End function
|
|
}
|
|
|
|
define void @test_1() {
|
|
entry:
|
|
; CHECK-LABEL: test_1:
|
|
; CHECK: push r8
|
|
; CHECK: push r6
|
|
; CHECK: push r4
|
|
call void asm sideeffect "", "~{r4},~{r6},~{r8}"()
|
|
; CHECK: pop r4
|
|
; CHECK: pop r6
|
|
; CHECK: pop r8
|
|
ret void
|
|
}
|
|
|
|
define void @test_2() {
|
|
entry:
|
|
; CHECK-LABEL: test_2:
|
|
; CHECK: push r9
|
|
; CHECK: push r7
|
|
; CHECK: push r5
|
|
call void asm sideeffect "", "~{r5},~{r7},~{r9}"()
|
|
; CHECK: pop r5
|
|
; CHECK: pop r7
|
|
; CHECK: pop r9
|
|
ret void
|
|
}
|
|
|
|
; The r10 register is special because the sequence
|
|
; pop r10
|
|
; ret
|
|
; can be replaced with
|
|
; jmp __mspabi_func_epilog_1
|
|
; or other such function (depending on previous instructions).
|
|
; Still, it is not replaced *yet*.
|
|
define void @test_r10() {
|
|
entry:
|
|
; CHECK-LABEL: test_r10:
|
|
; CHECK: push r10
|
|
call void asm sideeffect "", "~{r10}"()
|
|
; CHECK: pop r10
|
|
ret void
|
|
}
|