Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LoongArch] Diagnose the behavior of reading and writing registers th…
…at do not conform to the hardware register size When reading or writing a register that does not conform to the size of a hardware register, an error message is generated instead of a compiler crash. Differential Revision: https://reviews.llvm.org/D138008
- Loading branch information
1 parent
55fceef
commit eca62f9
Showing
4 changed files
with
78 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,21 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: not llc < %s --mtriple=loongarch32 2>&1 | FileCheck %s | ||
|
||
define i64 @read_sp() nounwind { | ||
entry: | ||
; CHECK: On LA32, only 32-bit registers can be read. | ||
%a1 = call i64 @llvm.read_register.i64(metadata !0) | ||
ret i64 %a1 | ||
} | ||
|
||
define void @write_sp(i64 %val) nounwind { | ||
entry: | ||
; CHECK: On LA32, only 32-bit registers can be written. | ||
call void @llvm.write_register.i64(metadata !0, i64 %val) | ||
ret void | ||
} | ||
|
||
declare i64 @llvm.read_register.i64(metadata) nounwind | ||
declare void @llvm.write_register.i64(metadata, i64) nounwind | ||
|
||
!0 = !{!"$sp\00"} |
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,21 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: not llc < %s --mtriple=loongarch64 2>&1 | FileCheck %s | ||
|
||
define i32 @read_sp() nounwind { | ||
entry: | ||
; CHECK: On LA64, only 64-bit registers can be read. | ||
%a1 = call i32 @llvm.read_register.i32(metadata !0) | ||
ret i32 %a1 | ||
} | ||
|
||
define void @write_sp(i32 %val) nounwind { | ||
entry: | ||
; CHECK: On LA64, only 64-bit registers can be written. | ||
call void @llvm.write_register.i32(metadata !0, i32 %val) | ||
ret void | ||
} | ||
|
||
declare i32 @llvm.read_register.i32(metadata) nounwind | ||
declare void @llvm.write_register.i32(metadata, i32) nounwind | ||
|
||
!0 = !{!"$sp\00"} |