Skip to content

Commit 8efd590

Browse files
committed
Merge from 'main' to 'sycl-web' (54 commits)
CONFLICT (content): Merge conflict in clang/include/clang/Basic/DiagnosticSemaKinds.td
2 parents 4c8ba45 + 8cc9a48 commit 8efd590

File tree

521 files changed

+41521
-105123
lines changed

Some content is hidden

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

521 files changed

+41521
-105123
lines changed

clang/include/clang/Analysis/ProgramPoint.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class ProgramPointTag {
3939
public:
4040
ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {}
4141
virtual ~ProgramPointTag();
42+
43+
/// The description of this program point which will be displayed when the
44+
/// ExplodedGraph is dumped in DOT format for debugging.
4245
virtual StringRef getTagDescription() const = 0;
4346

4447
/// Used to implement 'isKind' in subclasses.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7731,9 +7731,13 @@ def warn_arith_conv_mixed_enum_types_cxx20 : Warning<
77317731
"%sub{select_arith_conv_kind}0 "
77327732
"different enumeration types%diff{ ($ and $)|}1,2 is deprecated">,
77337733
InGroup<DeprecatedEnumEnumConversion>;
7734-
def err_conv_mixed_enum_types_cxx26 : Error<
7734+
7735+
def err_conv_mixed_enum_types: Error <
77357736
"invalid %sub{select_arith_conv_kind}0 "
77367737
"different enumeration types%diff{ ($ and $)|}1,2">;
7738+
def warn_conv_mixed_enum_types_cxx26 : Warning <
7739+
err_conv_mixed_enum_types.Summary>,
7740+
InGroup<EnumEnumConversion>, DefaultError;
77377741

77387742
def warn_arith_conv_mixed_anon_enum_types : Warning<
77397743
warn_arith_conv_mixed_enum_types.Summary>,
@@ -12632,21 +12636,34 @@ def err_builtin_is_within_lifetime_invalid_arg : Error<
1263212636
"%select{non-|function }0pointer argument to '__builtin_is_within_lifetime' "
1263312637
"is not allowed">;
1263412638

12635-
def err_builtin_invalid_arg_type: Error <
12636-
"%ordinal0 argument must be "
12637-
"%select{a vector, integer or floating point type|a matrix|"
12638-
"a pointer to a valid matrix element type|"
12639-
"a signed integer or floating point type|a vector type|"
12640-
"a floating point type|"
12641-
"a vector of integers|"
12642-
"an unsigned integer|"
12643-
"an 'int'|"
12644-
"a vector of floating points|"
12645-
"a function pointer}1 (was %2)">;
12639+
// A multi-component builtin type diagnostic. The first component broadly
12640+
// selects a scalar or container type (scalar, vector or matrix). The second
12641+
// component selects integer types and the third component selects
12642+
// floating-point types. Any component can be left empty.
12643+
def err_builtin_invalid_arg_type: Error<
12644+
"%ordinal0 argument must be a "
12645+
// First component: scalar or container types
12646+
"%select{|scalar|vector|matrix|vector of|scalar or vector of}1"
12647+
// A comma after generic vector/matrix types if there are non-empty second
12648+
// and third components, to initiate a list.
12649+
"%plural{[2,3]:%plural{0:|:%plural{0:|:,}2}3|:}1"
12650+
// A space after a non-empty first component
12651+
"%plural{0:|: }1"
12652+
// Second component: integer-like types
12653+
"%select{|integer|signed integer|unsigned integer|'int'|"
12654+
"pointer to a valid matrix element}2"
12655+
// A space after a non-empty second component
12656+
"%plural{0:|: }2"
12657+
// An 'or' if non-empty second and third components are combined
12658+
"%plural{0:|:%plural{0:|:or }2}3"
12659+
// Third component: floating-point types
12660+
"%select{|floating-point}3"
12661+
// A space after a non-empty third component
12662+
"%plural{0:|: }3"
12663+
"%plural{[0,3]:type|:types}1 (was %4)">;
1264612664

1264712665
def err_builtin_invalid_arg_value: Error<
1264812666
"%ordinal0 argument must be a strictly positive value (was %1)">;
12649-
1265012667
def err_builtin_matrix_disabled: Error<
1265112668
"matrix types extension is disabled. Pass -fenable-matrix to enable it">;
1265212669
def err_matrix_index_not_integer: Error<

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
#define LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
1111

1212
#include "clang/AST/CharUnits.h"
13+
#include "clang/AST/Type.h"
1314
#include "clang/CIR/Dialect/IR/CIRAttrs.h"
1415
#include "clang/CIR/Dialect/IR/CIRDialect.h"
1516
#include "clang/CIR/Dialect/IR/CIRTypes.h"
17+
#include "llvm/Support/ErrorHandling.h"
1618

1719
#include "mlir/IR/Builders.h"
1820
#include "mlir/IR/BuiltinTypes.h"
@@ -78,6 +80,60 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
7880
return create<cir::StoreOp>(loc, val, dst);
7981
}
8082

83+
mlir::Value createDummyValue(mlir::Location loc, mlir::Type type,
84+
clang::CharUnits alignment) {
85+
auto addr = createAlloca(loc, getPointerTo(type), type, {},
86+
getSizeFromCharUnits(getContext(), alignment));
87+
return createLoad(loc, addr);
88+
}
89+
90+
//===--------------------------------------------------------------------===//
91+
// Cast/Conversion Operators
92+
//===--------------------------------------------------------------------===//
93+
94+
mlir::Value createCast(mlir::Location loc, cir::CastKind kind,
95+
mlir::Value src, mlir::Type newTy) {
96+
if (newTy == src.getType())
97+
return src;
98+
return create<cir::CastOp>(loc, newTy, kind, src);
99+
}
100+
101+
mlir::Value createCast(cir::CastKind kind, mlir::Value src,
102+
mlir::Type newTy) {
103+
if (newTy == src.getType())
104+
return src;
105+
return createCast(src.getLoc(), kind, src, newTy);
106+
}
107+
108+
mlir::Value createIntCast(mlir::Value src, mlir::Type newTy) {
109+
return createCast(cir::CastKind::integral, src, newTy);
110+
}
111+
112+
mlir::Value createIntToPtr(mlir::Value src, mlir::Type newTy) {
113+
return createCast(cir::CastKind::int_to_ptr, src, newTy);
114+
}
115+
116+
mlir::Value createPtrToInt(mlir::Value src, mlir::Type newTy) {
117+
return createCast(cir::CastKind::ptr_to_int, src, newTy);
118+
}
119+
120+
mlir::Value createPtrToBoolCast(mlir::Value v) {
121+
return createCast(cir::CastKind::ptr_to_bool, v, getBoolTy());
122+
}
123+
124+
mlir::Value createBoolToInt(mlir::Value src, mlir::Type newTy) {
125+
return createCast(cir::CastKind::bool_to_int, src, newTy);
126+
}
127+
128+
mlir::Value createBitcast(mlir::Value src, mlir::Type newTy) {
129+
return createCast(cir::CastKind::bitcast, src, newTy);
130+
}
131+
132+
mlir::Value createBitcast(mlir::Location loc, mlir::Value src,
133+
mlir::Type newTy) {
134+
return createCast(loc, cir::CastKind::bitcast, src, newTy);
135+
}
136+
81137
//
82138
// Block handling helpers
83139
// ----------------------

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

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,156 @@ class LLVMLoweringInfo {
7878
class CIR_Op<string mnemonic, list<Trait> traits = []> :
7979
Op<CIR_Dialect, mnemonic, traits>, LLVMLoweringInfo;
8080

81+
//===----------------------------------------------------------------------===//
82+
// CastOp
83+
//===----------------------------------------------------------------------===//
84+
85+
// CK_Dependent
86+
def CK_BitCast : I32EnumAttrCase<"bitcast", 1>;
87+
// CK_LValueBitCast
88+
// CK_LValueToRValueBitCast
89+
// CK_LValueToRValue
90+
// CK_NoOp
91+
// CK_BaseToDerived
92+
// CK_DerivedToBase
93+
// CK_UncheckedDerivedToBase
94+
// CK_Dynamic
95+
// CK_ToUnion
96+
def CK_ArrayToPointerDecay : I32EnumAttrCase<"array_to_ptrdecay", 11>;
97+
// CK_FunctionToPointerDecay
98+
// CK_NullToPointer
99+
// CK_NullToMemberPointer
100+
// CK_BaseToDerivedMemberPointer
101+
// CK_DerivedToBaseMemberPointer
102+
def CK_MemberPointerToBoolean : I32EnumAttrCase<"member_ptr_to_bool", 17>;
103+
// CK_ReinterpretMemberPointer
104+
// CK_UserDefinedConversion
105+
// CK_ConstructorConversion
106+
def CK_IntegralToPointer : I32EnumAttrCase<"int_to_ptr", 21>;
107+
def CK_PointerToIntegral : I32EnumAttrCase<"ptr_to_int", 22>;
108+
def CK_PointerToBoolean : I32EnumAttrCase<"ptr_to_bool", 23>;
109+
// CK_ToVoid
110+
// CK_MatrixCast
111+
// CK_VectorSplat
112+
def CK_IntegralCast : I32EnumAttrCase<"integral", 27>;
113+
def CK_IntegralToBoolean : I32EnumAttrCase<"int_to_bool", 28>;
114+
def CK_IntegralToFloating : I32EnumAttrCase<"int_to_float", 29>;
115+
// CK_FloatingToFixedPoint
116+
// CK_FixedPointToFloating
117+
// CK_FixedPointCast
118+
// CK_FixedPointToIntegral
119+
// CK_IntegralToFixedPoint
120+
// CK_FixedPointToBoolean
121+
def CK_FloatingToIntegral : I32EnumAttrCase<"float_to_int", 36>;
122+
def CK_FloatingToBoolean : I32EnumAttrCase<"float_to_bool", 37>;
123+
def CK_BooleanToSignedIntegral : I32EnumAttrCase<"bool_to_int", 38>;
124+
def CK_FloatingCast : I32EnumAttrCase<"floating", 39>;
125+
// CK_CPointerToObjCPointerCast
126+
// CK_BlockPointerToObjCPointerCast
127+
// CK_AnyPointerToBlockPointerCast
128+
// CK_ObjCObjectLValueCast
129+
// CK_FloatingRealToComplex
130+
// CK_FloatingComplexToReal
131+
// CK_FloatingComplexToBoolean
132+
def CK_FloatingComplexCast : I32EnumAttrCase<"float_complex", 47>;
133+
// CK_FloatingComplexToIntegralComplex
134+
// CK_IntegralRealToComplex
135+
def CK_IntegralComplexToReal : I32EnumAttrCase<"int_complex_to_real", 50>;
136+
def CK_IntegralComplexToBoolean : I32EnumAttrCase<"int_complex_to_bool", 51>;
137+
def CK_IntegralComplexCast : I32EnumAttrCase<"int_complex", 52>;
138+
def CK_IntegralComplexToFloatingComplex
139+
: I32EnumAttrCase<"int_complex_to_float_complex", 53>;
140+
// CK_ARCProduceObject
141+
// CK_ARCConsumeObject
142+
// CK_ARCReclaimReturnedObject
143+
// CK_ARCExtendBlockObject
144+
// CK_AtomicToNonAtomic
145+
// CK_NonAtomicToAtomic
146+
// CK_CopyAndAutoreleaseBlockObject
147+
// CK_BuiltinFnToFnPtr
148+
// CK_ZeroToOCLOpaqueType
149+
def CK_AddressSpaceConversion : I32EnumAttrCase<"address_space", 63>;
150+
// CK_IntToOCLSampler
151+
// CK_HLSLVectorTruncation
152+
// CK_HLSLArrayRValue
153+
// CK_HLSLElementwiseCast
154+
// CK_HLSLAggregateSplatCast
155+
156+
// Enums below are specific to CIR and don't have a correspondence to classic
157+
// codegen:
158+
def CK_BooleanToFloat : I32EnumAttrCase<"bool_to_float", 1000>;
159+
160+
def CastKind : I32EnumAttr<
161+
"CastKind",
162+
"cast kind",
163+
[CK_BitCast, CK_ArrayToPointerDecay, CK_MemberPointerToBoolean,
164+
CK_IntegralToPointer, CK_PointerToIntegral, CK_PointerToBoolean,
165+
CK_IntegralCast, CK_IntegralToBoolean, CK_IntegralToFloating,
166+
CK_FloatingToIntegral, CK_FloatingToBoolean, CK_BooleanToSignedIntegral,
167+
CK_FloatingCast, CK_FloatingComplexCast, CK_IntegralComplexToReal,
168+
CK_IntegralComplexToBoolean, CK_IntegralComplexCast,
169+
CK_IntegralComplexToFloatingComplex, CK_AddressSpaceConversion,
170+
CK_BooleanToFloat]> {
171+
let cppNamespace = "::cir";
172+
}
173+
174+
def CastOp : CIR_Op<"cast",
175+
[Pure,
176+
DeclareOpInterfaceMethods<PromotableOpInterface>]> {
177+
// FIXME: not all conversions are free of side effects.
178+
let summary = "Conversion between values of different types";
179+
let description = [{
180+
Apply C/C++ usual conversions rules between values. Currently supported kinds:
181+
182+
- `array_to_ptrdecay`
183+
- `bitcast`
184+
- `integral`
185+
- `int_to_bool`
186+
- `int_to_float`
187+
- `floating`
188+
- `float_to_int`
189+
- `float_to_bool`
190+
- `ptr_to_int`
191+
- `ptr_to_bool`
192+
- `bool_to_int`
193+
- `bool_to_float`
194+
- `address_space`
195+
- `float_to_complex`
196+
- `int_to_complex`
197+
- `float_complex_to_real`
198+
- `int_complex_to_real`
199+
- `float_complex_to_bool`
200+
- `int_complex_to_bool`
201+
- `float_complex`
202+
- `float_complex_to_int_complex`
203+
- `int_complex`
204+
- `int_complex_to_float_complex`
205+
206+
This is effectively a subset of the rules from
207+
`llvm-project/clang/include/clang/AST/OperationKinds.def`; but note that some
208+
of the conversions aren't implemented in terms of `cir.cast`, `lvalue-to-rvalue`
209+
for instance is modeled as a regular `cir.load`.
210+
211+
```mlir
212+
%4 = cir.cast (int_to_bool, %3 : i32), !cir.bool
213+
...
214+
%x = cir.cast(array_to_ptrdecay, %0 : !cir.ptr<!cir.array<i32 x 10>>), !cir.ptr<i32>
215+
```
216+
}];
217+
218+
let arguments = (ins CastKind:$kind, CIR_AnyType:$src);
219+
let results = (outs CIR_AnyType:$result);
220+
221+
let assemblyFormat = [{
222+
`(` $kind `,` $src `:` type($src) `)`
223+
`,` type($result) attr-dict
224+
}];
225+
226+
// The input and output types should match the cast kind.
227+
let hasVerifier = 1;
228+
let hasFolder = 1;
229+
}
230+
81231
//===----------------------------------------------------------------------===//
82232
// ConstantOp
83233
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,31 @@ struct MissingFeatures {
7777
static bool opUnaryPromotionType() { return false; }
7878

7979
// Misc
80-
static bool scalarConversionOpts() { return false; }
80+
static bool cxxABI() { return false; }
8181
static bool tryEmitAsConstant() { return false; }
8282
static bool constructABIArgDirectExtend() { return false; }
8383
static bool opGlobalViewAttr() { return false; }
8484
static bool lowerModeOptLevel() { return false; }
8585
static bool opTBAA() { return false; }
86+
static bool opCmp() { return false; }
8687
static bool objCLifetime() { return false; }
8788
static bool emitNullabilityCheck() { return false; }
8889
static bool astVarDeclInterface() { return false; }
8990
static bool stackSaveOp() { return false; }
9091
static bool aggValueSlot() { return false; }
9192

92-
static bool unsizedTypes() { return false; }
93+
static bool fpConstraints() { return false; }
9394
static bool sanitizers() { return false; }
95+
static bool addHeapAllocSiteMetadata() { return false; }
96+
static bool targetCodeGenInfoGetNullPointer() { return false; }
9497
static bool CGFPOptionsRAII() { return false; }
9598

9699
// Missing types
100+
static bool dataMemberType() { return false; }
101+
static bool matrixType() { return false; }
102+
static bool methodType() { return false; }
103+
static bool scalableVectors() { return false; }
104+
static bool unsizedTypes() { return false; }
97105
static bool vectorType() { return false; }
98106
};
99107

clang/include/clang/Sema/Sema.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,9 +2360,18 @@ class Sema final : public SemaBase {
23602360
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
23612361
const FunctionProtoType *Proto);
23622362

2363+
enum class EltwiseBuiltinArgTyRestriction {
2364+
None,
2365+
FloatTy,
2366+
IntegerTy,
2367+
SignedIntOrFloatTy,
2368+
};
2369+
23632370
/// \param FPOnly restricts the arguments to floating-point types.
2364-
std::optional<QualType> BuiltinVectorMath(CallExpr *TheCall,
2365-
bool FPOnly = false);
2371+
std::optional<QualType>
2372+
BuiltinVectorMath(CallExpr *TheCall,
2373+
EltwiseBuiltinArgTyRestriction ArgTyRestr =
2374+
EltwiseBuiltinArgTyRestriction::None);
23662375
bool BuiltinVectorToScalarMath(CallExpr *TheCall);
23672376

23682377
void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
@@ -2466,9 +2475,13 @@ class Sema final : public SemaBase {
24662475
bool *ICContext = nullptr,
24672476
bool IsListInit = false);
24682477

2469-
bool BuiltinElementwiseTernaryMath(CallExpr *TheCall,
2470-
bool CheckForFloatArgs = true);
2471-
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall);
2478+
bool
2479+
BuiltinElementwiseTernaryMath(CallExpr *TheCall,
2480+
EltwiseBuiltinArgTyRestriction ArgTyRestr =
2481+
EltwiseBuiltinArgTyRestriction::FloatTy);
2482+
bool PrepareBuiltinElementwiseMathOneArgCall(
2483+
CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr =
2484+
EltwiseBuiltinArgTyRestriction::None);
24722485

24732486
private:
24742487
void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
@@ -2577,7 +2590,9 @@ class Sema final : public SemaBase {
25772590
AtomicExpr::AtomicOp Op);
25782591

25792592
/// \param FPOnly restricts the arguments to floating-point types.
2580-
bool BuiltinElementwiseMath(CallExpr *TheCall, bool FPOnly = false);
2593+
bool BuiltinElementwiseMath(CallExpr *TheCall,
2594+
EltwiseBuiltinArgTyRestriction ArgTyRestr =
2595+
EltwiseBuiltinArgTyRestriction::None);
25812596
bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
25822597

25832598
bool BuiltinNonDeterministicValue(CallExpr *TheCall);

0 commit comments

Comments
 (0)