philnik updated this revision to Diff 409629.
philnik marked an inline comment as done.
philnik added a comment.
Herald added a subscriber: mstorsjo.
- Add tests
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114425/new/
https://reviews.llvm.org/D114425
Files:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Builtins.def
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtin-bswap128.c
clang/test/CodeGen/builtins.cpp
clang/test/Sema/builtin-bswap128.c
clang/test/Sema/constant-builtins-2.c
Index: clang/test/Sema/constant-builtins-2.c
===================================================================
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -216,6 +216,9 @@
int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f();
int h4 = __builtin_bswap32(0x1234) == 0x34120000 ? 1 : f();
int h5 = __builtin_bswap64(0x1234) == 0x3412000000000000 ? 1 : f();
+#if defined(__SIZEOF_INT128__)
+int h6 = __builtin_bswap128(0x1234) == (((__int128)0x3412) << 112) ? 1 : f();
+#endif
extern long int bi0;
extern __typeof__(__builtin_expect(0, 0)) bi0;
Index: clang/test/Sema/builtin-bswap128.c
===================================================================
--- /dev/null
+++ clang/test/Sema/builtin-bswap128.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify %s
+
+void test() {
+ __builtin_bswap128(1); // expected-error {{use of unknown builtin '__builtin_bswap128'}}
+}
Index: clang/test/CodeGen/builtins.cpp
===================================================================
--- clang/test/CodeGen/builtins.cpp
+++ clang/test/CodeGen/builtins.cpp
@@ -20,6 +20,10 @@
decltype(__builtin_bswap32(0)) bswap32 = 42;
extern uint64_t bswap64;
decltype(__builtin_bswap64(0)) bswap64 = 42;
+#ifdef __SIZEOF_INT128__
+extern __uint128_t bswap128;
+decltype(__builtin_bswap128(0)) bswap128 = 42;
+#endif
#ifdef __clang__
extern uint8_t bitrev8;
Index: clang/test/CodeGen/builtin-bswap128.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/builtin-bswap128.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @test(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: [[R1:%.*]] = alloca i128, align 16
+// CHECK-NEXT: [[R2:%.*]] = alloca i128, align 16
+// CHECK-NEXT: store i128 1329227995784915872903807060280344576, i128* [[R1:%.*]], align 16
+// CHECK-NEXT: store i128 2658455991569831745807614120560689152, i128* [[R2:%.*]], align 16
+void test() {
+ __int128 r1 = __builtin_bswap128(1);
+ __int128 r2 = __builtin_bswap128((__int128)2);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2929,7 +2929,8 @@
}
case Builtin::BI__builtin_bswap16:
case Builtin::BI__builtin_bswap32:
- case Builtin::BI__builtin_bswap64: {
+ case Builtin::BI__builtin_bswap64:
+ case Builtin::BI__builtin_bswap128: {
return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
}
case Builtin::BI__builtin_bitreverse8:
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11784,7 +11784,8 @@
case Builtin::BI__builtin_bswap16:
case Builtin::BI__builtin_bswap32:
- case Builtin::BI__builtin_bswap64: {
+ case Builtin::BI__builtin_bswap64:
+ case Builtin::BI__builtin_bswap128: {
APSInt Val;
if (!EvaluateInteger(E->getArg(0), Val, Info))
return false;
Index: clang/lib/AST/ASTContext.cpp
===================================================================
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -10839,8 +10839,8 @@
/// to be an Integer Constant Expression.
static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
ASTContext::GetBuiltinTypeError &Error,
- bool &RequiresICE,
- bool AllowTypeModifiers) {
+ bool &RequiresICE, bool AllowTypeModifiers,
+ bool AllowInt128 = false) {
// Modifiers.
int HowLong = 0;
bool Signed = false, Unsigned = false;
@@ -10983,9 +10983,13 @@
Type = Context.ShortTy;
break;
case 'i':
- if (HowLong == 3)
+ if (HowLong == 3) {
+ if (!AllowInt128 && !Context.getTargetInfo().hasInt128Type()) {
+ Error = ASTContext::GE_Missing_type;
+ return {};
+ }
Type = Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
- else if (HowLong == 2)
+ } else if (HowLong == 2)
Type = Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
else if (HowLong == 1)
Type = Unsigned ? Context.UnsignedLongTy : Context.LongTy;
@@ -11064,8 +11068,8 @@
assert(End != Str && "Missing vector size");
Str = End;
- QualType ElementType = DecodeTypeFromStr(Str, Context, Error,
- RequiresICE, false);
+ QualType ElementType =
+ DecodeTypeFromStr(Str, Context, Error, RequiresICE, false, true);
assert(!RequiresICE && "Can't require vector ICE");
// TODO: No way to make AltiVec vectors in builtins yet.
Index: clang/include/clang/Basic/Builtins.def
===================================================================
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -513,6 +513,7 @@
BUILTIN(__builtin_bswap16, "UsUs", "nc")
BUILTIN(__builtin_bswap32, "UZiUZi", "nc")
BUILTIN(__builtin_bswap64, "UWiUWi", "nc")
+BUILTIN(__builtin_bswap128, "ULLLiULLLi", "nc")
BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -60,6 +60,14 @@
Non-comprehensive list of changes in this release
-------------------------------------------------
+- Maximum _ExtInt size was decreased from 16,777,215 bits to 8,388,608 bits.
+ Motivation for this was discussed in PR51829.
+- Configuration file syntax extended with ``<CFGDIR>`` token. This expands to
+ the base path of the current config file. See :ref:`configuration-files` for
+ details.
+
+- The builtin ``__builtin_bswap128`` was added.
+
New Compiler Flags
------------------
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits