Skip to content

Commit adb6469

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into zcfs
2 parents 246ff38 + 45083dc commit adb6469

File tree

569 files changed

+56199
-48465
lines changed

Some content is hidden

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

569 files changed

+56199
-48465
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,9 @@ Improvements to Clang's diagnostics
661661
diagnostics when floating-point numbers had both width field and plus or space
662662
prefix specified. (#GH143951)
663663

664+
- A warning is now emitted when ``main`` is attached to a named module,
665+
which can be turned off with ``-Wno-main-attached-to-named-module``. (#GH146247)
666+
664667
- Clang now avoids issuing `-Wreturn-type` warnings in some cases where
665668
the final statement of a non-void function is a `throw` expression, or
666669
a call to a function that is trivially known to always throw (i.e., its
@@ -973,6 +976,8 @@ Arm and AArch64 Support
973976

974977
- For AArch64, added support for generating executable-only code sections by using the
975978
``-mexecute-only`` or ``-mpure-code`` compiler flags. (#GH125688)
979+
- Added ``-msve-streaming-vector-bits=`` flag, which allows specifying the
980+
SVE vector width in streaming mode.
976981

977982
Android Support
978983
^^^^^^^^^^^^^^^

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_f16_f32, "V2hV2hfUiIb", "nc", "f32-to-f16
645645
// GFX1250+ only builtins.
646646
//===----------------------------------------------------------------------===//
647647

648+
TARGET_BUILTIN(__builtin_amdgcn_tensor_load_to_lds, "vV4iV8iV4iV4iIi", "nc", "gfx1250-insts")
649+
TARGET_BUILTIN(__builtin_amdgcn_tensor_load_to_lds_d2, "vV4iV8iIi", "nc", "gfx1250-insts")
650+
TARGET_BUILTIN(__builtin_amdgcn_tensor_store_from_lds, "vV4iV8iV4iV4iIi", "nc", "gfx1250-insts")
651+
TARGET_BUILTIN(__builtin_amdgcn_tensor_store_from_lds_d2, "vV4iV8iIi", "nc", "gfx1250-insts")
652+
648653
TARGET_BUILTIN(__builtin_amdgcn_global_load_tr4_b64_v2i32, "V2iV2i*1", "nc", "transpose-load-f4f6-insts,wavefrontsize32")
649654
TARGET_BUILTIN(__builtin_amdgcn_global_load_tr8_b64_v2i32, "V2iV2i*1", "nc", "gfx1250-insts,wavefrontsize32")
650655
TARGET_BUILTIN(__builtin_amdgcn_global_load_tr6_b96_v3i32, "V3iV3i*1", "nc", "transpose-load-f4f6-insts,wavefrontsize32")

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,9 @@ def err_constexpr_main : Error<
10621062
"'main' is not allowed to be declared %select{constexpr|consteval}0">;
10631063
def err_deleted_main : Error<"'main' is not allowed to be deleted">;
10641064
def err_mainlike_template_decl : Error<"%0 cannot be a template">;
1065+
def warn_main_in_named_module
1066+
: ExtWarn<"'main' never has module linkage">,
1067+
InGroup<DiagGroup<"main-attached-to-named-module">>;
10651068
def err_main_returns_nonint : Error<"'main' must return 'int'">;
10661069
def ext_main_returns_nonint : ExtWarn<"return type of 'main' is not 'int'">,
10671070
InGroup<MainReturnType>;
@@ -3329,6 +3332,9 @@ def err_sve_vector_in_non_sve_target : Error<
33293332
"SVE vector type %0 cannot be used in a target without sve">;
33303333
def err_sve_vector_in_non_streaming_function : Error<
33313334
"SVE vector type %0 cannot be used in a non-streaming function">;
3335+
def err_sve_fixed_vector_in_streaming_function
3336+
: Error<"fixed width SVE vector type %0 cannot be used in a "
3337+
"%select{streaming|streaming-compatible}1 function">;
33323338
def err_attribute_riscv_rvv_bits_unsupported : Error<
33333339
"%0 is only supported when '-mrvv-vector-bits=<bits>' is specified with a "
33343340
"value of \"zvl\" or a power 2 in the range [64,65536]">;
@@ -13214,8 +13220,12 @@ def err_acc_not_a_var_ref_use_device_declare
1321413220
: Error<"OpenACC variable %select{in 'use_device' clause|on 'declare' "
1321513221
"construct}0 is not a valid variable name or array name">;
1321613222
def err_acc_not_a_var_ref_cache
13217-
: Error<"OpenACC variable in cache directive is not a valid sub-array or "
13223+
: Error<"OpenACC variable in 'cache' directive is not a valid sub-array or "
1321813224
"array element">;
13225+
def warn_acc_cache_var_not_outside_loop
13226+
: Warning<"OpenACC variable in 'cache' directive was not declared outside "
13227+
"of the associated 'loop' directive; directive has no effect">,
13228+
InGroup<DiagGroup<"openacc-cache-var-inside-loop">>;
1321913229
def err_acc_typecheck_subarray_value
1322013230
: Error<"OpenACC sub-array subscripted value is not an array or pointer">;
1322113231
def err_acc_subarray_function_type

clang/include/clang/Basic/LangOptions.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ LANGOPT(OmitVTableRTTI, 1, 0,
503503
LANGOPT(VScaleMin, 32, 0, "Minimum vscale value")
504504
LANGOPT(VScaleMax, 32, 0, "Maximum vscale value")
505505

506+
LANGOPT(VScaleStreamingMin, 32, 0, "Minimum streaming vscale value")
507+
LANGOPT(VScaleStreamingMax, 32, 0, "Maximum streaming vscale value")
508+
506509
ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, ExtendArgsKind::ExtendTo32,
507510
"Controls how scalar integer arguments are extended in calls "
508511
"to unprototyped and varargs functions")

clang/include/clang/Basic/TargetInfo.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,15 @@ class TargetInfo : public TransferrableTargetInfo,
10341034
/// set of primary and secondary targets.
10351035
virtual llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const = 0;
10361036

1037+
enum class ArmStreamingKind {
1038+
NotStreaming,
1039+
StreamingCompatible,
1040+
Streaming,
1041+
};
1042+
10371043
/// Returns target-specific min and max values VScale_Range.
10381044
virtual std::optional<std::pair<unsigned, unsigned>>
1039-
getVScaleRange(const LangOptions &LangOpts, bool IsArmStreamingFunction,
1045+
getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode,
10401046
llvm::StringMap<bool> *FeatureMap = nullptr) const {
10411047
return std::nullopt;
10421048
}

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,25 +228,28 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
228228

229229
cir::CallOp createCallOp(mlir::Location loc, mlir::SymbolRefAttr callee,
230230
mlir::Type returnType, mlir::ValueRange operands,
231-
cir::SideEffect sideEffect = cir::SideEffect::All) {
232-
return create<cir::CallOp>(loc, callee, returnType, operands, sideEffect);
231+
llvm::ArrayRef<mlir::NamedAttribute> attrs = {}) {
232+
auto op = create<cir::CallOp>(loc, callee, returnType, operands);
233+
op->setAttrs(attrs);
234+
return op;
233235
}
234236

235237
cir::CallOp createCallOp(mlir::Location loc, cir::FuncOp callee,
236238
mlir::ValueRange operands,
237-
cir::SideEffect sideEffect = cir::SideEffect::All) {
239+
llvm::ArrayRef<mlir::NamedAttribute> attrs = {}) {
238240
return createCallOp(loc, mlir::SymbolRefAttr::get(callee),
239241
callee.getFunctionType().getReturnType(), operands,
240-
sideEffect);
242+
attrs);
241243
}
242244

243-
cir::CallOp createIndirectCallOp(mlir::Location loc,
244-
mlir::Value indirectTarget,
245-
cir::FuncType funcType,
246-
mlir::ValueRange operands,
247-
cir::SideEffect sideEffect) {
248-
return create<cir::CallOp>(loc, indirectTarget, funcType.getReturnType(),
249-
operands, sideEffect);
245+
cir::CallOp
246+
createIndirectCallOp(mlir::Location loc, mlir::Value indirectTarget,
247+
cir::FuncType funcType, mlir::ValueRange operands,
248+
llvm::ArrayRef<mlir::NamedAttribute> attrs = {}) {
249+
llvm::SmallVector<mlir::Value> resOperands{indirectTarget};
250+
resOperands.append(operands.begin(), operands.end());
251+
return createCallOp(loc, mlir::SymbolRefAttr(), funcType.getReturnType(),
252+
resOperands, attrs);
250253
}
251254

252255
//===--------------------------------------------------------------------===//

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def CIR_Dialect : Dialect {
3737
let extraClassDeclaration = [{
3838
static llvm::StringRef getTripleAttrName() { return "cir.triple"; }
3939
static llvm::StringRef getOptInfoAttrName() { return "cir.opt_info"; }
40+
static llvm::StringRef getCalleeAttrName() { return "callee"; }
41+
static llvm::StringRef getNoThrowAttrName() { return "nothrow"; }
42+
static llvm::StringRef getSideEffectAttrName() { return "side_effect"; }
4043

4144
void registerAttributes();
4245
void registerTypes();

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

Lines changed: 145 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,7 @@ class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []>
19911991

19921992
dag commonArgs = (ins OptionalAttr<FlatSymbolRefAttr>:$callee,
19931993
Variadic<CIR_AnyType>:$args,
1994+
UnitAttr:$nothrow,
19941995
DefaultValuedAttr<CIR_SideEffect, "SideEffect::All">:$side_effect);
19951996
}
19961997

@@ -2020,29 +2021,14 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> {
20202021
let arguments = commonArgs;
20212022

20222023
let builders = [
2023-
// Build a call op for a direct call
20242024
OpBuilder<(ins "mlir::SymbolRefAttr":$callee, "mlir::Type":$resType,
2025-
"mlir::ValueRange":$operands,
2026-
CArg<"SideEffect", "SideEffect::All">:$sideEffect), [{
2027-
assert(callee && "callee attribute is required for direct call");
2025+
"mlir::ValueRange":$operands), [{
20282026
$_state.addOperands(operands);
2029-
$_state.addAttribute("callee", callee);
2030-
$_state.addAttribute("side_effect",
2031-
SideEffectAttr::get($_builder.getContext(), sideEffect));
2027+
if (callee)
2028+
$_state.addAttribute("callee", callee);
20322029
if (resType && !isa<VoidType>(resType))
20332030
$_state.addTypes(resType);
2034-
}]>,
2035-
// Build a call op for an indirect call
2036-
OpBuilder<(ins "mlir::Value":$calleePtr, "mlir::Type":$resType,
2037-
"mlir::ValueRange":$operands,
2038-
CArg<"SideEffect", "SideEffect::All">:$sideEffect), [{
2039-
$_state.addOperands(calleePtr);
2040-
$_state.addOperands(operands);
2041-
if (resType && !isa<VoidType>(resType))
2042-
$_state.addTypes(resType);
2043-
$_state.addAttribute("side_effect",
2044-
SideEffectAttr::get($_builder.getContext(), sideEffect));
2045-
}]>,
2031+
}]>
20462032
];
20472033
}
20482034

@@ -2535,6 +2521,146 @@ def ComplexImagOp : CIR_Op<"complex.imag", [Pure]> {
25352521
let hasFolder = 1;
25362522
}
25372523

2524+
//===----------------------------------------------------------------------===//
2525+
// Bit Manipulation Operations
2526+
//===----------------------------------------------------------------------===//
2527+
2528+
class CIR_BitOpBase<string mnemonic, TypeConstraint operandTy>
2529+
: CIR_Op<mnemonic, [Pure, SameOperandsAndResultType]> {
2530+
let arguments = (ins operandTy:$input);
2531+
let results = (outs operandTy:$result);
2532+
2533+
let assemblyFormat = [{
2534+
`(` $input `:` type($input) `)` `:` type($result) attr-dict
2535+
}];
2536+
}
2537+
2538+
class CIR_BitZeroCountOpBase<string mnemonic, TypeConstraint operandTy>
2539+
: CIR_BitOpBase<mnemonic, operandTy> {
2540+
let arguments = (ins operandTy:$input, UnitAttr:$poison_zero);
2541+
2542+
let assemblyFormat = [{
2543+
`(` $input `:` type($input) `)` (`poison_zero` $poison_zero^)?
2544+
`:` type($result) attr-dict
2545+
}];
2546+
}
2547+
2548+
def BitClrsbOp : CIR_BitOpBase<"bit.clrsb", CIR_SIntOfWidths<[32, 64]>> {
2549+
let summary = "Get the number of leading redundant sign bits in the input";
2550+
let description = [{
2551+
Compute the number of leading redundant sign bits in the input integer.
2552+
2553+
The input integer must be a signed integer. The most significant bit of the
2554+
input integer is the sign bit. The `cir.bit.clrsb` operation returns the
2555+
number of consecutive bits following the sign bit that are identical to the
2556+
sign bit.
2557+
2558+
The bit width of the input integer must be either 32 or 64.
2559+
2560+
Examples:
2561+
2562+
```mlir
2563+
// %0 = 0b1101_1110_1010_1101_1011_1110_1110_1111
2564+
%0 = cir.const #cir.int<3735928559> : !s32i
2565+
// %1 will be 1 because there is 1 bit following the most significant bit
2566+
// that is identical to it.
2567+
%1 = cir.bit.clrsb(%0 : !s32i) : !s32i
2568+
2569+
// %2 = 1, 0b0000_0000_0000_0000_0000_0000_0000_0001
2570+
%2 = cir.const #cir.int<1> : !s32i
2571+
// %3 will be 30 because there are 30 consecutive bits following the sign
2572+
// bit that are identical to the sign bit.
2573+
%3 = cir.bit.clrsb(%2 : !s32i) : !s32i
2574+
```
2575+
}];
2576+
}
2577+
2578+
def BitClzOp : CIR_BitZeroCountOpBase<"bit.clz",
2579+
CIR_UIntOfWidths<[16, 32, 64]>> {
2580+
let summary = "Get the number of leading 0-bits in the input";
2581+
let description = [{
2582+
Compute the number of leading 0-bits in the input.
2583+
2584+
The input integer must be an unsigned integer. The `cir.bit.clz` operation
2585+
returns the number of consecutive 0-bits at the most significant bit
2586+
position in the input.
2587+
2588+
If the `poison_zero` attribute is present, this operation will have
2589+
undefined behavior if the input value is 0.
2590+
2591+
Example:
2592+
2593+
```mlir
2594+
// %0 = 0b0000_0000_0000_0000_0000_0000_0000_1000
2595+
%0 = cir.const #cir.int<8> : !u32i
2596+
// %1 will be 28
2597+
%1 = cir.bit.clz(%0 : !u32i) poison_zero : !u32i
2598+
```
2599+
}];
2600+
}
2601+
2602+
def BitCtzOp : CIR_BitZeroCountOpBase<"bit.ctz",
2603+
CIR_UIntOfWidths<[16, 32, 64]>> {
2604+
let summary = "Get the number of trailing 0-bits in the input";
2605+
let description = [{
2606+
Compute the number of trailing 0-bits in the input.
2607+
2608+
The input integer must be an unsigned integer. The `cir.bit.ctz` operation
2609+
counts the number of consecutive 0-bits starting from the least significant
2610+
bit.
2611+
2612+
If the `poison_zero` attribute is present, this operation will have
2613+
undefined behavior if the input value is 0.
2614+
2615+
Example:
2616+
2617+
```mlir
2618+
// %0 = 0b1000
2619+
%0 = cir.const #cir.int<8> : !u32i
2620+
// %1 will be 3
2621+
%1 = cir.bit.ctz(%0 : !u32i) poison_zero : !u32i
2622+
```
2623+
}];
2624+
}
2625+
2626+
def BitParityOp : CIR_BitOpBase<"bit.parity", CIR_UIntOfWidths<[32, 64]>> {
2627+
let summary = "Get the parity of input";
2628+
let description = [{
2629+
Compute the parity of the input. The parity of an integer is the number of
2630+
1-bits in it modulo 2.
2631+
2632+
The input must be an unsigned integer.
2633+
2634+
Example:
2635+
2636+
```mlir
2637+
// %0 = 0x0110_1000
2638+
%0 = cir.const #cir.int<104> : !u32i
2639+
// %1 will be 1 since there are three 1-bits in %0
2640+
%1 = cir.bit.parity(%0 : !u32i) : !u32i
2641+
```
2642+
}];
2643+
}
2644+
2645+
def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
2646+
CIR_UIntOfWidths<[16, 32, 64]>> {
2647+
let summary = "Get the number of 1-bits in input";
2648+
let description = [{
2649+
Compute the number of 1-bits in the input.
2650+
2651+
The input must be an unsigned integer.
2652+
2653+
Example:
2654+
2655+
```mlir
2656+
// %0 = 0x0110_1000
2657+
%0 = cir.const #cir.int<104> : !u32i
2658+
// %1 will be 3 since there are 3 1-bits in %0
2659+
%1 = cir.bit.popcnt(%0 : !u32i) : !u32i
2660+
```
2661+
}];
2662+
}
2663+
25382664
//===----------------------------------------------------------------------===//
25392665
// Assume Operations
25402666
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/Interfaces/CIROpInterfaces.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ let cppNamespace = "::cir" in {
3434
"Return the number of operands, accounts for indirect call or "
3535
"exception info",
3636
"unsigned", "getNumArgOperands", (ins)>,
37+
InterfaceMethod<"Return whether the callee is nothrow",
38+
"bool", "getNothrow", (ins)>,
3739
InterfaceMethod<"Return the side effects of the call operation",
3840
"cir::SideEffect", "getSideEffect", (ins)>,
3941
];

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ struct MissingFeatures {
180180
static bool builtinCall() { return false; }
181181
static bool builtinCallF128() { return false; }
182182
static bool builtinCallMathErrno() { return false; }
183+
static bool builtinCheckKind() { return false; }
183184
static bool cgFPOptionsRAII() { return false; }
184185
static bool cirgenABIInfo() { return false; }
185186
static bool cleanupAfterErrorDiags() { return false; }

0 commit comments

Comments
 (0)