Skip to content

Commit bb6ea76

Browse files
committed
merge main into amd-staging
2 parents b60b3d9 + 5875faf commit bb6ea76

File tree

132 files changed

+8819
-1154
lines changed

Some content is hidden

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

132 files changed

+8819
-1154
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/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,22 +227,26 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
227227
//===--------------------------------------------------------------------===//
228228

229229
cir::CallOp createCallOp(mlir::Location loc, mlir::SymbolRefAttr callee,
230-
mlir::Type returnType, mlir::ValueRange operands) {
231-
return create<cir::CallOp>(loc, callee, returnType, operands);
230+
mlir::Type returnType, mlir::ValueRange operands,
231+
cir::SideEffect sideEffect = cir::SideEffect::All) {
232+
return create<cir::CallOp>(loc, callee, returnType, operands, sideEffect);
232233
}
233234

234235
cir::CallOp createCallOp(mlir::Location loc, cir::FuncOp callee,
235-
mlir::ValueRange operands) {
236+
mlir::ValueRange operands,
237+
cir::SideEffect sideEffect = cir::SideEffect::All) {
236238
return createCallOp(loc, mlir::SymbolRefAttr::get(callee),
237-
callee.getFunctionType().getReturnType(), operands);
239+
callee.getFunctionType().getReturnType(), operands,
240+
sideEffect);
238241
}
239242

240243
cir::CallOp createIndirectCallOp(mlir::Location loc,
241244
mlir::Value indirectTarget,
242245
cir::FuncType funcType,
243-
mlir::ValueRange operands) {
246+
mlir::ValueRange operands,
247+
cir::SideEffect sideEffect) {
244248
return create<cir::CallOp>(loc, indirectTarget, funcType.getReturnType(),
245-
operands);
249+
operands, sideEffect);
246250
}
247251

248252
//===--------------------------------------------------------------------===//

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class CIR_TypedAttr<string name, string attrMnemonic, list<Trait> traits = []>
4242
let assemblyFormat = [{}];
4343
}
4444

45+
class CIR_I32EnumAttr<string name, string summary, list<I32EnumAttrCase> cases>
46+
: I32EnumAttr<name, summary, cases> {
47+
let cppNamespace = "::cir";
48+
}
49+
4550
class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
4651
: CIR_Attr<name, attrMnemonic, traits> {
4752
let returnType = "bool";

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

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,36 @@ def FuncOp : CIR_Op<"func", [
18581858
// CallOp
18591859
//===----------------------------------------------------------------------===//
18601860

1861+
def CIR_SideEffect : CIR_I32EnumAttr<
1862+
"SideEffect", "allowed side effects of a function", [
1863+
I32EnumAttrCase<"All", 1, "all">,
1864+
I32EnumAttrCase<"Pure", 2, "pure">,
1865+
I32EnumAttrCase<"Const", 3, "const">
1866+
]> {
1867+
let description = [{
1868+
The side effect attribute specifies the possible side effects of the callee
1869+
of a call operation. This is an enumeration attribute and all possible
1870+
enumerators are:
1871+
1872+
- all: The callee can have any side effects. This is the default if no side
1873+
effects are explicitly listed.
1874+
- pure: The callee may read data from memory, but it cannot write data to
1875+
memory. This has the same effect as the GNU C/C++ attribute
1876+
`__attribute__((pure))`.
1877+
- const: The callee may not read or write data from memory. This has the
1878+
same effect as the GNU C/C++ attribute `__attribute__((const))`.
1879+
1880+
Examples:
1881+
1882+
```mlir
1883+
%2 = cir.call @add(%0, %1) : (!s32i, !s32i) -> !s32i
1884+
%2 = cir.call @add(%0, %1) : (!s32i, !s32i) -> !s32i side_effect(pure)
1885+
%2 = cir.call @add(%0, %1) : (!s32i, !s32i) -> !s32i side_effect(const)
1886+
```
1887+
}];
1888+
let cppNamespace = "::cir";
1889+
}
1890+
18611891
class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []>
18621892
: Op<CIR_Dialect, mnemonic,
18631893
!listconcat(extra_traits,
@@ -1911,7 +1941,8 @@ class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []>
19111941
// will add in the future.
19121942

19131943
dag commonArgs = (ins OptionalAttr<FlatSymbolRefAttr>:$callee,
1914-
Variadic<CIR_AnyType>:$args);
1944+
Variadic<CIR_AnyType>:$args,
1945+
DefaultValuedAttr<CIR_SideEffect, "SideEffect::All">:$side_effect);
19151946
}
19161947

19171948
def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> {
@@ -1942,20 +1973,26 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> {
19421973
let builders = [
19431974
// Build a call op for a direct call
19441975
OpBuilder<(ins "mlir::SymbolRefAttr":$callee, "mlir::Type":$resType,
1945-
"mlir::ValueRange":$operands), [{
1976+
"mlir::ValueRange":$operands,
1977+
CArg<"SideEffect", "SideEffect::All">:$sideEffect), [{
19461978
assert(callee && "callee attribute is required for direct call");
19471979
$_state.addOperands(operands);
19481980
$_state.addAttribute("callee", callee);
1981+
$_state.addAttribute("side_effect",
1982+
SideEffectAttr::get($_builder.getContext(), sideEffect));
19491983
if (resType && !isa<VoidType>(resType))
19501984
$_state.addTypes(resType);
19511985
}]>,
19521986
// Build a call op for an indirect call
19531987
OpBuilder<(ins "mlir::Value":$calleePtr, "mlir::Type":$resType,
1954-
"mlir::ValueRange":$operands), [{
1988+
"mlir::ValueRange":$operands,
1989+
CArg<"SideEffect", "SideEffect::All">:$sideEffect), [{
19551990
$_state.addOperands(calleePtr);
19561991
$_state.addOperands(operands);
19571992
if (resType && !isa<VoidType>(resType))
19581993
$_state.addTypes(resType);
1994+
$_state.addAttribute("side_effect",
1995+
SideEffectAttr::get($_builder.getContext(), sideEffect));
19591996
}]>,
19601997
];
19611998
}

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 the side effects of the call operation",
38+
"cir::SideEffect", "getSideEffect", (ins)>,
3739
];
3840
}
3941

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ struct MissingFeatures {
9595
static bool opCallReturn() { return false; }
9696
static bool opCallArgEvaluationOrder() { return false; }
9797
static bool opCallCallConv() { return false; }
98-
static bool opCallSideEffect() { return false; }
9998
static bool opCallNoPrototypeFunc() { return false; }
10099
static bool opCallMustTail() { return false; }
101100
static bool opCallVirtual() { return false; }

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:

0 commit comments

Comments
 (0)