r287378 - [ARM] Fix sema check of ARM special register names
Oleg Ranevskyy via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 18 13:00:08 PST 2016
Author: oleg
Date: Fri Nov 18 15:00:08 2016
New Revision: 287378
URL: http://llvm.org/viewvc/llvm-project?rev=287378&view=rev
Log:
[ARM] Fix sema check of ARM special register names
Summary:
This is a simple sema check patch for arguments of `__builtin_arm_rsr` and the related builtins, which currently do not allow special registers with indexes >7.
Some of the possible register name formats these builtins accept are:
```
{c}p<coprocessor>:<op1>:c<CRn>:c<CRm>:<op2>
```
```
o0:op1:CRn:CRm:op2
```
where `op1` / `op2` are integers in the range [0, 7] and `CRn` / `CRm` are integers in the range [0, 15].
The current sema check does not allow `CRn` > 7 and accepts `op2` up to 15.
Reviewers: LukeCheeseman, rengolin
Subscribers: asl, aemerson, rengolin, cfe-commits
Differential Revision: https://reviews.llvm.org/D26464
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/aarch64-special-register.c
cfe/trunk/test/Sema/arm-special-register.c
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=287378&r1=287377&r2=287378&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Nov 18 15:00:08 2016
@@ -4194,7 +4194,7 @@ bool Sema::SemaBuiltinARMSpecialReg(unsi
SmallVector<int, 5> Ranges;
if (FiveFields)
- Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 7, 15, 15});
+ Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 15, 15, 7});
else
Ranges.append({15, 7, 15});
Modified: cfe/trunk/test/Sema/aarch64-special-register.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/aarch64-special-register.c?rev=287378&r1=287377&r2=287378&view=diff
==============================================================================
--- cfe/trunk/test/Sema/aarch64-special-register.c (original)
+++ cfe/trunk/test/Sema/aarch64-special-register.c Fri Nov 18 15:00:08 2016
@@ -41,7 +41,7 @@ void wsr64_2(unsigned long v) {
}
unsigned rsr_2() {
- return __builtin_arm_rsr("0:1:2:3:4");
+ return __builtin_arm_rsr("0:1:15:15:4");
}
void *rsrp_2() {
@@ -49,7 +49,7 @@ void *rsrp_2() {
}
unsigned long rsr64_2() {
- return __builtin_arm_rsr64("0:1:2:3:4");
+ return __builtin_arm_rsr64("0:1:15:15:4");
}
void wsr_3(unsigned v) {
@@ -68,6 +68,18 @@ unsigned rsr_3() {
return __builtin_arm_rsr("0:1:2"); //expected-error {{invalid special register for builtin}}
}
+unsigned rsr_4() {
+ return __builtin_arm_rsr("0:1:2:3:8"); //expected-error {{invalid special register for builtin}}
+}
+
+unsigned rsr_5() {
+ return __builtin_arm_rsr("0:8:1:2:3"); //expected-error {{invalid special register for builtin}}
+}
+
+unsigned rsr_6() {
+ return __builtin_arm_rsr("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
+}
+
void *rsrp_3() {
return __builtin_arm_rsrp("0:1:2"); //expected-error {{invalid special register for builtin}}
}
@@ -75,3 +87,15 @@ void *rsrp_3() {
unsigned long rsr64_3() {
return __builtin_arm_rsr64("0:1:2"); //expected-error {{invalid special register for builtin}}
}
+
+unsigned long rsr64_4() {
+ return __builtin_arm_rsr64("0:1:2:3:8"); //expected-error {{invalid special register for builtin}}
+}
+
+unsigned long rsr64_5() {
+ return __builtin_arm_rsr64("0:8:2:3:4"); //expected-error {{invalid special register for builtin}}
+}
+
+unsigned long rsr64_6() {
+ return __builtin_arm_rsr64("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
+}
Modified: cfe/trunk/test/Sema/arm-special-register.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arm-special-register.c?rev=287378&r1=287377&r2=287378&view=diff
==============================================================================
--- cfe/trunk/test/Sema/arm-special-register.c (original)
+++ cfe/trunk/test/Sema/arm-special-register.c Fri Nov 18 15:00:08 2016
@@ -41,7 +41,7 @@ void wsr64_2(unsigned long v) {
}
unsigned rsr_2() {
- return __builtin_arm_rsr("cp0:1:c2:c3:4");
+ return __builtin_arm_rsr("cp0:1:c15:c15:4");
}
void *rsrp_2() {
@@ -73,13 +73,25 @@ void *rsrp_3() {
}
unsigned long rsr64_3() {
- return __builtin_arm_rsr64("cp0:1:c2");
+ return __builtin_arm_rsr64("cp0:1:c15");
}
unsigned rsr_4() {
return __builtin_arm_rsr("0:1:2:3:4"); //expected-error {{invalid special register for builtin}}
}
+unsigned rsr_5() {
+ return __builtin_arm_rsr("cp0:1:c2:c3:8"); //expected-error {{invalid special register for builtin}}
+}
+
+unsigned rsr_6() {
+ return __builtin_arm_rsr("cp0:8:c1:c2:3"); //expected-error {{invalid special register for builtin}}
+}
+
+unsigned rsr_7() {
+ return __builtin_arm_rsr("cp0:1:c16:c16:2"); //expected-error {{invalid special register for builtin}}
+}
+
void *rsrp_4() {
return __builtin_arm_rsrp("0:1:2:3:4"); //expected-error {{invalid special register for builtin}}
}
@@ -87,3 +99,11 @@ void *rsrp_4() {
unsigned long rsr64_4() {
return __builtin_arm_rsr64("0:1:2"); //expected-error {{invalid special register for builtin}}
}
+
+unsigned long rsr64_5() {
+ return __builtin_arm_rsr64("cp0:8:c1"); //expected-error {{invalid special register for builtin}}
+}
+
+unsigned long rsr64_6() {
+ return __builtin_arm_rsr64("cp0:1:c16"); //expected-error {{invalid special register for builtin}}
+}
More information about the cfe-commits
mailing list