Skip to content

Commit 0cc1088

Browse files
committed
merge main into amd-staging
2 parents 7507463 + 1695e8b commit 0cc1088

File tree

237 files changed

+6455
-3258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+6455
-3258
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,13 @@ template <typename T>
525525
static void populateInfo(Info &I, const T *D, const FullComment *C,
526526
bool &IsInAnonymousNamespace) {
527527
I.USR = getUSRForDecl(D);
528-
I.Name = D->getNameAsString();
528+
if (auto ConversionDecl = dyn_cast_or_null<CXXConversionDecl>(D);
529+
ConversionDecl && ConversionDecl->getConversionType()
530+
.getTypePtr()
531+
->isTemplateTypeParmType())
532+
I.Name = "operator " + ConversionDecl->getConversionType().getAsString();
533+
else
534+
I.Name = D->getNameAsString();
529535
populateParentNamespaces(I.Namespace, D, IsInAnonymousNamespace);
530536
if (C) {
531537
I.Description.emplace_back();

clang-tools-extra/test/clang-doc/conversion_function.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ struct MyStruct {
1111
operator T();
1212
};
1313

14-
// Output incorrect conversion names.
15-
// CHECK-YAML: Name: 'operator type-parameter-0-0'
16-
// CHECK-YAML-NOT: Name: 'operator T'
14+
// Output correct conversion names.
15+
// CHECK-YAML: Name: 'operator T'
1716

18-
// CHECK-HTML-NOT: <h3 id='{{[0-9A-F]*}}'>operator T</h3>
19-
// CHECK-HTML-NOT: <p>public T operator T()</p>
17+
// CHECK-HTML: <h3 id='{{[0-9A-F]*}}'>operator T</h3>
18+
// CHECK-HTML: <p>public T operator T()</p>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ TEST(HTMLMustacheGeneratorTest, generateDocs) {
9191
unittest::TempDir RootTestDirectory("generateDocsTest", /*Unique=*/true);
9292
CDCtx.OutDirectory = RootTestDirectory.path();
9393

94-
getMustacheHtmlFiles(CLANG_DOC_TEST_ASSET_DIR, CDCtx);
94+
// FIXME: We can't read files during unit tests. Migrate to lit once
95+
// tool support lands.
96+
// getMustacheHtmlFiles(CLANG_DOC_TEST_ASSET_DIR, CDCtx);
9597

9698
EXPECT_THAT_ERROR(G->generateDocs(RootTestDirectory.path(), {}, CDCtx),
97-
Succeeded())
99+
Failed())
98100
<< "Failed to generate docs.";
99101
}
100102

clang/cmake/modules/AddClang.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ macro(add_clang_tool name)
186186
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
187187
COMPONENT ${name})
188188

189+
if (LLVM_ENABLE_PDB)
190+
install(FILES $<TARGET_PDB_FILE:${name}> DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name} OPTIONAL)
191+
endif()
192+
189193
if(NOT LLVM_ENABLE_IDE)
190194
add_llvm_install_targets(install-${name}
191195
DEPENDS ${name}

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,4 +2105,33 @@ def VecExtractOp : CIR_Op<"vec.extract", [Pure,
21052105
let hasFolder = 1;
21062106
}
21072107

2108+
//===----------------------------------------------------------------------===//
2109+
// VecCmpOp
2110+
//===----------------------------------------------------------------------===//
2111+
2112+
def VecCmpOp : CIR_Op<"vec.cmp", [Pure, SameTypeOperands]> {
2113+
2114+
let summary = "Compare two vectors";
2115+
let description = [{
2116+
The `cir.vec.cmp` operation does an element-wise comparison of two vectors
2117+
of the same type. The result is a vector of the same size as the operands
2118+
whose element type is the signed integral type that is the same size as the
2119+
element type of the operands. The values in the result are 0 or -1.
2120+
2121+
```mlir
2122+
%eq = cir.vec.cmp(eq, %vec_a, %vec_b) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>
2123+
%lt = cir.vec.cmp(lt, %vec_a, %vec_b) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>
2124+
```
2125+
}];
2126+
2127+
let arguments = (ins Arg<CmpOpKind, "cmp kind">:$kind, CIR_VectorType:$lhs,
2128+
CIR_VectorType:$rhs);
2129+
let results = (outs CIR_VectorType:$result);
2130+
2131+
let assemblyFormat = [{
2132+
`(` $kind `,` $lhs `,` $rhs `)` `:` qualified(type($lhs)) `,`
2133+
qualified(type($result)) attr-dict
2134+
}];
2135+
}
2136+
21082137
#endif // CLANG_CIR_DIALECT_IR_CIROPS_TD

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class RootSignatureParser {
9393
std::optional<llvm::hlsl::rootsig::Register> Reg;
9494
std::optional<uint32_t> Space;
9595
std::optional<llvm::hlsl::rootsig::ShaderVisibility> Visibility;
96+
std::optional<llvm::hlsl::rootsig::RootDescriptorFlags> Flags;
9697
};
9798
std::optional<ParsedRootDescriptorParams>
9899
parseRootDescriptorParams(RootSignatureToken::Kind RegType);
@@ -113,6 +114,8 @@ class RootSignatureParser {
113114

114115
/// Parsing methods of various enums
115116
std::optional<llvm::hlsl::rootsig::ShaderVisibility> parseShaderVisibility();
117+
std::optional<llvm::hlsl::rootsig::RootDescriptorFlags>
118+
parseRootDescriptorFlags();
116119
std::optional<llvm::hlsl::rootsig::DescriptorRangeFlags>
117120
parseDescriptorRangeFlags();
118121

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,22 +786,30 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
786786
}
787787
};
788788

789+
cir::CmpOpKind kind = clangCmpToCIRCmp(e->getOpcode());
789790
if (lhsTy->getAs<MemberPointerType>()) {
790791
assert(!cir::MissingFeatures::dataMemberType());
791792
assert(e->getOpcode() == BO_EQ || e->getOpcode() == BO_NE);
792793
mlir::Value lhs = cgf.emitScalarExpr(e->getLHS());
793794
mlir::Value rhs = cgf.emitScalarExpr(e->getRHS());
794-
cir::CmpOpKind kind = clangCmpToCIRCmp(e->getOpcode());
795795
result = builder.createCompare(loc, kind, lhs, rhs);
796796
} else if (!lhsTy->isAnyComplexType() && !rhsTy->isAnyComplexType()) {
797797
BinOpInfo boInfo = emitBinOps(e);
798798
mlir::Value lhs = boInfo.lhs;
799799
mlir::Value rhs = boInfo.rhs;
800800

801801
if (lhsTy->isVectorType()) {
802-
assert(!cir::MissingFeatures::vectorType());
803-
cgf.cgm.errorNYI(loc, "vector comparisons");
804-
result = builder.getBool(false, loc);
802+
if (!e->getType()->isVectorType()) {
803+
// If AltiVec, the comparison results in a numeric type, so we use
804+
// intrinsics comparing vectors and giving 0 or 1 as a result
805+
cgf.cgm.errorNYI(loc, "AltiVec comparison");
806+
} else {
807+
// Other kinds of vectors. Element-wise comparison returning
808+
// a vector.
809+
result = builder.create<cir::VecCmpOp>(
810+
cgf.getLoc(boInfo.loc), cgf.convertType(boInfo.fullType), kind,
811+
boInfo.lhs, boInfo.rhs);
812+
}
805813
} else if (boInfo.isFixedPointOp()) {
806814
assert(!cir::MissingFeatures::fixedPointType());
807815
cgf.cgm.errorNYI(loc, "fixed point comparisons");

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,8 @@ void ConvertCIRToLLVMPass::runOnOperation() {
17161716
CIRToLLVMUnaryOpLowering,
17171717
CIRToLLVMVecCreateOpLowering,
17181718
CIRToLLVMVecExtractOpLowering,
1719-
CIRToLLVMVecInsertOpLowering
1719+
CIRToLLVMVecInsertOpLowering,
1720+
CIRToLLVMVecCmpOpLowering
17201721
// clang-format on
17211722
>(converter, patterns.getContext());
17221723

@@ -1841,6 +1842,35 @@ mlir::LogicalResult CIRToLLVMVecInsertOpLowering::matchAndRewrite(
18411842
return mlir::success();
18421843
}
18431844

1845+
mlir::LogicalResult CIRToLLVMVecCmpOpLowering::matchAndRewrite(
1846+
cir::VecCmpOp op, OpAdaptor adaptor,
1847+
mlir::ConversionPatternRewriter &rewriter) const {
1848+
assert(mlir::isa<cir::VectorType>(op.getType()) &&
1849+
mlir::isa<cir::VectorType>(op.getLhs().getType()) &&
1850+
mlir::isa<cir::VectorType>(op.getRhs().getType()) &&
1851+
"Vector compare with non-vector type");
1852+
mlir::Type elementType = elementTypeIfVector(op.getLhs().getType());
1853+
mlir::Value bitResult;
1854+
if (auto intType = mlir::dyn_cast<cir::IntType>(elementType)) {
1855+
bitResult = rewriter.create<mlir::LLVM::ICmpOp>(
1856+
op.getLoc(),
1857+
convertCmpKindToICmpPredicate(op.getKind(), intType.isSigned()),
1858+
adaptor.getLhs(), adaptor.getRhs());
1859+
} else if (mlir::isa<cir::CIRFPTypeInterface>(elementType)) {
1860+
bitResult = rewriter.create<mlir::LLVM::FCmpOp>(
1861+
op.getLoc(), convertCmpKindToFCmpPredicate(op.getKind()),
1862+
adaptor.getLhs(), adaptor.getRhs());
1863+
} else {
1864+
return op.emitError() << "unsupported type for VecCmpOp: " << elementType;
1865+
}
1866+
1867+
// LLVM IR vector comparison returns a vector of i1. This one-bit vector
1868+
// must be sign-extended to the correct result type.
1869+
rewriter.replaceOpWithNewOp<mlir::LLVM::SExtOp>(
1870+
op, typeConverter->convertType(op.getType()), bitResult);
1871+
return mlir::success();
1872+
}
1873+
18441874
std::unique_ptr<mlir::Pass> createConvertCIRToLLVMPass() {
18451875
return std::make_unique<ConvertCIRToLLVMPass>();
18461876
}

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,16 @@ class CIRToLLVMVecInsertOpLowering
342342
mlir::ConversionPatternRewriter &) const override;
343343
};
344344

345+
class CIRToLLVMVecCmpOpLowering
346+
: public mlir::OpConversionPattern<cir::VecCmpOp> {
347+
public:
348+
using mlir::OpConversionPattern<cir::VecCmpOp>::OpConversionPattern;
349+
350+
mlir::LogicalResult
351+
matchAndRewrite(cir::VecCmpOp op, OpAdaptor,
352+
mlir::ConversionPatternRewriter &) const override;
353+
};
354+
345355
} // namespace direct
346356
} // namespace cir
347357

clang/lib/Format/FormatTokenLexer.cpp

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,15 @@ ArrayRef<FormatToken *> FormatTokenLexer::lex() {
123123
if (Style.isJavaScript()) {
124124
tryParseJSRegexLiteral();
125125
handleTemplateStrings();
126-
}
127-
if (Style.isTextProto())
126+
} else if (Style.isTextProto()) {
128127
tryParsePythonComment();
128+
}
129129
tryMergePreviousTokens();
130130
if (Style.isCSharp()) {
131131
// This needs to come after tokens have been merged so that C#
132132
// string literals are correctly identified.
133133
handleCSharpVerbatimAndInterpolatedStrings();
134-
}
135-
if (Style.isTableGen()) {
134+
} else if (Style.isTableGen()) {
136135
handleTableGenMultilineString();
137136
handleTableGenNumericLikeIdentifier();
138137
}
@@ -190,23 +189,23 @@ void FormatTokenLexer::tryMergePreviousTokens() {
190189
}
191190
if (tryMergeNullishCoalescingEqual())
192191
return;
193-
}
194-
195-
if (Style.isCSharp()) {
196-
static const tok::TokenKind CSharpNullConditionalLSquare[] = {
197-
tok::question, tok::l_square};
198192

199-
if (tryMergeCSharpKeywordVariables())
200-
return;
201-
if (tryMergeCSharpStringLiteral())
202-
return;
203-
if (tryTransformCSharpForEach())
204-
return;
205-
if (tryMergeTokens(CSharpNullConditionalLSquare,
206-
TT_CSharpNullConditionalLSquare)) {
207-
// Treat like a regular "[" operator.
208-
Tokens.back()->Tok.setKind(tok::l_square);
209-
return;
193+
if (Style.isCSharp()) {
194+
static const tok::TokenKind CSharpNullConditionalLSquare[] = {
195+
tok::question, tok::l_square};
196+
197+
if (tryMergeCSharpKeywordVariables())
198+
return;
199+
if (tryMergeCSharpStringLiteral())
200+
return;
201+
if (tryTransformCSharpForEach())
202+
return;
203+
if (tryMergeTokens(CSharpNullConditionalLSquare,
204+
TT_CSharpNullConditionalLSquare)) {
205+
// Treat like a regular "[" operator.
206+
Tokens.back()->Tok.setKind(tok::l_square);
207+
return;
208+
}
210209
}
211210
}
212211

@@ -246,16 +245,12 @@ void FormatTokenLexer::tryMergePreviousTokens() {
246245
}
247246
if (tryMergeJSPrivateIdentifier())
248247
return;
249-
}
250-
251-
if (Style.isJava()) {
248+
} else if (Style.isJava()) {
252249
static const tok::TokenKind JavaRightLogicalShiftAssign[] = {
253250
tok::greater, tok::greater, tok::greaterequal};
254251
if (tryMergeTokens(JavaRightLogicalShiftAssign, TT_BinaryOperator))
255252
return;
256-
}
257-
258-
if (Style.isVerilog()) {
253+
} else if (Style.isVerilog()) {
259254
// Merge the number following a base like `'h?a0`.
260255
if (Tokens.size() >= 3 && Tokens.end()[-3]->is(TT_VerilogNumberBase) &&
261256
Tokens.end()[-2]->is(tok::numeric_constant) &&
@@ -327,8 +322,7 @@ void FormatTokenLexer::tryMergePreviousTokens() {
327322
Tokens.back()->ForcedPrecedence = prec::Comma;
328323
return;
329324
}
330-
}
331-
if (Style.isTableGen()) {
325+
} else if (Style.isTableGen()) {
332326
// TableGen's Multi line string starts with [{
333327
if (tryMergeTokens({tok::l_square, tok::l_brace},
334328
TT_TableGenMultiLineString)) {
@@ -843,10 +837,7 @@ void FormatTokenLexer::handleCSharpVerbatimAndInterpolatedStrings() {
843837

844838
const char *StrBegin = Lex->getBufferLocation() - TokenText.size();
845839
const char *Offset = StrBegin;
846-
if (Verbatim && Interpolated)
847-
Offset += 3;
848-
else
849-
Offset += 2;
840+
Offset += Verbatim && Interpolated ? 3 : 2;
850841

851842
const auto End = Lex->getBuffer().end();
852843
Offset = lexCSharpString(Offset, End, Verbatim, Interpolated);
@@ -1377,13 +1368,9 @@ FormatToken *FormatTokenLexer::getNextToken() {
13771368
} else if (Style.isTableGen() && !Keywords.isTableGenKeyword(*FormatTok)) {
13781369
FormatTok->Tok.setKind(tok::identifier);
13791370
}
1380-
} else if (FormatTok->is(tok::greatergreater)) {
1381-
FormatTok->Tok.setKind(tok::greater);
1382-
FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
1383-
++Column;
1384-
StateStack.push(LexerState::TOKEN_STASHED);
1385-
} else if (FormatTok->is(tok::lessless)) {
1386-
FormatTok->Tok.setKind(tok::less);
1371+
} else if (const bool Greater = FormatTok->is(tok::greatergreater);
1372+
Greater || FormatTok->is(tok::lessless)) {
1373+
FormatTok->Tok.setKind(Greater ? tok::greater : tok::less);
13871374
FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
13881375
++Column;
13891376
StateStack.push(LexerState::TOKEN_STASHED);

0 commit comments

Comments
 (0)