Skip to content

Commit 4119b43

Browse files
authored
merge main into amd-staging (#459)
2 parents 1ab2948 + 023140b commit 4119b43

File tree

287 files changed

+4360
-1419
lines changed

Some content is hidden

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

287 files changed

+4360
-1419
lines changed

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ LANGOPT(OpenCLPipes , 1, 0, NotCompatible, "OpenCL pipes language c
217217
LANGOPT(NativeHalfType , 1, 0, NotCompatible, "Native half type support")
218218
LANGOPT(NativeHalfArgsAndReturns, 1, 0, NotCompatible, "Native half args and returns")
219219
LANGOPT(HalfArgsAndReturns, 1, 0, NotCompatible, "half args and returns")
220+
LANGOPT(NativeInt16Type , 1, 1, NotCompatible, "Native int 16 type support")
220221
LANGOPT(CUDA , 1, 0, NotCompatible, "CUDA")
221222
LANGOPT(HIP , 1, 0, NotCompatible, "HIP")
222223
LANGOPT(OpenMP , 32, 0, NotCompatible, "OpenMP support and version of OpenMP (31, 40 or 45)")

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8804,6 +8804,11 @@ def fobjc_subscripting_legacy_runtime : Flag<["-"], "fobjc-subscripting-legacy-r
88048804
def vtordisp_mode_EQ : Joined<["-"], "vtordisp-mode=">,
88058805
HelpText<"Control vtordisp placement on win32 targets">,
88068806
MarshallingInfoInt<LangOpts<"VtorDispMode">, "1">;
8807+
def fnative_int16_type : Flag<["-"], "fnative-int16-type">,
8808+
HelpText<"Use 16 bit integer types">,
8809+
// This option is implied unless we are in HLSL lang mode
8810+
ImpliedByAnyOf<[!strconcat("!", hlsl.KeyPath)]>,
8811+
MarshallingInfoFlag<LangOpts<"NativeInt16Type">>;
88078812
def fnative_half_type: Flag<["-"], "fnative-half-type">,
88088813
HelpText<"Use the native half type for __fp16 instead of promoting to float">,
88098814
MarshallingInfoFlag<LangOpts<"NativeHalfType">>,
@@ -9811,7 +9816,7 @@ def emit_pristine_llvm : DXCFlag<"emit-pristine-llvm">,
98119816
HelpText<"Emit pristine LLVM IR from the frontend by not running any LLVM passes at all."
98129817
"Same as -S + -emit-llvm + -disable-llvm-passes.">;
98139818
def fcgl : DXCFlag<"fcgl">, Alias<emit_pristine_llvm>;
9814-
def enable_16bit_types : DXCFlag<"enable-16bit-types">, Alias<fnative_half_type>,
9819+
def enable_16bit_types : DXCFlag<"enable-16bit-types">,
98159820
HelpText<"Enable 16-bit types and disable min precision types."
98169821
"Available in HLSL 2018 and shader model 6.2.">;
98179822
def fdx_rootsignature_version :

clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -771,14 +771,6 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
771771
case X86::BI_WriteBarrier:
772772
case X86::BI_AddressOfReturnAddress:
773773
case X86::BI__stosb:
774-
case X86::BI__builtin_ia32_t2rpntlvwz0_internal:
775-
case X86::BI__builtin_ia32_t2rpntlvwz0rs_internal:
776-
case X86::BI__builtin_ia32_t2rpntlvwz0t1_internal:
777-
case X86::BI__builtin_ia32_t2rpntlvwz0rst1_internal:
778-
case X86::BI__builtin_ia32_t2rpntlvwz1_internal:
779-
case X86::BI__builtin_ia32_t2rpntlvwz1rs_internal:
780-
case X86::BI__builtin_ia32_t2rpntlvwz1t1_internal:
781-
case X86::BI__builtin_ia32_t2rpntlvwz1rst1_internal:
782774
case X86::BI__ud2:
783775
case X86::BI__int2c:
784776
case X86::BI__readfsbyte:

clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2635,7 +2635,7 @@ llvm::Value *CGOpenMPRuntimeGPU::getGPUBlockID(CodeGenFunction &CGF) {
26352635
CGBuilderTy &Bld = CGF.Builder;
26362636
llvm::Function *F =
26372637
CGF.CGM.getIntrinsic(llvm::Intrinsic::amdgcn_workgroup_id_x);
2638-
return Bld.CreateCall(F, std::nullopt, "gpu_block_id");
2638+
return Bld.CreateCall(F, {}, "gpu_block_id");
26392639
}
26402640

26412641
llvm::Value *CGOpenMPRuntimeGPU::getGPUNumBlocks(CodeGenFunction &CGF) {

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3752,6 +3752,7 @@ static void RenderHLSLOptions(const ArgList &Args, ArgStringList &CmdArgs,
37523752
options::OPT_emit_obj,
37533753
options::OPT_disable_llvm_passes,
37543754
options::OPT_fnative_half_type,
3755+
options::OPT_fnative_int16_type,
37553756
options::OPT_hlsl_entrypoint,
37563757
options::OPT_fdx_rootsignature_define,
37573758
options::OPT_fdx_rootsignature_version,

clang/lib/Driver/ToolChains/HLSL.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,15 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
498498
continue;
499499
}
500500

501+
if (A->getOption().getID() == options::OPT_enable_16bit_types) {
502+
// Translate -enable-16bit-types into -fnative-half-type and
503+
// -fnative-int16-type
504+
DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_fnative_half_type));
505+
DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_fnative_int16_type));
506+
A->claim();
507+
continue;
508+
}
509+
501510
DAL->append(A);
502511
}
503512

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4729,7 +4729,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
47294729
// Validate that if fnative-half-type is given, that
47304730
// the language standard is at least hlsl2018, and that
47314731
// the target shader model is at least 6.2.
4732-
if (Args.getLastArg(OPT_fnative_half_type)) {
4732+
if (Args.getLastArg(OPT_fnative_half_type) ||
4733+
Args.getLastArg(OPT_fnative_int16_type)) {
47334734
const LangStandard &Std =
47344735
LangStandard::getLangStandardForKind(Opts.LangStd);
47354736
if (!(Opts.LangStd >= LangStandard::lang_hlsl2018 &&
@@ -4743,12 +4744,16 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
47434744
Diags.Report(diag::err_drv_hlsl_bad_shader_unsupported)
47444745
<< VulkanEnv << T.getOSName() << T.str();
47454746
}
4746-
if (Args.getLastArg(OPT_fnative_half_type)) {
4747+
if (Args.getLastArg(OPT_fnative_half_type) ||
4748+
Args.getLastArg(OPT_fnative_int16_type)) {
4749+
const char *Str = Args.getLastArg(OPT_fnative_half_type)
4750+
? "-fnative-half-type"
4751+
: "-fnative-int16-type";
47474752
const LangStandard &Std =
47484753
LangStandard::getLangStandardForKind(Opts.LangStd);
47494754
if (!(Opts.LangStd >= LangStandard::lang_hlsl2018))
47504755
Diags.Report(diag::err_drv_hlsl_16bit_types_unsupported)
4751-
<< "-fnative-half-type" << false << Std.getName();
4756+
<< Str << false << Std.getName();
47524757
}
47534758
} else {
47544759
llvm_unreachable("expected DXIL or SPIR-V target");

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
399399
Builder.defineMacro("__HLSL_202y",
400400
Twine((unsigned)LangOptions::HLSLLangStd::HLSL_202y));
401401

402-
if (LangOpts.NativeHalfType)
402+
if (LangOpts.NativeHalfType && LangOpts.NativeInt16Type)
403403
Builder.defineMacro("__HLSL_ENABLE_16_BIT", "1");
404404

405405
// Shader target information

clang/lib/Parse/ParseDecl.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4248,6 +4248,13 @@ void Parser::ParseDeclarationSpecifiers(
42484248

42494249
// type-specifier
42504250
case tok::kw_short:
4251+
if (!getLangOpts().NativeInt16Type) {
4252+
Diag(Tok, diag::err_unknown_typename) << Tok.getName();
4253+
DS.SetTypeSpecError();
4254+
DS.SetRangeEnd(Tok.getLocation());
4255+
ConsumeToken();
4256+
goto DoneWithDeclSpec;
4257+
}
42514258
isInvalid = DS.SetTypeSpecWidth(TypeSpecifierWidth::Short, Loc, PrevSpec,
42524259
DiagID, Policy);
42534260
break;

clang/lib/Sema/SemaCodeComplete.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10208,6 +10208,24 @@ void SemaCodeCompletion::CodeCompletePreprocessorDirective(bool InConditional) {
1020810208
Builder.AddPlaceholderChunk("message");
1020910209
Results.AddResult(Builder.TakeString());
1021010210

10211+
if (getLangOpts().C23) {
10212+
// #embed "file"
10213+
Builder.AddTypedTextChunk("embed");
10214+
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
10215+
Builder.AddTextChunk("\"");
10216+
Builder.AddPlaceholderChunk("file");
10217+
Builder.AddTextChunk("\"");
10218+
Results.AddResult(Builder.TakeString());
10219+
10220+
// #embed <file>
10221+
Builder.AddTypedTextChunk("embed");
10222+
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
10223+
Builder.AddTextChunk("<");
10224+
Builder.AddPlaceholderChunk("file");
10225+
Builder.AddTextChunk(">");
10226+
Results.AddResult(Builder.TakeString());
10227+
}
10228+
1021110229
// Note: #ident and #sccs are such crazy anachronisms that we don't provide
1021210230
// completions for them. And __include_macros is a Clang-internal extension
1021310231
// that we don't want to encourage anyone to use.

0 commit comments

Comments
 (0)