Skip to content

Commit 1175145

Browse files
authored
merge main into amd-staging (llvm#2710)
2 parents b60b3d9 + bf32c1a commit 1175145

File tree

96 files changed

+1062
-1052
lines changed

Some content is hidden

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

96 files changed

+1062
-1052
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5023,14 +5023,6 @@ def HLSLVkExtBuiltinInput : InheritableAttr {
50235023
let Documentation = [HLSLVkExtBuiltinInputDocs];
50245024
}
50255025

5026-
def HLSLVkConstantId : InheritableAttr {
5027-
let Spellings = [CXX11<"vk", "constant_id">];
5028-
let Args = [IntArgument<"Id">];
5029-
let Subjects = SubjectList<[ExternalGlobalVar]>;
5030-
let LangOpts = [HLSL];
5031-
let Documentation = [VkConstantIdDocs];
5032-
}
5033-
50345026
def RandomizeLayout : InheritableAttr {
50355027
let Spellings = [GCC<"randomize_layout">];
50365028
let Subjects = SubjectList<[Record]>;

clang/include/clang/Basic/AttrDocs.td

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8252,21 +8252,6 @@ and https://microsoft.github.io/hlsl-specs/proposals/0013-wave-size-range.html
82528252
}];
82538253
}
82548254

8255-
def VkConstantIdDocs : Documentation {
8256-
let Category = DocCatFunction;
8257-
let Content = [{
8258-
The ``vk::constant_id`` attribute specifies the id for a SPIR-V specialization
8259-
constant. The attribute applies to const global scalar variables. The variable must be initialized with a C++11 constexpr.
8260-
In SPIR-V, the
8261-
variable will be replaced with an `OpSpecConstant` with the given id.
8262-
The syntax is:
8263-
8264-
.. code-block:: text
8265-
8266-
``[[vk::constant_id(<Id>)]] const T Name = <Init>``
8267-
}];
8268-
}
8269-
82708255
def RootSignatureDocs : Documentation {
82718256
let Category = DocCatFunction;
82728257
let Content = [{

clang/include/clang/Basic/Builtins.td

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5065,19 +5065,6 @@ def HLSLGroupMemoryBarrierWithGroupSync: LangBuiltin<"HLSL_LANG"> {
50655065
let Prototype = "void()";
50665066
}
50675067

5068-
class HLSLScalarTemplate
5069-
: Template<["bool", "char", "short", "int", "long long int",
5070-
"unsigned short", "unsigned int", "unsigned long long int",
5071-
"__fp16", "float", "double"],
5072-
["_bool", "_char", "_short", "_int", "_longlong", "_ushort",
5073-
"_uint", "_ulonglong", "_half", "_float", "_double"]>;
5074-
5075-
def HLSLGetSpirvSpecConstant : LangBuiltin<"HLSL_LANG">, HLSLScalarTemplate {
5076-
let Spellings = ["__builtin_get_spirv_spec_constant"];
5077-
let Attributes = [NoThrow, Const, Pure];
5078-
let Prototype = "T(unsigned int, T)";
5079-
}
5080-
50815068
// Builtins for XRay.
50825069
def XRayCustomEvent : Builtin {
50835070
let Spellings = ["__xray_customevent"];

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12931,10 +12931,6 @@ def err_spirv_enum_not_int : Error<
1293112931
def err_spirv_enum_not_valid : Error<
1293212932
"invalid value for %select{storage class}0 argument">;
1293312933

12934-
def err_specialization_const
12935-
: Error<"variable with 'vk::constant_id' attribute must be a const "
12936-
"int/float/enum/bool and be initialized with a literal">;
12937-
1293812934
// errors of expect.with.probability
1293912935
def err_probability_not_constant_float : Error<
1294012936
"probability argument to __builtin_expect_with_probability must be constant "

clang/include/clang/Sema/SemaHLSL.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ class SemaHLSL : public SemaBase {
9898
HLSLWaveSizeAttr *mergeWaveSizeAttr(Decl *D, const AttributeCommonInfo &AL,
9999
int Min, int Max, int Preferred,
100100
int SpelledArgsCount);
101-
HLSLVkConstantIdAttr *
102-
mergeVkConstantIdAttr(Decl *D, const AttributeCommonInfo &AL, int Id);
103101
HLSLShaderAttr *mergeShaderAttr(Decl *D, const AttributeCommonInfo &AL,
104102
llvm::Triple::EnvironmentType ShaderType);
105103
HLSLParamModifierAttr *
@@ -137,7 +135,6 @@ class SemaHLSL : public SemaBase {
137135
void handleRootSignatureAttr(Decl *D, const ParsedAttr &AL);
138136
void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL);
139137
void handleWaveSizeAttr(Decl *D, const ParsedAttr &AL);
140-
void handleVkConstantIdAttr(Decl *D, const ParsedAttr &AL);
141138
void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL);
142139
void handleSV_GroupThreadIDAttr(Decl *D, const ParsedAttr &AL);
143140
void handleSV_GroupIDAttr(Decl *D, const ParsedAttr &AL);
@@ -174,7 +171,7 @@ class SemaHLSL : public SemaBase {
174171
QualType getInoutParameterType(QualType Ty);
175172

176173
bool transformInitList(const InitializedEntity &Entity, InitListExpr *Init);
177-
bool handleInitialization(VarDecl *VDecl, Expr *&Init);
174+
178175
void deduceAddressSpace(VarDecl *Decl);
179176

180177
private:

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
7878
assert(!cir::MissingFeatures::builtinCallMathErrno());
7979
assert(!cir::MissingFeatures::builtinCall());
8080

81+
mlir::Location loc = getLoc(e->getExprLoc());
82+
8183
switch (builtinIDIfNoAsmLabel) {
8284
default:
8385
break;
@@ -88,9 +90,16 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
8890
return RValue::get(nullptr);
8991

9092
mlir::Value argValue = emitCheckedArgForAssume(e->getArg(0));
91-
builder.create<cir::AssumeOp>(getLoc(e->getExprLoc()), argValue);
93+
builder.create<cir::AssumeOp>(loc, argValue);
9294
return RValue::get(nullptr);
9395
}
96+
97+
case Builtin::BI__builtin_complex: {
98+
mlir::Value real = emitScalarExpr(e->getArg(0));
99+
mlir::Value imag = emitScalarExpr(e->getArg(1));
100+
mlir::Value complex = builder.createComplexCreate(loc, real, imag);
101+
return RValue::get(complex);
102+
}
94103
}
95104

96105
cgm.errorNYI(e->getSourceRange(), "unimplemented builtin call");

clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,25 @@ class ComplexExprEmitter : public StmtVisitor<ComplexExprEmitter, mlir::Value> {
1515
explicit ComplexExprEmitter(CIRGenFunction &cgf)
1616
: cgf(cgf), builder(cgf.getBuilder()) {}
1717

18+
//===--------------------------------------------------------------------===//
19+
// Utilities
20+
//===--------------------------------------------------------------------===//
21+
22+
/// Given an expression with complex type that represents a value l-value,
23+
/// this method emits the address of the l-value, then loads and returns the
24+
/// result.
25+
mlir::Value emitLoadOfLValue(const Expr *e) {
26+
return emitLoadOfLValue(cgf.emitLValue(e), e->getExprLoc());
27+
}
28+
29+
mlir::Value emitLoadOfLValue(LValue lv, SourceLocation loc);
30+
1831
/// Store the specified real/imag parts into the
1932
/// specified value pointer.
2033
void emitStoreOfComplex(mlir::Location loc, mlir::Value val, LValue lv,
2134
bool isInit);
2235

36+
mlir::Value VisitCallExpr(const CallExpr *e);
2337
mlir::Value VisitInitListExpr(InitListExpr *e);
2438

2539
mlir::Value VisitImaginaryLiteral(const ImaginaryLiteral *il);
@@ -34,18 +48,35 @@ static const ComplexType *getComplexType(QualType type) {
3448
return cast<ComplexType>(cast<AtomicType>(type)->getValueType());
3549
}
3650

51+
mlir::Value ComplexExprEmitter::emitLoadOfLValue(LValue lv,
52+
SourceLocation loc) {
53+
assert(lv.isSimple() && "non-simple complex l-value?");
54+
if (lv.getType()->isAtomicType())
55+
cgf.cgm.errorNYI(loc, "emitLoadOfLValue with Atomic LV");
56+
57+
const Address srcAddr = lv.getAddress();
58+
return builder.createLoad(cgf.getLoc(loc), srcAddr);
59+
}
60+
3761
void ComplexExprEmitter::emitStoreOfComplex(mlir::Location loc, mlir::Value val,
3862
LValue lv, bool isInit) {
3963
if (lv.getType()->isAtomicType() ||
4064
(!isInit && cgf.isLValueSuitableForInlineAtomic(lv))) {
41-
cgf.cgm.errorNYI("StoreOfComplex with Atomic LV");
65+
cgf.cgm.errorNYI(loc, "StoreOfComplex with Atomic LV");
4266
return;
4367
}
4468

4569
const Address destAddr = lv.getAddress();
4670
builder.createStore(loc, val, destAddr);
4771
}
4872

73+
mlir::Value ComplexExprEmitter::VisitCallExpr(const CallExpr *e) {
74+
if (e->getCallReturnType(cgf.getContext())->isReferenceType())
75+
return emitLoadOfLValue(e);
76+
77+
return cgf.emitCallExpr(e).getValue();
78+
}
79+
4980
mlir::Value ComplexExprEmitter::VisitInitListExpr(InitListExpr *e) {
5081
mlir::Location loc = cgf.getLoc(e->getExprLoc());
5182
if (e->getNumInits() == 2) {

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,22 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
416416
break;
417417
}
418418

419+
case Type::IncompleteArray: {
420+
const IncompleteArrayType *arrTy = cast<IncompleteArrayType>(ty);
421+
if (arrTy->getIndexTypeCVRQualifiers() != 0)
422+
cgm.errorNYI(SourceLocation(), "non trivial array types", type);
423+
424+
mlir::Type elemTy = convertTypeForMem(arrTy->getElementType());
425+
// int X[] -> [0 x int], unless the element type is not sized. If it is
426+
// unsized (e.g. an incomplete record) just use [0 x i8].
427+
if (!builder.isSized(elemTy)) {
428+
elemTy = cgm.SInt8Ty;
429+
}
430+
431+
resultType = cir::ArrayType::get(elemTy, 0);
432+
break;
433+
}
434+
419435
case Type::ConstantArray: {
420436
const ConstantArrayType *arrTy = cast<ConstantArrayType>(ty);
421437
mlir::Type elemTy = convertTypeForMem(arrTy->getElementType());

clang/lib/CIR/CodeGen/CIRGenValue.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class RValue {
8888
return er;
8989
}
9090

91-
// FIXME: Aggregate rvalues need to retain information about whether they are
9291
// volatile or not. Remove default to find all places that probably get this
9392
// wrong.
9493

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,8 @@ unsigned CodeGenTypes::ClangCallConvToLLVMCallConv(CallingConv CC) {
8383
return llvm::CallingConv::AArch64_SVE_VectorCall;
8484
case CC_SpirFunction:
8585
return llvm::CallingConv::SPIR_FUNC;
86-
case CC_DeviceKernel: {
87-
if (CGM.getLangOpts().OpenCL)
88-
return CGM.getTargetCodeGenInfo().getOpenCLKernelCallingConv();
89-
if (CGM.getTriple().isSPIROrSPIRV())
90-
return llvm::CallingConv::SPIR_KERNEL;
91-
if (CGM.getTriple().isAMDGPU())
92-
return llvm::CallingConv::AMDGPU_KERNEL;
93-
if (CGM.getTriple().isNVPTX())
94-
return llvm::CallingConv::PTX_Kernel;
95-
llvm_unreachable("Unknown kernel calling convention");
96-
}
86+
case CC_DeviceKernel:
87+
return CGM.getTargetCodeGenInfo().getDeviceKernelCallingConv();
9788
case CC_PreserveMost:
9889
return llvm::CallingConv::PreserveMost;
9990
case CC_PreserveAll:

0 commit comments

Comments
 (0)