diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td index 49f4527bde66e..cb699cc3ea16d 100644 --- a/llvm/include/llvm/IR/Attributes.td +++ b/llvm/include/llvm/IR/Attributes.td @@ -153,6 +153,9 @@ def InlineHint : EnumAttr<"inlinehint", IntersectAnd, [FnAttr]>; /// Force argument to be passed in register. def InReg : EnumAttr<"inreg", IntersectPreserve, [ParamAttr, RetAttr]>; +/// Function involves wave operations. +def IsWave: EnumAttr<"iswave", IntersectAnd, [FnAttr]>; + /// Build jump-instruction tables and replace refs. def JumpTable : EnumAttr<"jumptable", IntersectPreserve, [FnAttr]>; diff --git a/llvm/lib/Target/DirectX/DXIL.td b/llvm/lib/Target/DirectX/DXIL.td index 1e8dc63ffa257..d316b99dc104b 100644 --- a/llvm/lib/Target/DirectX/DXIL.td +++ b/llvm/lib/Target/DirectX/DXIL.td @@ -705,6 +705,7 @@ def CreateHandle : DXILOp<57, createHandle> { let arguments = [Int8Ty, Int32Ty, Int32Ty, Int1Ty]; let result = HandleTy; let stages = [Stages, Stages]; + let attributes = [Attributes]; } def BufferLoad : DXILOp<68, bufferLoad> { @@ -716,6 +717,7 @@ def BufferLoad : DXILOp<68, bufferLoad> { [Overloads]; let stages = [Stages]; + let attributes = [Attributes]; } def BufferStore : DXILOp<69, bufferStore> { @@ -737,6 +739,7 @@ def CheckAccessFullyMapped : DXILOp<71, checkAccessFullyMapped> { let result = Int1Ty; let overloads = [Overloads]; let stages = [Stages]; + let attributes = [Attributes]; } def ThreadId : DXILOp<93, threadId> { @@ -793,6 +796,7 @@ def AnnotateHandle : DXILOp<217, annotateHandle> { let arguments = [HandleTy, ResPropsTy]; let result = HandleTy; let stages = [Stages]; + let attributes = [Attributes]; } def CreateHandleFromBinding : DXILOp<218, createHandleFromBinding> { @@ -800,6 +804,7 @@ def CreateHandleFromBinding : DXILOp<218, createHandleFromBinding> { let arguments = [ResBindTy, Int32Ty, Int1Ty]; let result = HandleTy; let stages = [Stages]; + let attributes = [Attributes]; } def WaveIsFirstLane : DXILOp<110, waveIsFirstLane> { @@ -808,7 +813,7 @@ def WaveIsFirstLane : DXILOp<110, waveIsFirstLane> { let arguments = []; let result = Int1Ty; let stages = [Stages]; - let attributes = [Attributes]; + let attributes = [Attributes]; } def WaveReadLaneAt: DXILOp<117, waveReadLaneAt> { @@ -827,5 +832,6 @@ def WaveGetLaneIndex : DXILOp<111, waveGetLaneIndex> { let arguments = []; let result = Int32Ty; let stages = [Stages]; - let attributes = [Attributes]; + // Lane Index can change on thread repacking. See dxc #5607 for details. + let attributes = [Attributes]; } diff --git a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp index 5d5bb3eacace2..64ce704372faf 100644 --- a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp +++ b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp @@ -54,7 +54,7 @@ struct OpStage { struct OpAttribute { Version DXILVersion; - uint32_t ValidAttrs; + llvm::SmallVector ValidAttrs; }; static const char *getOverloadTypeName(OverloadKind Kind) { @@ -464,14 +464,6 @@ Expected DXILOpBuilder::tryCreateOp(dxil::OpCode OpCode, return IRB.CreateCall(DXILFn, OpArgs, Name); } -CallInst *DXILOpBuilder::createOp(dxil::OpCode OpCode, ArrayRef Args, - const Twine &Name, Type *RetTy) { - Expected Result = tryCreateOp(OpCode, Args, Name, RetTy); - if (Error E = Result.takeError()) - llvm_unreachable("Invalid arguments for operation"); - return *Result; -} - StructType *DXILOpBuilder::getResRetType(Type *ElementTy) { return ::getResRetType(ElementTy); } diff --git a/llvm/lib/Target/DirectX/DXILOpBuilder.h b/llvm/lib/Target/DirectX/DXILOpBuilder.h index df5a0240870f4..78eb511a28bf9 100644 --- a/llvm/lib/Target/DirectX/DXILOpBuilder.h +++ b/llvm/lib/Target/DirectX/DXILOpBuilder.h @@ -36,11 +36,6 @@ class DXILOpBuilder { IRBuilder<> &getIRB() { return IRB; } - /// Create a call instruction for the given DXIL op. The arguments - /// must be valid for an overload of the operation. - CallInst *createOp(dxil::OpCode Op, ArrayRef Args, - const Twine &Name = "", Type *RetTy = nullptr); - /// Try to create a call instruction for the given DXIL op. Fails if the /// overload is invalid. Expected tryCreateOp(dxil::OpCode Op, ArrayRef Args, diff --git a/llvm/utils/TableGen/DXILEmitter.cpp b/llvm/utils/TableGen/DXILEmitter.cpp index 467a6163ae3b0..bab8fdea681cd 100644 --- a/llvm/utils/TableGen/DXILEmitter.cpp +++ b/llvm/utils/TableGen/DXILEmitter.cpp @@ -288,38 +288,39 @@ static std::string getStageMaskString(ArrayRef Recs) { /// \return std::string string representation of stages mask string /// predicated by DXIL Version. E.g., // {{{1, 0}, Mask1}, {{1, 2}, Mask2}, ...} -static std::string getAttributeMaskString(ArrayRef Recs) { - std::string MaskString = ""; +static std::string getAttributeListString(ArrayRef Recs) { + std::string ListString = ""; std::string Prefix = ""; - MaskString.append("{"); + ListString.append("{"); for (auto Rec : Recs) { unsigned Major = Rec->getValueAsDef("dxil_version")->getValueAsInt("Major"); unsigned Minor = Rec->getValueAsDef("dxil_version")->getValueAsInt("Minor"); - MaskString.append(Prefix) + ListString.append(Prefix) .append("{{") .append(std::to_string(Major)) .append(", ") - .append(std::to_string(Minor).append("}, ")); + .append(std::to_string(Minor).append("}, {")); - std::string PipePrefix = ""; + std::string CommaPrefix = ""; auto Attrs = Rec->getValueAsListOfDefs("op_attrs"); if (Attrs.empty()) { - MaskString.append("Attribute::None"); + ListString.append("Attribute::None"); } else { for (const auto *Attr : Attrs) { - MaskString.append(PipePrefix) + ListString.append(CommaPrefix) .append("Attribute::") .append(Attr->getName()); - PipePrefix = " | "; + CommaPrefix = ", "; } + ListString.append("}"); // End attribute. } - MaskString.append("}"); + ListString.append("}"); // End Rec. Prefix = ", "; } - MaskString.append("}"); - return MaskString; + ListString.append("}"); // End List.; + return ListString; } /// Emit a mapping of DXIL opcode to opname @@ -421,7 +422,7 @@ static void emitDXILOperationTable(ArrayRef Ops, << OpClassStrings.get(Op.OpClass.data()) << ", " << getOverloadMaskString(Op.OverloadRecs) << ", " << getStageMaskString(Op.StageRecs) << ", " - << getAttributeMaskString(Op.AttrRecs) << ", " << Op.OverloadParamIndex + << getAttributeListString(Op.AttrRecs) << ", " << Op.OverloadParamIndex << " }"; Prefix = ",\n"; }