Skip to content

Commit faef073

Browse files
author
v01dxyz
committed
[Clang][AArch64] Fix typo with colon-separated syntax for system registers
The range for Op0 was set to 1 instead of 3. Since the ranges are all power of 2 minus 1, this commit reformulates them with the bitwidth of each part of the register to highlight the association with the encoding. cf one commit description explaining the encoding of an implementation-defined system register: e493f17
1 parent aad27bf commit faef073

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

clang/lib/Sema/SemaARM.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,16 @@ bool SemaARM::BuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall,
248248
}
249249
}
250250

251-
SmallVector<int, 5> Ranges;
251+
SmallVector<int, 5> FieldBitWidths;
252252
if (FiveFields)
253-
Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 15, 15, 7});
253+
FieldBitWidths.append({IsAArch64Builtin ? 2 : 4, 3, 4, 4, 3});
254254
else
255-
Ranges.append({15, 7, 15});
255+
FieldBitWidths.append({4, 3, 4});
256256

257257
for (unsigned i = 0; i < Fields.size(); ++i) {
258258
int IntField;
259259
ValidString &= !Fields[i].getAsInteger(10, IntField);
260-
ValidString &= (IntField >= 0 && IntField <= Ranges[i]);
260+
ValidString &= (IntField >= 0 && IntField < (1 << FieldBitWidths[i]));
261261
}
262262

263263
if (!ValidString)

clang/test/Sema/aarch64-special-register.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ unsigned long rsr64_6(void) {
116116
return __builtin_arm_rsr64("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
117117
}
118118

119+
void rsr64_7(unsigned long *r) {
120+
// The following three instructions should produce the same assembly.
121+
r[0] = __builtin_arm_rsr64("ICC_CTLR_EL3");
122+
r[1] = __builtin_arm_rsr64("s3_6_c12_c12_4");
123+
r[2] = __builtin_arm_rsr64("3:6:12:12:4");
124+
}
125+
119126
__uint128_t rsr128_3(void) {
120127
return __builtin_arm_rsr128("0:1:2"); //expected-error {{invalid special register for builtin}}
121128
}

0 commit comments

Comments
 (0)