Skip to content

Commit 26cf8aa

Browse files
committed
Manually merged main:c14e086b2392 into amd-gfx:38e7e0673384
Local branch amd-gfx 38e7e06 Merged main:8b36a19b3fe6 into amd-gfx:f05b7dadd0b5 Remote branch main c14e086 [NFC][RISCV] Add `SiFive` prefix for XSfvfnrclipxfqf description (llvm#71141) Change-Id: Ia9ce29385a261da8979a13c5cf13fca3ab268dde
2 parents 38e7e06 + c14e086 commit 26cf8aa

File tree

475 files changed

+9068
-3172
lines changed

Some content is hidden

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

475 files changed

+9068
-3172
lines changed

bolt/include/bolt/Passes/ReorderFunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ReorderFunctions : public BinaryFunctionPass {
3232
RT_EXEC_COUNT,
3333
RT_HFSORT,
3434
RT_HFSORT_PLUS,
35-
RT_CDS,
35+
RT_CDSORT,
3636
RT_PETTIS_HANSEN,
3737
RT_RANDOM,
3838
RT_USER

bolt/lib/Passes/ReorderFunctions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions(
4242
"use hfsort algorithm"),
4343
clEnumValN(bolt::ReorderFunctions::RT_HFSORT_PLUS, "hfsort+",
4444
"use hfsort+ algorithm"),
45-
clEnumValN(bolt::ReorderFunctions::RT_CDS, "cds",
45+
clEnumValN(bolt::ReorderFunctions::RT_CDSORT, "cdsort",
4646
"use cache-directed sort"),
4747
clEnumValN(bolt::ReorderFunctions::RT_PETTIS_HANSEN,
4848
"pettis-hansen", "use Pettis-Hansen algorithm"),
@@ -322,7 +322,7 @@ void ReorderFunctions::runOnFunctions(BinaryContext &BC) {
322322
case RT_HFSORT_PLUS:
323323
Clusters = hfsortPlus(Cg);
324324
break;
325-
case RT_CDS: {
325+
case RT_CDSORT: {
326326
// It is required that the sum of incoming arc weights is not greater
327327
// than the number of samples for every function. Ensuring the call graph
328328
// obeys the property before running the algorithm.

clang/include/clang/Basic/riscv_sifive_vector.td

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ let SupportOverloading = false in {
104104
}
105105
}
106106

107+
multiclass RVVVFWMACCBuiltinSet<list<list<string>> suffixes_prototypes> {
108+
let OverloadedName = NAME,
109+
Name = NAME,
110+
HasMasked = false,
111+
Log2LMUL = [-2, -1, 0, 1, 2] in
112+
defm NAME : RVVOutOp1Op2BuiltinSet<NAME, "x", suffixes_prototypes>;
113+
}
114+
107115
multiclass RVVVQMACCBuiltinSet<list<list<string>> suffixes_prototypes> {
108116
let OverloadedName = NAME,
109117
Name = NAME,
@@ -112,6 +120,14 @@ multiclass RVVVQMACCBuiltinSet<list<list<string>> suffixes_prototypes> {
112120
defm NAME : RVVOutOp1Op2BuiltinSet<NAME, "i", suffixes_prototypes>;
113121
}
114122

123+
multiclass RVVVFNRCLIPBuiltinSet<string suffix, string prototype, string type_range> {
124+
let Log2LMUL = [-3, -2, -1, 0, 1, 2],
125+
Name = NAME,
126+
IRName = NAME,
127+
MaskedIRName = NAME # "_mask" in
128+
def : RVVConvBuiltin<suffix, prototype, type_range, NAME>;
129+
}
130+
115131
let UnMaskedPolicyScheme = HasPolicyOperand in
116132
let RequiredFeatures = ["Xsfvqmaccdod"] in {
117133
defm sf_vqmaccu_2x8x2 : RVVVQMACCBuiltinSet<[["", "v", "vv(FixedSEW:8)SUv(FixedSEW:8)Uv"]]>;
@@ -127,3 +143,61 @@ let UnMaskedPolicyScheme = HasPolicyOperand in
127143
defm sf_vqmaccus_4x8x4 : RVVVQMACCBuiltinSet<[["", "v", "vv(FixedSEW:8)SUv(FixedSEW:8)v"]]>;
128144
defm sf_vqmaccsu_4x8x4 : RVVVQMACCBuiltinSet<[["", "v", "vv(FixedSEW:8)Sv(FixedSEW:8)Uv"]]>;
129145
}
146+
147+
let UnMaskedPolicyScheme = HasPolicyOperand in
148+
let RequiredFeatures = ["Xsfvfwmaccqqq"] in
149+
defm sf_vfwmacc_4x4x4 : RVVVFWMACCBuiltinSet<[["", "w", "wwSvv"]]>;
150+
151+
let UnMaskedPolicyScheme = HasPassthruOperand, RequiredFeatures = ["Xsfvfnrclipxfqf"] in {
152+
let ManualCodegen = [{
153+
{
154+
// LLVM intrinsic
155+
// Unmasked: (passthru, vector_in, scalar_in, frm, vl)
156+
// Masked: (passthru, vector_in, scalar_in, mask, frm, vl, policy)
157+
158+
SmallVector<llvm::Value*, 7> Operands;
159+
bool HasMaskedOff = !(
160+
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
161+
(!IsMasked && PolicyAttrs & RVV_VTA));
162+
bool HasRoundModeOp = IsMasked ?
163+
(HasMaskedOff ? Ops.size() == 6 : Ops.size() == 5) :
164+
(HasMaskedOff ? Ops.size() == 5 : Ops.size() == 4);
165+
166+
unsigned Offset = IsMasked ?
167+
(HasMaskedOff ? 2 : 1) : (HasMaskedOff ? 1 : 0);
168+
169+
if (!HasMaskedOff)
170+
Operands.push_back(llvm::PoisonValue::get(ResultType));
171+
else
172+
Operands.push_back(Ops[IsMasked ? 1 : 0]);
173+
174+
Operands.push_back(Ops[Offset]); // op0
175+
Operands.push_back(Ops[Offset + 1]); // op1
176+
177+
if (IsMasked)
178+
Operands.push_back(Ops[0]); // mask
179+
180+
if (HasRoundModeOp) {
181+
Operands.push_back(Ops[Offset + 2]); // frm
182+
Operands.push_back(Ops[Offset + 3]); // vl
183+
} else {
184+
Operands.push_back(ConstantInt::get(Ops[Offset + 2]->getType(), 7)); // frm
185+
Operands.push_back(Ops[Offset + 2]); // vl
186+
}
187+
188+
if (IsMasked)
189+
Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
190+
191+
IntrinsicTypes = {ResultType, Ops[Offset]->getType(), Operands.back()->getType()};
192+
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
193+
return Builder.CreateCall(F, Operands, "");
194+
}
195+
}] in {
196+
let HasFRMRoundModeOp = true in {
197+
defm sf_vfnrclip_x_f_qf : RVVVFNRCLIPBuiltinSet<"v", "vFqfu", "c">;
198+
defm sf_vfnrclip_xu_f_qf : RVVVFNRCLIPBuiltinSet<"Uv", "UvFqfu", "c">;
199+
}
200+
defm sf_vfnrclip_x_f_qf : RVVVFNRCLIPBuiltinSet<"v", "vFqf", "c">;
201+
defm sf_vfnrclip_xu_f_qf : RVVVFNRCLIPBuiltinSet<"Uv", "UvFqf", "c">;
202+
}
203+
}

clang/include/clang/Basic/riscv_vector.td

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2588,8 +2588,15 @@ let UnMaskedPolicyScheme = HasPolicyOperand, HasMasked = false in {
25882588
defm vaesz : RVVOutBuiltinSetZvk<HasVV=0>;
25892589
}
25902590

2591-
// zvknha or zvknhb
2591+
// zvknha
25922592
let RequiredFeatures = ["Zvknha"] in {
2593+
defm vsha2ch : RVVOutOp2BuiltinSetVVZvk<"i">;
2594+
defm vsha2cl : RVVOutOp2BuiltinSetVVZvk<"i">;
2595+
defm vsha2ms : RVVOutOp2BuiltinSetVVZvk<"i">;
2596+
}
2597+
2598+
// zvknhb
2599+
let RequiredFeatures = ["Zvknhb"] in {
25932600
defm vsha2ch : RVVOutOp2BuiltinSetVVZvk<"il">;
25942601
defm vsha2cl : RVVOutOp2BuiltinSetVVZvk<"il">;
25952602
defm vsha2ms : RVVOutOp2BuiltinSetVVZvk<"il">;

clang/include/clang/Basic/riscv_vector_common.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
// t: ptrdiff_t, ignores "t"
6767
// u: unsigned long, ignores "t"
6868
// l: long, ignores "t"
69+
// f: float32, ignores "t"
6970
//
7071
// So for instance if t is "i", i.e. int, then "e" will yield int again. "v"
7172
// will yield an RVV vector type (assume LMUL=1), so __rvv_int32m1_t.

clang/include/clang/Driver/Options.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,6 +2947,14 @@ def fno_modules_validate_textual_header_includes :
29472947
MarshallingInfoNegativeFlag<LangOpts<"ModulesValidateTextualHeaderIncludes">>,
29482948
HelpText<"Do not enforce -fmodules-decluse and private header restrictions for textual headers. "
29492949
"This flag will be removed in a future Clang release.">;
2950+
defm modules_skip_diagnostic_options : BoolFOption<"modules-skip-diagnostic-options",
2951+
HeaderSearchOpts<"ModulesSkipDiagnosticOptions">, DefaultFalse,
2952+
PosFlag<SetTrue, [], [], "Disable writing diagnostic options">,
2953+
NegFlag<SetFalse>, BothFlags<[], [CC1Option]>>;
2954+
defm modules_skip_header_search_paths : BoolFOption<"modules-skip-header-search-paths",
2955+
HeaderSearchOpts<"ModulesSkipHeaderSearchPaths">, DefaultFalse,
2956+
PosFlag<SetTrue, [], [], "Disable writing header search paths">,
2957+
NegFlag<SetFalse>, BothFlags<[], [CC1Option]>>;
29502958

29512959
def fincremental_extensions :
29522960
Flag<["-"], "fincremental-extensions">,

clang/include/clang/Lex/HeaderSearchOptions.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ class HeaderSearchOptions {
219219

220220
unsigned ModulesValidateDiagnosticOptions : 1;
221221

222+
/// Whether to entirely skip writing diagnostic options.
223+
/// Primarily used to speed up deserialization during dependency scanning.
224+
unsigned ModulesSkipDiagnosticOptions : 1;
225+
226+
/// Whether to entirely skip writing header search paths.
227+
/// Primarily used to speed up deserialization during dependency scanning.
228+
unsigned ModulesSkipHeaderSearchPaths : 1;
229+
222230
unsigned ModulesHashContent : 1;
223231

224232
/// Whether we should include all things that could impact the module in the
@@ -238,7 +246,9 @@ class HeaderSearchOptions {
238246
ModulesValidateSystemHeaders(false),
239247
ValidateASTInputFilesContent(false),
240248
ForceCheckCXX20ModulesInputFiles(false), UseDebugInfo(false),
241-
ModulesValidateDiagnosticOptions(true), ModulesHashContent(false),
249+
ModulesValidateDiagnosticOptions(true),
250+
ModulesSkipDiagnosticOptions(false),
251+
ModulesSkipHeaderSearchPaths(false), ModulesHashContent(false),
242252
ModulesStrictContextHash(false) {}
243253

244254
/// AddPath - Add the \p Path path to the specified \p Group list.

clang/include/clang/Support/RISCVVIntrinsicUtils.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ enum class BaseTypeModifier : uint8_t {
8585
Ptrdiff,
8686
UnsignedLong,
8787
SignedLong,
88+
Float32
8889
};
8990

9091
// Modifier for type, used for both scalar and vector types.
@@ -485,16 +486,19 @@ enum RVVRequire : uint16_t {
485486
RVV_REQ_RV64 = 1 << 0,
486487
RVV_REQ_ZvfhminOrZvfh = 1 << 1,
487488
RVV_REQ_Xsfvcp = 1 << 2,
488-
RVV_REQ_Xsfvqmaccdod = 1 << 3,
489-
RVV_REQ_Xsfvqmaccqoq = 1 << 4,
490-
RVV_REQ_Zvbb = 1 << 5,
491-
RVV_REQ_Zvbc = 1 << 6,
492-
RVV_REQ_Zvkb = 1 << 7,
493-
RVV_REQ_Zvkg = 1 << 8,
494-
RVV_REQ_Zvkned = 1 << 9,
495-
RVV_REQ_Zvknha = 1 << 10,
496-
RVV_REQ_Zvksed = 1 << 11,
497-
RVV_REQ_Zvksh = 1 << 12,
489+
RVV_REQ_Xsfvfnrclipxfqf = 1 << 3,
490+
RVV_REQ_Xsfvfwmaccqqq = 1 << 4,
491+
RVV_REQ_Xsfvqmaccdod = 1 << 5,
492+
RVV_REQ_Xsfvqmaccqoq = 1 << 6,
493+
RVV_REQ_Zvbb = 1 << 7,
494+
RVV_REQ_Zvbc = 1 << 8,
495+
RVV_REQ_Zvkb = 1 << 9,
496+
RVV_REQ_Zvkg = 1 << 10,
497+
RVV_REQ_Zvkned = 1 << 11,
498+
RVV_REQ_Zvknha = 1 << 12,
499+
RVV_REQ_Zvknhb = 1 << 13,
500+
RVV_REQ_Zvksed = 1 << 14,
501+
RVV_REQ_Zvksh = 1 << 15,
498502

499503
LLVM_MARK_AS_BITMASK_ENUM(RVV_REQ_Zvksh)
500504
};

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,7 @@ EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *M) {
450450
Address Object = createReferenceTemporary(*this, M, E);
451451
if (auto *Var = dyn_cast<llvm::GlobalVariable>(Object.getPointer())) {
452452
llvm::Type *Ty = ConvertTypeForMem(E->getType());
453-
Object = Address(llvm::ConstantExpr::getBitCast(
454-
Var, Ty->getPointerTo(Object.getAddressSpace())),
455-
Ty, Object.getAlignment());
453+
Object = Object.withElementType(Ty);
456454

457455
// createReferenceTemporary will promote the temporary to a global with a
458456
// constant initializer if it can. It can only do this to a value of
@@ -508,11 +506,7 @@ EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *M) {
508506
if (auto *Var = dyn_cast<llvm::GlobalVariable>(
509507
Object.getPointer()->stripPointerCasts())) {
510508
llvm::Type *TemporaryType = ConvertTypeForMem(E->getType());
511-
Object = Address(llvm::ConstantExpr::getBitCast(
512-
cast<llvm::Constant>(Object.getPointer()),
513-
TemporaryType->getPointerTo()),
514-
TemporaryType,
515-
Object.getAlignment());
509+
Object = Object.withElementType(TemporaryType);
516510
// If the temporary is a global and has a constant initializer or is a
517511
// constant temporary that we promoted to a global, we may have already
518512
// initialized it.
@@ -2678,19 +2672,6 @@ static llvm::Constant *EmitFunctionDeclPointer(CodeGenModule &CGM,
26782672
}
26792673

26802674
llvm::Constant *V = CGM.GetAddrOfFunction(GD);
2681-
if (!FD->hasPrototype()) {
2682-
if (const FunctionProtoType *Proto =
2683-
FD->getType()->getAs<FunctionProtoType>()) {
2684-
// Ugly case: for a K&R-style definition, the type of the definition
2685-
// isn't the same as the type of a use. Correct for this with a
2686-
// bitcast.
2687-
QualType NoProtoType =
2688-
CGM.getContext().getFunctionNoProtoType(Proto->getReturnType());
2689-
NoProtoType = CGM.getContext().getPointerType(NoProtoType);
2690-
V = llvm::ConstantExpr::getBitCast(V,
2691-
CGM.getTypes().ConvertType(NoProtoType));
2692-
}
2693-
}
26942675
return V;
26952676
}
26962677

clang/lib/Driver/ToolChains/Solaris.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
215215

216216
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
217217
options::OPT_r)) {
218+
// Use the static OpenMP runtime with -static-openmp
219+
bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
220+
!Args.hasArg(options::OPT_static);
221+
addOpenMPRuntime(CmdArgs, getToolChain(), Args, StaticOpenMP);
222+
218223
if (D.CCCIsCXX()) {
219224
if (getToolChain().ShouldLinkCXXStdlib(Args))
220225
getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);

clang/lib/Driver/ToolChains/WebAssembly.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,25 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
141141
CmdArgs.push_back("-o");
142142
CmdArgs.push_back(Output.getFilename());
143143

144+
// When optimizing, if wasm-opt is available, run it.
145+
std::string WasmOptPath;
146+
if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
147+
WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
148+
if (WasmOptPath == "wasm-opt") {
149+
WasmOptPath = {};
150+
}
151+
}
152+
153+
if (!WasmOptPath.empty()) {
154+
CmdArgs.push_back("--keep-section=target_features");
155+
}
156+
144157
C.addCommand(std::make_unique<Command>(JA, *this,
145158
ResponseFileSupport::AtFileCurCP(),
146159
Linker, CmdArgs, Inputs, Output));
147160

148-
// When optimizing, if wasm-opt is available, run it.
149161
if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
150-
auto WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
151-
if (WasmOptPath != "wasm-opt") {
162+
if (!WasmOptPath.empty()) {
152163
StringRef OOpt = "s";
153164
if (A->getOption().matches(options::OPT_O4) ||
154165
A->getOption().matches(options::OPT_Ofast))
@@ -160,13 +171,13 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
160171

161172
if (OOpt != "0") {
162173
const char *WasmOpt = Args.MakeArgString(WasmOptPath);
163-
ArgStringList CmdArgs;
164-
CmdArgs.push_back(Output.getFilename());
165-
CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
166-
CmdArgs.push_back("-o");
167-
CmdArgs.push_back(Output.getFilename());
174+
ArgStringList OptArgs;
175+
OptArgs.push_back(Output.getFilename());
176+
OptArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
177+
OptArgs.push_back("-o");
178+
OptArgs.push_back(Output.getFilename());
168179
C.addCommand(std::make_unique<Command>(
169-
JA, *this, ResponseFileSupport::AtFileCurCP(), WasmOpt, CmdArgs,
180+
JA, *this, ResponseFileSupport::AtFileCurCP(), WasmOpt, OptArgs,
170181
Inputs, Output));
171182
}
172183
}

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,18 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
491491
SmallVector<StackEntry, 8> LBraceStack;
492492
assert(Tok->is(tok::l_brace));
493493
do {
494-
// Get next non-comment token.
494+
// Get next non-comment, non-preprocessor token.
495495
FormatToken *NextTok;
496496
do {
497497
NextTok = Tokens->getNextToken();
498498
} while (NextTok->is(tok::comment));
499+
while (NextTok->is(tok::hash)) {
500+
NextTok = Tokens->getNextToken();
501+
do {
502+
NextTok = Tokens->getNextToken();
503+
} while (NextTok->is(tok::comment) ||
504+
(NextTok->NewlinesBefore == 0 && NextTok->isNot(tok::eof)));
505+
}
499506

500507
switch (Tok->Tok.getKind()) {
501508
case tok::l_brace:
@@ -611,12 +618,9 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
611618
if (Tok->isNot(TT_StatementMacro))
612619
break;
613620
[[fallthrough]];
614-
case tok::kw_if:
615-
if (PrevTok->is(tok::hash))
616-
break;
617-
[[fallthrough]];
618621
case tok::at:
619622
case tok::semi:
623+
case tok::kw_if:
620624
case tok::kw_while:
621625
case tok::kw_for:
622626
case tok::kw_switch:
@@ -3117,9 +3121,16 @@ void UnwrappedLineParser::parseForOrWhileLoop(bool HasParens) {
31173121
FormatTok->setFinalizedType(TT_ConditionLParen);
31183122
parseParens();
31193123
}
3120-
// Event control.
3121-
if (Style.isVerilog())
3124+
3125+
if (Style.isVerilog()) {
3126+
// Event control.
31223127
parseVerilogSensitivityList();
3128+
} else if (Style.AllowShortLoopsOnASingleLine && FormatTok->is(tok::semi) &&
3129+
Tokens->getPreviousToken()->is(tok::r_paren)) {
3130+
nextToken();
3131+
addUnwrappedLine();
3132+
return;
3133+
}
31233134

31243135
handleAttributes();
31253136
parseLoopBody(KeepBraces, /*WrapRightBrace=*/true);

0 commit comments

Comments
 (0)