kamaub created this revision. kamaub added reviewers: PowerPC, nemanjai, lei, stefanp. Herald added subscribers: shchenz, kbarton. kamaub requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
The builtin __rlwnm is currently constrained to accept only constants for the shift parameter but the instructions emitted for it have no such constraint, this patch allows the builtins to accept variable shift. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D111229 Files: clang/include/clang/Basic/BuiltinsPPC.def clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-ppc-xlcompat-error.c Index: clang/test/CodeGen/builtins-ppc-xlcompat-error.c =================================================================== --- clang/test/CodeGen/builtins-ppc-xlcompat-error.c +++ clang/test/CodeGen/builtins-ppc-xlcompat-error.c @@ -43,7 +43,7 @@ void test_builtin_ppc_rlwnm() { unsigned int shift; unsigned int mask; - unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}} + unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); res = __builtin_ppc_rlwnm(ui, 31, mask); // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}} res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00); // expected-error {{argument 2 value should represent a contiguous bit field}} } Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -3432,8 +3432,7 @@ // For __rlwnm, __rlwimi and __rldimi, the last parameter mask must // be a constant that represents a contiguous bit field. case PPC::BI__builtin_ppc_rlwnm: - return SemaBuiltinConstantArg(TheCall, 1, Result) || - SemaValueIsRunOfOnes(TheCall, 2); + return SemaValueIsRunOfOnes(TheCall, 2); case PPC::BI__builtin_ppc_rlwimi: case PPC::BI__builtin_ppc_rldimi: return SemaBuiltinConstantArg(TheCall, 2, Result) || Index: clang/include/clang/Basic/BuiltinsPPC.def =================================================================== --- clang/include/clang/Basic/BuiltinsPPC.def +++ clang/include/clang/Basic/BuiltinsPPC.def @@ -117,7 +117,7 @@ BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "") BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "") // Rotate -BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "") +BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "") BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "") BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "") // load
Index: clang/test/CodeGen/builtins-ppc-xlcompat-error.c =================================================================== --- clang/test/CodeGen/builtins-ppc-xlcompat-error.c +++ clang/test/CodeGen/builtins-ppc-xlcompat-error.c @@ -43,7 +43,7 @@ void test_builtin_ppc_rlwnm() { unsigned int shift; unsigned int mask; - unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}} + unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); res = __builtin_ppc_rlwnm(ui, 31, mask); // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}} res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00); // expected-error {{argument 2 value should represent a contiguous bit field}} } Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -3432,8 +3432,7 @@ // For __rlwnm, __rlwimi and __rldimi, the last parameter mask must // be a constant that represents a contiguous bit field. case PPC::BI__builtin_ppc_rlwnm: - return SemaBuiltinConstantArg(TheCall, 1, Result) || - SemaValueIsRunOfOnes(TheCall, 2); + return SemaValueIsRunOfOnes(TheCall, 2); case PPC::BI__builtin_ppc_rlwimi: case PPC::BI__builtin_ppc_rldimi: return SemaBuiltinConstantArg(TheCall, 2, Result) || Index: clang/include/clang/Basic/BuiltinsPPC.def =================================================================== --- clang/include/clang/Basic/BuiltinsPPC.def +++ clang/include/clang/Basic/BuiltinsPPC.def @@ -117,7 +117,7 @@ BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "") BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "") // Rotate -BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "") +BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "") BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "") BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "") // load
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits