[PATCH] D137809: [LoongArch] Add immediate operand validity check for __builtin_loongarch_dbar
Gong LingQin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 10 17:45:54 PST 2022
gonglingqin created this revision.
gonglingqin added reviewers: xen0n, xry111, SixWeining, wangleiat, MaskRay.
Herald added a subscriber: StephenFan.
Herald added a project: All.
gonglingqin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137809
Files:
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/LoongArch/intrinsic-error.c
Index: clang/test/CodeGen/LoongArch/intrinsic-error.c
===================================================================
--- clang/test/CodeGen/LoongArch/intrinsic-error.c
+++ clang/test/CodeGen/LoongArch/intrinsic-error.c
@@ -6,3 +6,7 @@
int crc_w_d_w(long int a, int b) {
return __builtin_loongarch_crc_w_d_w(a, b); // expected-error {{this builtin requires target: loongarch64}}
}
+
+void dbar() {
+ return __builtin_loongarch_dbar(32768); // expected-error {{argument value 32768 is outside the valid range [0, 32767]}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3683,6 +3683,9 @@
diag::err_loongarch_builtin_requires_la64)
<< TheCall->getSourceRange();
break;
+ case LoongArch::BI__builtin_loongarch_dbar:
+ // Check if immediate is in [0, 32767]
+ return SemaBuiltinConstantArgRange(TheCall, 0, 0, 32767);
}
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137809.474641.patch
Type: text/x-patch
Size: 1031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221111/bf36dc5a/attachment.bin>
More information about the cfe-commits
mailing list