Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions docs/DXIL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3209,6 +3209,7 @@ INSTR.ILLEGALDXILOPCODE DXILOpCode must be valid o
INSTR.ILLEGALDXILOPFUNCTION '%0' is not a DXILOpFuncition for DXILOpcode '%1'.
INSTR.IMMBIASFORSAMPLEB bias amount for sample_b must be in the range [%0,%1], but %2 was specified as an immediate.
INSTR.INBOUNDSACCESS Access to out-of-bounds memory is disallowed.
INSTR.LINALGILLEGALKDIM Matrix K Dimension out of bounds. K=%0 must be >= %1 and <= %2.
INSTR.MAYREORDERTHREADUNDEFCOHERENCEHINTPARAM Use of undef coherence hint or num coherence hint bits in MaybeReorderThread.
INSTR.MINPRECISIONNOTPRECISE Instructions marked precise may not refer to minprecision values.
INSTR.MINPRECISONBITCAST Bitcast on minprecison types is not allowed.
Expand Down
80 changes: 79 additions & 1 deletion lib/DxilValidation/DxilValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,54 @@ static void ValidateImmOperandForMathDxilOp(CallInst *CI, DXIL::OpCode Opcode,
}
}

static void ValidateLinAlgOpParameters(CallInst *CI,
ValidationContext &ValCtx) {
for (uint32_t Idx = 0; Idx < CI->getNumArgOperands(); ++Idx) {
Value *Arg = CI->getArgOperand(Idx);
Type *Ty = Arg->getType();

// No parameters may be undef
if (isa<UndefValue>(Arg))
ValCtx.EmitInstrError(CI, ValidationRule::InstrNoReadingUninitialized);

// If we have a LinAlg Matrix validate it
if (!dxilutil::IsHLSLLinAlgMatrixType(Ty))
continue;

// Metadata is malformed if we don't have metadata
if (ValCtx.TargetTypeMap.find(Ty) == ValCtx.TargetTypeMap.end()) {
Comment thread
V-FEXrt marked this conversation as resolved.
Outdated
ValCtx.EmitInstrError(CI, ValidationRule::MetaWellFormed);
continue;
}
}
}

static void ValidateLinAlgOpReturn(CallInst *CI, ValidationContext &ValCtx) {
Comment thread
V-FEXrt marked this conversation as resolved.
Outdated
Type *Ty = CI->getType();
assert(dxilutil::IsHLSLLinAlgMatrixType(Ty) && "CI must return a matrix");

// Metadata is malformed if we don't have metadata
auto it = ValCtx.TargetTypeMap.find(Ty);
if (it == ValCtx.TargetTypeMap.end()) {
ValCtx.EmitInstrError(CI, ValidationRule::MetaWellFormed);
return;
}

LinAlgTargetType LATT = it->second;

// Validate the K dim is in bounds. Which dim is K depends on use.
// This validation isn't applied to an accumulator matrix
if (LATT.Use != DXIL::MatrixUse::Accumulator) {
unsigned MinK = 4;
unsigned K = (LATT.Use == DXIL::MatrixUse::A) ? LATT.N : LATT.M;
unsigned MaxK = (LATT.Scope == DXIL::MatrixScope::ThreadGroup) ? 1024 : 128;
Comment thread
V-FEXrt marked this conversation as resolved.
Outdated
if (K < MinK || K > MaxK)
ValCtx.EmitInstrFormatError(
CI, ValidationRule::InstrLinAlgIllegalKDim,
{std::to_string(K), std::to_string(MinK), std::to_string(MaxK)});
}
}

// Validate the type-defined mask compared to the store value mask which
// indicates which parts were defined returns true if caller should continue
// validation
Expand Down Expand Up @@ -1713,7 +1761,7 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI,
ShaderKind = DXIL::ShaderKind::Hull;
}

// These shader models are treted like compute
// These shader models are treated like compute
bool IsCSLike = ShaderKind == DXIL::ShaderKind::Compute ||
ShaderKind == DXIL::ShaderKind::Mesh ||
ShaderKind == DXIL::ShaderKind::Amplification ||
Expand Down Expand Up @@ -2177,6 +2225,36 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI,
ValCtx.EmitInstrFormatError(CI, ValidationRule::SmIsSpecialFloat, {});
break;
}

// LinAlg Operations
case DXIL::OpCode::LinAlgMatrixLength:
case DXIL::OpCode::LinAlgMatrixGetCoordinate:
case DXIL::OpCode::LinAlgMatrixGetElement:
case DXIL::OpCode::LinAlgMatrixStoreToDescriptor:
case DXIL::OpCode::LinAlgMatrixStoreToMemory:
case DXIL::OpCode::LinAlgMatVecMul:
case DXIL::OpCode::LinAlgMatVecMulAdd:
case DXIL::OpCode::LinAlgMatrixAccumulateToDescriptor:
case DXIL::OpCode::LinAlgMatrixAccumulateToMemory:
case DXIL::OpCode::LinAlgConvert:
case DXIL::OpCode::LinAlgVectorAccumulateToDescriptor: {
ValidateLinAlgOpParameters(CI, ValCtx);
break;
}
case DXIL::OpCode::LinAlgFillMatrix:
case DXIL::OpCode::LinAlgCopyConvertMatrix:
case DXIL::OpCode::LinAlgMatrixLoadFromDescriptor:
case DXIL::OpCode::LinAlgMatrixLoadFromMemory:
case DXIL::OpCode::LinAlgMatrixSetElement:
case DXIL::OpCode::LinAlgMatrixMultiply:
case DXIL::OpCode::LinAlgMatrixAccumulate:
case DXIL::OpCode::LinAlgMatrixMultiplyAccumulate:
case DXIL::OpCode::LinAlgMatrixOuterProduct: {
ValidateLinAlgOpReturn(CI, ValCtx);
ValidateLinAlgOpParameters(CI, ValCtx);
break;
}

default:
// TODO: make sure every Opcode is checked.
// Skip opcodes don't need special check.
Expand Down
53 changes: 53 additions & 0 deletions lib/DxilValidation/DxilValidationUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include "DxilValidationUtils.h"

#include <optional>

#include "dxc/DXIL/DxilEntryProps.h"
#include "dxc/DXIL/DxilInstructions.h"
#include "dxc/DXIL/DxilModule.h"
Expand Down Expand Up @@ -39,6 +41,40 @@ EntryStatus::EntryStatus(DxilEntryProps &entryProps)
entryProps.sig.PatchConstOrPrimSignature.GetElements().size(), 0);
}

static std::optional<std::tuple<Type *, LinAlgTargetType>>
TryMakeLinAlgTargetType(MDTuple *MDT) {
Comment thread
V-FEXrt marked this conversation as resolved.
Outdated
if (!MDT || MDT->getNumOperands() != 6)
return std::nullopt;

ConstantAsMetadata *ConstMD0 =
dyn_cast<ConstantAsMetadata>(MDT->getOperand(0).get());
if (!ConstMD0)
return std::nullopt;

Type *Ty = ConstMD0->getValue()->getType();
ConstantInt *Ints[5];

for (size_t I = 0; I < 5; ++I) {
ConstantAsMetadata *ConstMDI =
dyn_cast<ConstantAsMetadata>(MDT->getOperand(I + 1).get());
if (!ConstMDI)
return std::nullopt;
ConstantInt *CI = dyn_cast<ConstantInt>(ConstMDI->getValue());
if (!CI)
return std::nullopt;
Ints[I] = CI;
}

LinAlgTargetType LATT;
LATT.Type = static_cast<DXIL::ComponentType>(Ints[0]->getLimitedValue());
LATT.M = Ints[1]->getLimitedValue();
LATT.N = Ints[2]->getLimitedValue();
LATT.Use = static_cast<DXIL::MatrixUse>(Ints[3]->getLimitedValue());
LATT.Scope = static_cast<DXIL::MatrixScope>(Ints[4]->getLimitedValue());

return {{Ty, LATT}};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(read the next comment first please ;))

This is want I have in mind:

Suggested change
ConstantInt *Ints[5];
for (size_t I = 0; I < 5; ++I) {
ConstantAsMetadata *ConstMDI =
dyn_cast<ConstantAsMetadata>(MDT->getOperand(I + 1).get());
if (!ConstMDI)
return std::nullopt;
ConstantInt *CI = dyn_cast<ConstantInt>(ConstMDI->getValue());
if (!CI)
return std::nullopt;
Ints[I] = CI;
}
LinAlgTargetType LATT;
LATT.Type = static_cast<DXIL::ComponentType>(Ints[0]->getLimitedValue());
LATT.M = Ints[1]->getLimitedValue();
LATT.N = Ints[2]->getLimitedValue();
LATT.Use = static_cast<DXIL::MatrixUse>(Ints[3]->getLimitedValue());
LATT.Scope = static_cast<DXIL::MatrixScope>(Ints[4]->getLimitedValue());
return {{Ty, LATT}};
uint64_t Ints[5];
for (size_t I = 0; I < 5; ++I) {
ConstantAsMetadata *ConstMDI =
dyn_cast<ConstantAsMetadata>(MDT->getOperand(I + 1).get());
if (!ConstMDI)
return;
ConstantInt *CI = dyn_cast<ConstantInt>(ConstMDI->getValue());
if (!CI)
return;
Ints[I] = CI->getLimitedValue();
}
auto Result = Map.try_emplace(Ty, static_cast<DXIL::ComponentType>(Ints[0]),
Ints[1], Ints[2], static_cast<DXIL::MatrixUse>(Ints[3]),
static_cast<DXIL::MatrixScope>(Ints[4]));
if (!Result.second)
;// TODO: validation error - metadata for this type already exists

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how strongly do you want the validation error for type already exists?

The map is built up during initialization/before we have access to a ValidationContext (in fact this function call is in the ValContext ctor). If we want to raise an error there, we'll need to do some rearchitecting somewhere.

}

ValidationContext::ValidationContext(Module &llvmModule, Module *DebugModule,
DxilModule &dxilModule)
: M(llvmModule), pDebugModule(DebugModule), DxilMod(dxilModule),
Expand Down Expand Up @@ -89,6 +125,23 @@ ValidationContext::ValidationContext(Module &llvmModule, Module *DebugModule,
Entry);
}
}

// Capture the TargetTypes metadata in the validation context
// if it is present and valid.
NamedMDNode *NMD = M.getNamedMetadata("dx.targetTypes");
if (NMD) {
for (llvm::MDNode *MDN : NMD->operands()) {
MDTuple *MDT = dyn_cast<MDTuple>(MDN);
std::optional<std::tuple<Type *, LinAlgTargetType>> LATTOpt =
TryMakeLinAlgTargetType(MDT);
if (!LATTOpt)
continue;
Type *Ty;
LinAlgTargetType LATT;
std::tie(Ty, LATT) = *LATTOpt;
TargetTypeMap.try_emplace(Ty, LATT);
Comment thread
bob80905 marked this conversation as resolved.
Outdated
}
}
}

void ValidationContext::PropagateResMap(Value *V, DxilResourceBase *Res) {
Expand Down
10 changes: 10 additions & 0 deletions lib/DxilValidation/DxilValidationUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Value;
class GlobalVariable;
class Instruction;
class Type;
class MDTuple;
Comment thread
V-FEXrt marked this conversation as resolved.
Outdated
} // namespace llvm

namespace hlsl {
Expand Down Expand Up @@ -63,6 +64,14 @@ struct EntryStatus {
EntryStatus(DxilEntryProps &entryProps);
};

struct LinAlgTargetType {
DXIL::ComponentType Type;
unsigned M;
unsigned N;
DXIL::MatrixUse Use;
DXIL::MatrixScope Scope;
};

struct ValidationContext {
bool Failed = false;
Module &M;
Expand All @@ -80,6 +89,7 @@ struct ValidationContext {
std::unordered_map<Value *, DxilResourceProperties> ResPropMap;
std::unordered_map<Function *, std::vector<Function *>> PatchConstantFuncMap;
std::unordered_map<Function *, std::unique_ptr<EntryStatus>> entryStatusMap;
std::unordered_map<Type *, LinAlgTargetType> TargetTypeMap;
Comment thread
V-FEXrt marked this conversation as resolved.
Outdated
bool isLibProfile;
const unsigned kDxilControlFlowHintMDKind;
const unsigned kDxilPreciseMDKind;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ void main() {
// CHECK-LABEL: define void @main()

// CHECK: call %dx.types.LinAlgMatrixC4M5N4U1S2 @dx.op.linAlgCopyConvertMatrix.mC4M5N4U1S2.mC2M5N4U1S2
// CHECK-SAME: (i32 -2147483635, %dx.types.LinAlgMatrixC2M5N4U1S2 {{.*}}, i1 false)
// CHECK-SAME: (i32 -2147483635, %dx.types.LinAlgMatrixC2M5N4U1S2 %{{.*}}, i1 false)
// CHECK-SAME: ; LinAlgCopyConvertMatrix(srcMatrix,transpose)

// CHECK2: call void @"dx.hl.op..void (i32, %dx.types.LinAlgMatrixC4M5N4U1S2*, %dx.types.LinAlgMatrixC2M5N4U1S2, i1)"
// CHECK2-SAME: (i32 401, %dx.types.LinAlgMatrixC4M5N4U1S2* {{.*}}, %dx.types.LinAlgMatrixC2M5N4U1S2 {{.*}}, i1 false)
// CHECK2-SAME: (i32 401, %dx.types.LinAlgMatrixC4M5N4U1S2* %{{.*}}, %dx.types.LinAlgMatrixC2M5N4U1S2 {{.*}}, i1 false)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(2, 5, 4, 1, 2)]] mat1;
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat2;

__builtin_LinAlg_FillMatrix(mat1, 1);

__builtin_LinAlg_CopyConvertMatrix(mat2, mat1, false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
void main() {
// CHECK-LABEL: define void @main()

__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(5, 3, 4, 0, 0)]] mat1;
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(1, 1, 1, 0, 0)]] mat2;
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(2, 2, 2, 2, 2)]] mat3;

// CHECK: call %dx.types.LinAlgMatrixC2M2N2U2S2 @dx.op.linAlgMatrixAccumulate.mC2M2N2U2S2.mC1M1N1U0S0.mC5M3N4U0S
// CHECK-SAME: (i32 -2147483624, %dx.types.LinAlgMatrixC1M1N1U0S0 {{.*}}, %dx.types.LinAlgMatrixC5M3N4U0S0 {{.*}}) ; LinAlgMatrixAccumulate(matrixLHS,matrixRHS)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(5, 4, 4, 0, 0)]] mat1;
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(5, 4, 4, 0, 0)]] mat2;
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(5, 4, 4, 0, 0)]] mat3;

// CHECK2: call void @"dx.hl.op..void (i32, %dx.types.LinAlgMatrixC2M2N2U2S2*, %dx.types.LinAlgMatrixC1M1N1U0S0,
// CHECK2-SAME: %dx.types.LinAlgMatrixC5M3N4U0S0)"(i32 411, %dx.types.LinAlgMatrixC2M2N2U2S2* %mat3,
// CHECK2-SAME: %dx.types.LinAlgMatrixC1M1N1U0S0 %{{[0-9]+}}, %dx.types.LinAlgMatrixC5M3N4U0S0 %{{[0-9]+}})
__builtin_LinAlg_FillMatrix(mat1, 1);
__builtin_LinAlg_FillMatrix(mat2, 2);

// CHECK: call %dx.types.LinAlgMatrixC5M4N4U0S0 @dx.op.linAlgMatrixAccumulate.mC5M4N4U0S0.mC5M4N4U0S0.mC5M4N4U0S0
// CHECK-SAME: (i32 -2147483624, %dx.types.LinAlgMatrixC5M4N4U0S0 %{{.*}}, %dx.types.LinAlgMatrixC5M4N4U0S0 %{{.*}}) ; LinAlgMatrixAccumulate(matrixLHS,matrixRHS)

// CHECK2: call void @"dx.hl.op..void (i32, %dx.types.LinAlgMatrixC5M4N4U0S0*, %dx.types.LinAlgMatrixC5M4N4U0S0,
// CHECK2-SAME: %dx.types.LinAlgMatrixC5M4N4U0S0)"(i32 411, %dx.types.LinAlgMatrixC5M4N4U0S0* %mat3,
// CHECK2-SAME: %dx.types.LinAlgMatrixC5M4N4U0S0 %{{[0-9]+}}, %dx.types.LinAlgMatrixC5M4N4U0S0 %{{[0-9]+}})
__builtin_LinAlg_MatrixAccumulate(mat3, mat2, mat1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ void main() {
// CHECK-LABEL: define void @main()

// CHECK: call void @dx.op.linAlgMatrixAccumulateToDescriptor.mC4M5N4U1S2(i32 -2147483621,
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, %dx.types.Handle %{{.*}}, i32 5, i32 5, i32 5, i32 4)
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, %dx.types.Handle %{{.*}}, i32 5, i32 5, i32 5, i32 4)
// CHECK-SAME: ; LinAlgMatrixAccumulateToDescriptor(matrix,handle,offset,stride,layout,align)

// CHECK2: call void @"dx.hl.op..void (i32, %dx.types.LinAlgMatrixC4M5N4U1S2, %dx.types.Handle, i32, i32, i32, i32)"
// CHECK2-SAME: (i32 415, %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, %dx.types.Handle {{.*}}, i32 5, i32 5, i32 5, i32 4)
// CHECK2-SAME: (i32 415, %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, %dx.types.Handle {{.*}}, i32 5, i32 5, i32 5, i32 4)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_FillMatrix(mat, 1);
__builtin_LinAlg_MatrixAccumulateToDescriptor(mat, outbuf, 5, 5, 5, 4);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ void main() {
// CHECK-LABEL: define void @main()

// CHECK: call void @dx.op.linAlgMatrixAccumulateToMemory.mC4M5N4U1S2.f32(i32 -2147483620,
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, float addrspace(3)* getelementptr inbounds ([64 x float],
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, float addrspace(3)* getelementptr inbounds ([64 x float],
// CHECK-SAME: [64 x float] addrspace(3)* @"\01?SharedArr@@3PAMA", i32 0, i32 0), i32 1, i32 2, i32 3)
// CHECK-SAME: ; LinAlgMatrixAccumulateToMemory(matrix,memory,offset,stride,layout)

// CHECK2: call void @"dx.hl.op..void (i32, %dx.types.LinAlgMatrixC4M5N4U1S2,
// CHECK2-SAME: [64 x float] addrspace(3)*, i32, i32, i32)"(i32 416,
// CHECK2-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, [64 x float] addrspace(3)* @"\01?SharedArr@@3PAMA",
// CHECK2-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, [64 x float] addrspace(3)* @"\01?SharedArr@@3PAMA",
// CHECK2-SAME: i32 1, i32 2, i32 3)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_FillMatrix(mat, 1);
__builtin_LinAlg_MatrixAccumulateToMemory(mat, SharedArr, 1, 2, 3);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ void main() {
// CHECK-LABEL: define void @main()

// CHECK: call <2 x i32> @dx.op.linAlgMatrixGetCoordinate.mC4M5N4U1S2(i32 -2147483631,
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 1)
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 1)
// CHECK-SAME: ; LinAlgMatrixGetCoordinate(matrix,threadLocalIndex)

// CHECK2: call <2 x i32> @"dx.hl.op..<2 x i32> (i32, %dx.types.LinAlgMatrixC4M5N4U1S2, i32)"
// CHECK2-SAME: (i32 403, %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 1)
// CHECK2-SAME: (i32 403, %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 1)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_FillMatrix(mat, 1);
uint2 coord = __builtin_LinAlg_MatrixGetCoordinate(mat, 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,40 @@ void main() {
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;

// CHECK: call i32 @dx.op.linAlgMatrixGetElement.i32.mC4M5N4U1S2(i32 -2147483630,
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 0)
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 0)
// CHECK-SAME: ; LinAlgMatrixGetElement(matrix,threadLocalIndex)

// CHECK2: call void @"dx.hl.op..void (i32, i32*, %dx.types.LinAlgMatrixC4M5N4U1S2, i32)"
// CHECK2-SAME: (i32 404, i32* %elem1, %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 0)
// CHECK2-SAME: (i32 404, i32* %elem1, %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 0)
uint elem1;
__builtin_LinAlg_FillMatrix(mat, 1);
__builtin_LinAlg_MatrixGetElement(elem1, mat, 0);

// CHECK: call float @dx.op.linAlgMatrixGetElement.f32.mC4M5N4U1S2(i32 -2147483630,
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 1)
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 1)
// CHECK-SAME: ; LinAlgMatrixGetElement(matrix,threadLocalIndex)

// CHECK2: call void @"dx.hl.op..void (i32, float*, %dx.types.LinAlgMatrixC4M5N4U1S2, i32)"
// CHECK2-SAME: (i32 404, float* %elem2, %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 1)
// CHECK2-SAME: (i32 404, float* %elem2, %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 1)
float elem2;
__builtin_LinAlg_MatrixGetElement(elem2, mat, 1);

// CHECK: call double @dx.op.linAlgMatrixGetElement.f64.mC4M5N4U1S2(i32 -2147483630,
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 1)
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 1)
// CHECK-SAME: ; LinAlgMatrixGetElement(matrix,threadLocalIndex)

// CHECK2: call void @"dx.hl.op..void (i32, double*, %dx.types.LinAlgMatrixC4M5N4U1S2, i32)"
// CHECK2-SAME: (i32 404, double* %elem3, %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 1)
// CHECK2-SAME: (i32 404, double* %elem3, %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 1)
double elem3;
__builtin_LinAlg_MatrixGetElement(elem3, mat, 1);


// CHECK: call i64 @dx.op.linAlgMatrixGetElement.i64.mC4M5N4U1S2(i32 -2147483630,
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 1)
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 1)
// CHECK-SAME: ; LinAlgMatrixGetElement(matrix,threadLocalIndex)

// CHECK2: call void @"dx.hl.op..void (i32, i64*, %dx.types.LinAlgMatrixC4M5N4U1S2, i32)"
// CHECK2-SAME: (i32 404, i64* %elem4, %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, i32 1)
// CHECK2-SAME: (i32 404, i64* %elem4, %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}, i32 1)
int64_t elem4;
__builtin_LinAlg_MatrixGetElement(elem4, mat, 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ void main() {
// CHECK-LABEL: define void @main()

// CHECK: call i32 @dx.op.linAlgMatrixLength.mC4M5N4U1S2(i32 -2147483632,
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}) ; LinAlgMatrixLength(matrix)
// CHECK-SAME: %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}}) ; LinAlgMatrixLength(matrix)

// CHECK2: call i32 @"dx.hl.op..i32 (i32, %dx.types.LinAlgMatrixC4M5N4U1S2)"
// CHECK2-SAME: (i32 405, %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}})
// CHECK2-SAME: (i32 405, %dx.types.LinAlgMatrixC4M5N4U1S2 %{{.*}})
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_FillMatrix(mat, 1);
uint len = __builtin_LinAlg_MatrixLength(mat);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ ByteAddressBuffer inbuf;
void main() {
// CHECK-LABEL: define void @main()

// CHECK: %{{.*}} = call %dx.types.LinAlgMatrixC1M1N1U0S0 @dx.op.linAlgMatrixLoadFromDescriptor.mC1M1N1U0S0
// CHECK: %{{.*}} = call %dx.types.LinAlgMatrixC1M4N4U0S0 @dx.op.linAlgMatrixLoadFromDescriptor.mC1M4N4U0S0
// CHECK-SAME: (i32 -2147483634, %dx.types.Handle %{{.*}}, i32 0, i32 0, i32 0, i32 4)
// CHECK-SAME: ; LinAlgMatrixLoadFromDescriptor(handle,offset,stride,layout,align)

// CHECK2: call void @"dx.hl.op..void (i32, %dx.types.LinAlgMatrixC1M1N1U0S0*, %dx.types.Handle, i32, i32, i32, i32)
// CHECK2-SAME: "(i32 406, %dx.types.LinAlgMatrixC1M1N1U0S0* %mat, %dx.types.Handle {{.*}}, i32 0, i32 0, i32 0, i32 4)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(1, 1, 1, 0, 0)]] mat;
// CHECK2: call void @"dx.hl.op..void (i32, %dx.types.LinAlgMatrixC1M4N4U0S0*, %dx.types.Handle, i32, i32, i32, i32)
// CHECK2-SAME: "(i32 406, %dx.types.LinAlgMatrixC1M4N4U0S0* %mat, %dx.types.Handle {{.*}}, i32 0, i32 0, i32 0, i32 4)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(1, 4, 4, 0, 0)]] mat;
__builtin_LinAlg_MatrixLoadFromDescriptor(mat, inbuf, 0, 0, 0, 4);
}
Loading
Loading