Skip to content

Commit be85207

Browse files
committed
WIP: Addressed PR feedback
1 parent c2b3fd3 commit be85207

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

clang/lib/CodeGen/CGHLSLBuiltins.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,18 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
380380
getDotProductIntrinsic(CGM.getHLSLRuntime(), VecTy0->getElementType()),
381381
ArrayRef<Value *>{Op0, Op1}, nullptr, "hlsl.dot");
382382
}
383+
case Builtin::BI__builtin_hlsl_dot2add: {
384+
llvm::Triple::ArchType Arch = CGM.getTarget().getTriple().getArch();
385+
assert(Arch == llvm::Triple::dxil && "Intrinsic dot2add is only allowed for dxil architecture");
386+
Value *A = EmitScalarExpr(E->getArg(0));
387+
Value *B = EmitScalarExpr(E->getArg(1));
388+
Value *C = EmitScalarExpr(E->getArg(2));
389+
390+
Intrinsic::ID ID = llvm ::Intrinsic::dx_dot2add;
391+
return Builder.CreateIntrinsic(
392+
/*ReturnType=*/C->getType(), ID, ArrayRef<Value *>{A, B, C}, nullptr,
393+
"dx.dot2add");
394+
}
383395
case Builtin::BI__builtin_hlsl_dot4add_i8packed: {
384396
Value *A = EmitScalarExpr(E->getArg(0));
385397
Value *B = EmitScalarExpr(E->getArg(1));

clang/test/CodeGenHLSL/builtins/dot2add.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Test basic lowering to runtime function call.
99

1010
// CHECK-LABEL: define {{.*}}test
11-
float test(half2 p1, half2 p2, float p3) {
11+
float test_default_parameter(half2 p1, half2 p2, float p3) {
1212
// CHECK-SPIRV: %[[RES:.*]] = call {{.*}} float @_ZN4hlsl7dot2addEDv2_DhS0_f(<2 x half> {{.*}} %1, <2 x half> {{.*}} %2, float {{.*}} %3) #3 {{.*}}
1313
// CHECK-DXIL: %[[RES:.*]] = call {{.*}} float @_ZN4hlsl7dot2addEDv2_DhS0_f(<2 x half> {{.*}} %0, <2 x half> {{.*}} %1, float {{.*}} %2) #2
1414
// CHECK: ret float %[[RES]]

0 commit comments

Comments
 (0)