Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/include/llvm/IR/Attributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -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]>;

Expand Down
10 changes: 8 additions & 2 deletions llvm/lib/Target/DirectX/DXIL.td
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ def CreateHandle : DXILOp<57, createHandle> {
let arguments = [Int8Ty, Int32Ty, Int32Ty, Int1Ty];
let result = HandleTy;
let stages = [Stages<DXIL1_0, [all_stages]>, Stages<DXIL1_6, [removed]>];
let attributes = [Attributes<DXIL1_0, [ReadOnly]>];
}

def BufferLoad : DXILOp<68, bufferLoad> {
Expand All @@ -716,6 +717,7 @@ def BufferLoad : DXILOp<68, bufferLoad> {
[Overloads<DXIL1_0,
[ResRetHalfTy, ResRetFloatTy, ResRetInt16Ty, ResRetInt32Ty]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadOnly]>];
}

def BufferStore : DXILOp<69, bufferStore> {
Expand All @@ -737,6 +739,7 @@ def CheckAccessFullyMapped : DXILOp<71, checkAccessFullyMapped> {
let result = Int1Ty;
let overloads = [Overloads<DXIL1_0, [Int32Ty]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadOnly]>];
}

def ThreadId : DXILOp<93, threadId> {
Expand Down Expand Up @@ -793,13 +796,15 @@ def AnnotateHandle : DXILOp<217, annotateHandle> {
let arguments = [HandleTy, ResPropsTy];
let result = HandleTy;
let stages = [Stages<DXIL1_6, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}

def CreateHandleFromBinding : DXILOp<218, createHandleFromBinding> {
let Doc = "create resource handle from binding";
let arguments = [ResBindTy, Int32Ty, Int1Ty];
let result = HandleTy;
let stages = [Stages<DXIL1_6, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}

def WaveIsFirstLane : DXILOp<110, waveIsFirstLane> {
Expand All @@ -808,7 +813,7 @@ def WaveIsFirstLane : DXILOp<110, waveIsFirstLane> {
let arguments = [];
let result = Int1Ty;
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
let attributes = [Attributes<DXIL1_0, [ReadNone, IsWave]>];
}

def WaveReadLaneAt: DXILOp<117, waveReadLaneAt> {
Expand All @@ -827,5 +832,6 @@ def WaveGetLaneIndex : DXILOp<111, waveGetLaneIndex> {
let arguments = [];
let result = Int32Ty;
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
// Lane Index can change on thread repacking. See dxc #5607 for details.
let attributes = [Attributes<DXIL1_0, [ReadOnly]>];
}
10 changes: 1 addition & 9 deletions llvm/lib/Target/DirectX/DXILOpBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct OpStage {

struct OpAttribute {
Version DXILVersion;
uint32_t ValidAttrs;
llvm::SmallVector<Attribute::AttrKind> ValidAttrs;
};

static const char *getOverloadTypeName(OverloadKind Kind) {
Expand Down Expand Up @@ -464,14 +464,6 @@ Expected<CallInst *> DXILOpBuilder::tryCreateOp(dxil::OpCode OpCode,
return IRB.CreateCall(DXILFn, OpArgs, Name);
}

CallInst *DXILOpBuilder::createOp(dxil::OpCode OpCode, ArrayRef<Value *> Args,
const Twine &Name, Type *RetTy) {
Expected<CallInst *> 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);
}
Expand Down
5 changes: 0 additions & 5 deletions llvm/lib/Target/DirectX/DXILOpBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Value *> 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<CallInst *> tryCreateOp(dxil::OpCode Op, ArrayRef<Value *> Args,
Expand Down
27 changes: 14 additions & 13 deletions llvm/utils/TableGen/DXILEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,38 +288,39 @@ static std::string getStageMaskString(ArrayRef<const Record *> 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<const Record *> Recs) {
std::string MaskString = "";
static std::string getAttributeListString(ArrayRef<const Record *> 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
Expand Down Expand Up @@ -421,7 +422,7 @@ static void emitDXILOperationTable(ArrayRef<DXILOperationDesc> Ops,
<< OpClassStrings.get(Op.OpClass.data()) << ", "
<< getOverloadMaskString(Op.OverloadRecs) << ", "
<< getStageMaskString(Op.StageRecs) << ", "
<< getAttributeMaskString(Op.AttrRecs) << ", " << Op.OverloadParamIndex
<< getAttributeListString(Op.AttrRecs) << ", " << Op.OverloadParamIndex
<< " }";
Prefix = ",\n";
}
Expand Down