forked from jeremyhu/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ARM] MSR instructions implicitly set CPSR
The MSR instructions can write to the CPSR, but we did not model this fact, so we could emit them in the middle of IT blocks, changing the condition flags for later instructions in the block. The tests use two calls to llvm.write_register.i32 because it is valid to use these instructions at the end of an IT block, which if conversion does do in some cases. With two calls, the first clobbers the flags, so a branch has to be used to make the second one conditional. Differential Revision: http://reviews.llvm.org/D21139 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272154 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
; RUN: llc < %s -mtriple=thumbv6m-none-eabi | FileCheck %s --check-prefix=V6M --check-prefix=CHECK | ||
; RUN: llc < %s -mtriple=thumbv7m-none-eabi | FileCheck %s --check-prefix=V7M --check-prefix=CHECK | ||
; RUN: llc < %s -mtriple=thumbv7a-none-eabi | FileCheck %s --check-prefix=V7A --check-prefix=CHECK | ||
; RUN: llc < %s -mtriple=armv7a-none-eabi | FileCheck %s --check-prefix=V7A --check-prefix=CHECK | ||
|
||
|
||
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" | ||
target triple = "armv7a-arm-none-eabi" | ||
|
||
define void @test_const(i32 %val) { | ||
; CHECK-LABEL: test_const: | ||
entry: | ||
%cmp = icmp eq i32 %val, 0 | ||
br i1 %cmp, label %write_reg, label %exit | ||
|
||
write_reg: | ||
tail call void @llvm.write_register.i32(metadata !0, i32 0) | ||
tail call void @llvm.write_register.i32(metadata !0, i32 0) | ||
; V6M: msr apsr, {{r[0-9]+}} | ||
; V6M: msr apsr, {{r[0-9]+}} | ||
; V7M: msr apsr_nzcvq, {{r[0-9]+}} | ||
; V7M: msr apsr_nzcvq, {{r[0-9]+}} | ||
; V7A: msr APSR_nzcvqg, {{r[0-9]+}} | ||
; V7A: msr APSR_nzcvqg, {{r[0-9]+}} | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
define void @test_var(i32 %val, i32 %apsr) { | ||
; CHECK-LABEL: test_var: | ||
entry: | ||
%cmp = icmp eq i32 %val, 0 | ||
br i1 %cmp, label %write_reg, label %exit | ||
|
||
write_reg: | ||
tail call void @llvm.write_register.i32(metadata !0, i32 %apsr) | ||
tail call void @llvm.write_register.i32(metadata !0, i32 %apsr) | ||
; V6M: msr apsr, {{r[0-9]+}} | ||
; V6M: msr apsr, {{r[0-9]+}} | ||
; V7M: msr apsr_nzcvq, {{r[0-9]+}} | ||
; V7M: msr apsr_nzcvq, {{r[0-9]+}} | ||
; V7A: msr APSR_nzcvqg, {{r[0-9]+}} | ||
; V7A: msr APSR_nzcvqg, {{r[0-9]+}} | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
|
||
declare void @llvm.write_register.i32(metadata, i32) | ||
|
||
!0 = !{!"apsr"} |