Skip to content

Commit 98162f1

Browse files
authored
Merge branch 'main' into neg_indices
2 parents 0d3cc18 + 3b010c9 commit 98162f1

File tree

17 files changed

+334
-111
lines changed

17 files changed

+334
-111
lines changed

clang-tools-extra/clang-doc/JSONGenerator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ static void insertArray(Object &Obj, json::Value &Array, StringRef Key) {
468468
static void serializeInfo(const RecordInfo &I, json::Object &Obj,
469469
const std::optional<StringRef> &RepositoryUrl) {
470470
serializeCommonAttributes(I, Obj, RepositoryUrl);
471-
Obj["FullName"] = I.FullName;
472471
Obj["TagType"] = getTagType(I.TagType);
473472
Obj["IsTypedef"] = I.IsTypeDef;
474473
Obj["MangledName"] = I.MangledName;

clang-tools-extra/clang-doc/Representation.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,6 @@ struct FunctionInfo : public SymbolInfo {
437437
// (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
438438
AccessSpecifier Access = AccessSpecifier::AS_public;
439439

440-
// Full qualified name of this function, including namespaces and template
441-
// specializations.
442-
SmallString<16> FullName;
443-
444440
// Function Prototype
445441
SmallString<256> Prototype;
446442

@@ -460,10 +456,6 @@ struct RecordInfo : public SymbolInfo {
460456
// Type of this record (struct, class, union, interface).
461457
TagTypeKind TagType = TagTypeKind::Struct;
462458

463-
// Full qualified name of this record, including namespaces and template
464-
// specializations.
465-
SmallString<16> FullName;
466-
467459
// When present, this record is a template or specialization.
468460
std::optional<TemplateInfo> Template;
469461

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -178,55 +178,6 @@ static llvm::SmallString<16> getTypeAlias(const TypeAliasDecl *Alias) {
178178
return Result;
179179
}
180180

181-
// extract full syntax for record declaration
182-
static llvm::SmallString<16> getRecordPrototype(const CXXRecordDecl *CXXRD) {
183-
llvm::SmallString<16> Result;
184-
LangOptions LangOpts;
185-
PrintingPolicy Policy(LangOpts);
186-
Policy.SuppressTagKeyword = false;
187-
Policy.FullyQualifiedName = true;
188-
Policy.IncludeNewlines = false;
189-
llvm::raw_svector_ostream OS(Result);
190-
if (const auto *TD = CXXRD->getDescribedClassTemplate()) {
191-
OS << "template <";
192-
bool FirstParam = true;
193-
for (const auto *Param : *TD->getTemplateParameters()) {
194-
if (!FirstParam)
195-
OS << ", ";
196-
Param->print(OS, Policy);
197-
FirstParam = false;
198-
}
199-
OS << ">\n";
200-
}
201-
202-
if (CXXRD->isStruct())
203-
OS << "struct ";
204-
else if (CXXRD->isClass())
205-
OS << "class ";
206-
else if (CXXRD->isUnion())
207-
OS << "union ";
208-
209-
OS << CXXRD->getNameAsString();
210-
211-
// We need to make sure we have a good enough declaration to check. In the
212-
// case where the class is a forward declaration, we'll fail assertions in
213-
// DeclCXX.
214-
if (CXXRD->isCompleteDefinition() && CXXRD->getNumBases() > 0) {
215-
OS << " : ";
216-
bool FirstBase = true;
217-
for (const auto &Base : CXXRD->bases()) {
218-
if (!FirstBase)
219-
OS << ", ";
220-
if (Base.isVirtual())
221-
OS << "virtual ";
222-
OS << getAccessSpelling(Base.getAccessSpecifier()) << " ";
223-
OS << Base.getType().getAsString(Policy);
224-
FirstBase = false;
225-
}
226-
}
227-
return Result;
228-
}
229-
230181
// A function to extract the appropriate relative path for a given info's
231182
// documentation. The path returned is a composite of the parent namespaces.
232183
//
@@ -1033,7 +984,6 @@ emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc,
1033984
parseFields(*RI, D, PublicOnly);
1034985

1035986
if (const auto *C = dyn_cast<CXXRecordDecl>(D)) {
1036-
RI->FullName = getRecordPrototype(C);
1037987
if (const TypedefNameDecl *TD = C->getTypedefNameForAnonDecl()) {
1038988
RI->Name = TD->getNameAsString();
1039989
RI->IsTypeDef = true;

clang-tools-extra/test/clang-doc/json/class.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ struct MyClass {
124124
// CHECK-NEXT: }
125125
// CHECK-NEXT: }
126126
// CHECK-NEXT: ],
127-
// COM: FIXME: FullName is not emitted correctly.
128-
// CHECK-NEXT: "FullName": "",
129127
// CHECK-NEXT: "HasEnums": true,
130128
// CHECK-NEXT: "HasPublicFunctions": true,
131129
// CHECK-NEXT: "HasPublicMembers": true,

clang-tools-extra/unittests/clang-doc/JSONGeneratorTest.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ static std::unique_ptr<Generator> getJSONGenerator() {
1616
TEST(JSONGeneratorTest, emitRecordJSON) {
1717
RecordInfo I;
1818
I.Name = "Foo";
19-
// FIXME: FullName is not emitted correctly.
20-
I.FullName = "";
2119
I.IsTypeDef = false;
2220
I.Namespace.emplace_back(EmptySID, "GlobalNamespace", InfoType::IT_namespace);
2321
I.Path = "GlobalNamespace";
@@ -64,7 +62,6 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
6462
{
6563
"Access": "public",
6664
"End": true,
67-
"FullName": "",
6865
"HasPublicFunctions": true,
6966
"HasPublicMembers": true,
7067
"InfoType": "record",
@@ -115,7 +112,6 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
115112
"USR": "0000000000000000000000000000000000000000"
116113
}
117114
],
118-
"FullName": "",
119115
"HasEnums": true,
120116
"HasPublicFunctions": true,
121117
"HasRecords": true,

clang/docs/LanguageExtensions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ of different sizes and signs is forbidden in binary and ternary builtins.
807807
T __builtin_elementwise_exp(T x) returns the base-e exponential, e^x, of the specified value floating point types
808808
T __builtin_elementwise_exp2(T x) returns the base-2 exponential, 2^x, of the specified value floating point types
809809
T __builtin_elementwise_exp10(T x) returns the base-10 exponential, 10^x, of the specified value floating point types
810+
T __builtin_elementwise_ldexp(T x, IntT y) returns the product of x and 2 raised to the power y. T: floating point types,
811+
y must be an integer type matching the shape of x. IntT: integer types
810812

811813
T __builtin_elementwise_sqrt(T x) return the square root of a floating-point number floating point types
812814
T __builtin_elementwise_roundeven(T x) round x to the nearest integer value in floating point format, floating point types

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ C23 Feature Support
214214

215215
Non-comprehensive list of changes in this release
216216
-------------------------------------------------
217+
- Added ``__builtin_elementwise_ldexp``.
218+
217219
- Added ``__builtin_elementwise_fshl`` and ``__builtin_elementwise_fshr``.
218220

219221
- ``__builtin_elementwise_abs`` can now be used in constant expression.

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,12 @@ def ElementwiseExp10 : Builtin {
14181418
let Prototype = "void(...)";
14191419
}
14201420

1421+
def ElementwiseLdexp : Builtin {
1422+
let Spellings = ["__builtin_elementwise_ldexp"];
1423+
let Attributes = [NoThrow, Const, CustomTypeChecking];
1424+
let Prototype = "void(...)";
1425+
}
1426+
14211427
def ElementwiseFloor : Builtin {
14221428
let Spellings = ["__builtin_elementwise_floor"];
14231429
let Attributes = [NoThrow, Const, CustomTypeChecking];

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3992,6 +3992,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
39923992
case Builtin::BI__builtin_elementwise_exp10:
39933993
return RValue::get(emitBuiltinWithOneOverloadedType<1>(
39943994
*this, E, Intrinsic::exp10, "elt.exp10"));
3995+
case Builtin::BI__builtin_elementwise_ldexp: {
3996+
Value *Src = EmitScalarExpr(E->getArg(0));
3997+
Value *Exp = EmitScalarExpr(E->getArg(1));
3998+
Value *Result = Builder.CreateLdexp(Src, Exp, {}, "elt.ldexp");
3999+
return RValue::get(Result);
4000+
}
39954001
case Builtin::BI__builtin_elementwise_log:
39964002
return RValue::get(emitBuiltinWithOneOverloadedType<1>(
39974003
*this, E, Intrinsic::log, "elt.log"));

clang/lib/Sema/SemaChecking.cpp

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,18 @@ static ExprResult BuiltinInvoke(Sema &S, CallExpr *TheCall) {
26092609
Args.drop_front(), TheCall->getRParenLoc());
26102610
}
26112611

2612+
// Performs a similar job to Sema::UsualUnaryConversions, but without any
2613+
// implicit promotion of integral/enumeration types.
2614+
static ExprResult BuiltinVectorMathConversions(Sema &S, Expr *E) {
2615+
// First, convert to an r-value.
2616+
ExprResult Res = S.DefaultFunctionArrayLvalueConversion(E);
2617+
if (Res.isInvalid())
2618+
return ExprError();
2619+
2620+
// Promote floating-point types.
2621+
return S.UsualUnaryFPConversions(Res.get());
2622+
}
2623+
26122624
ExprResult
26132625
Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
26142626
CallExpr *TheCall) {
@@ -3273,6 +3285,46 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
32733285
return ExprError();
32743286
break;
32753287

3288+
case Builtin::BI__builtin_elementwise_ldexp: {
3289+
if (checkArgCount(TheCall, 2))
3290+
return ExprError();
3291+
3292+
ExprResult A = BuiltinVectorMathConversions(*this, TheCall->getArg(0));
3293+
if (A.isInvalid())
3294+
return ExprError();
3295+
QualType TyA = A.get()->getType();
3296+
if (checkMathBuiltinElementType(*this, A.get()->getBeginLoc(), TyA,
3297+
EltwiseBuiltinArgTyRestriction::FloatTy, 1))
3298+
return ExprError();
3299+
3300+
ExprResult Exp = UsualUnaryConversions(TheCall->getArg(1));
3301+
if (Exp.isInvalid())
3302+
return ExprError();
3303+
QualType TyExp = Exp.get()->getType();
3304+
if (checkMathBuiltinElementType(*this, Exp.get()->getBeginLoc(), TyExp,
3305+
EltwiseBuiltinArgTyRestriction::IntegerTy,
3306+
2))
3307+
return ExprError();
3308+
3309+
// Check the two arguments are either scalars or vectors of equal length.
3310+
const auto *Vec0 = TyA->getAs<VectorType>();
3311+
const auto *Vec1 = TyExp->getAs<VectorType>();
3312+
unsigned Arg0Length = Vec0 ? Vec0->getNumElements() : 0;
3313+
unsigned Arg1Length = Vec1 ? Vec1->getNumElements() : 0;
3314+
if (Arg0Length != Arg1Length) {
3315+
Diag(Exp.get()->getBeginLoc(),
3316+
diag::err_typecheck_vector_lengths_not_equal)
3317+
<< TyA << TyExp << A.get()->getSourceRange()
3318+
<< Exp.get()->getSourceRange();
3319+
return ExprError();
3320+
}
3321+
3322+
TheCall->setArg(0, A.get());
3323+
TheCall->setArg(1, Exp.get());
3324+
TheCall->setType(TyA);
3325+
break;
3326+
}
3327+
32763328
// These builtins restrict the element type to floating point
32773329
// types only, and take in two arguments.
32783330
case Builtin::BI__builtin_elementwise_minnum:
@@ -15992,18 +16044,6 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) {
1599216044
_2, _3, _4));
1599316045
}
1599416046

15995-
// Performs a similar job to Sema::UsualUnaryConversions, but without any
15996-
// implicit promotion of integral/enumeration types.
15997-
static ExprResult BuiltinVectorMathConversions(Sema &S, Expr *E) {
15998-
// First, convert to an r-value.
15999-
ExprResult Res = S.DefaultFunctionArrayLvalueConversion(E);
16000-
if (Res.isInvalid())
16001-
return ExprError();
16002-
16003-
// Promote floating-point types.
16004-
return S.UsualUnaryFPConversions(Res.get());
16005-
}
16006-
1600716047
bool Sema::PrepareBuiltinElementwiseMathOneArgCall(
1600816048
CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr) {
1600916049
if (checkArgCount(TheCall, 1))

0 commit comments

Comments
 (0)