@@ -485,40 +485,43 @@ Value *TrivialDxilOperation(OP::OpCode opcode, ArrayRef<Value *> refArgs,
485485}
486486
487487Value *TrivialDxilVectorOperation (Function *dxilFunc, OP::OpCode opcode,
488- ArrayRef<Value *> refArgs, Type *Ty,
489- OP *hlslOP, IRBuilder<> &Builder) {
488+ ArrayRef<Value *> refArgs, Type *Ty,
489+ OP *hlslOP, IRBuilder<> &Builder) {
490490 if (!Ty->isVoidTy ()) {
491491 Value *retVal =
492- Builder.CreateCall (dxilFunc, refArgs, hlslOP->GetOpCodeName (opcode));
492+ Builder.CreateCall (dxilFunc, refArgs, hlslOP->GetOpCodeName (opcode));
493493 return retVal;
494494 } else {
495495 // Cannot add name to void.
496496 return Builder.CreateCall (dxilFunc, refArgs);
497497 }
498498}
499499
500-
501- Value * TrivialDxilVectorUnaryOperationRet (OP::OpCode opcode, Value *src, Type *Ty,
502- OP *hlslOP, IRBuilder<> &Builder) {
500+ Value * TrivialDxilVectorUnaryOperationRet (OP::OpCode opcode, Value *src,
501+ Type *Ty, OP *hlslOP ,
502+ IRBuilder<> &Builder) {
503503
504504 Constant *opArg = hlslOP->GetU32Const ((unsigned )opcode);
505505 Value *args[] = {opArg, src};
506506
507507 Function *dxilFunc = hlslOP->GetOpFunc (opcode, Ty);
508508
509- return TrivialDxilVectorOperation (dxilFunc, opcode, args, Ty, hlslOP, Builder);
509+ return TrivialDxilVectorOperation (dxilFunc, opcode, args, Ty, hlslOP,
510+ Builder);
510511}
511512
512- Value *TrivialDxilVectorBinaryOperation (OP::OpCode opcode, Value *src0, Value *src1,
513- hlsl::OP *hlslOP, IRBuilder<> &Builder) {
513+ Value *TrivialDxilVectorBinaryOperation (OP::OpCode opcode, Value *src0,
514+ Value *src1, hlsl::OP *hlslOP,
515+ IRBuilder<> &Builder) {
514516 Type *Ty = src0->getType ();
515517
516518 Constant *opArg = hlslOP->GetU32Const ((unsigned )opcode);
517519 Value *args[] = {opArg, src0, src1};
518520
519521 Function *dxilFunc = hlslOP->GetOpFunc (opcode, Ty);
520522
521- return TrivialDxilVectorOperation (dxilFunc, opcode, args, Ty, hlslOP, Builder);
523+ return TrivialDxilVectorOperation (dxilFunc, opcode, args, Ty, hlslOP,
524+ Builder);
522525}
523526
524527Value *TrivialDxilUnaryOperationRet (OP::OpCode opcode, Value *src, Type *RetTy,
@@ -547,24 +550,26 @@ Value *TrivialDxilBinaryOperation(OP::OpCode opcode, Value *src0, Value *src1,
547550 return TrivialDxilOperation (opcode, args, Ty, Ty, hlslOP, Builder);
548551}
549552
550- Value *TrivialDxilTrinaryOperationRet (OP::OpCode opcode, Value *src0, Value *src1,
551- Value *src2, Type *Ty, hlsl::OP *hlslOP ,
552- IRBuilder<> &Builder) {
553+ Value *TrivialDxilTrinaryOperationRet (OP::OpCode opcode, Value *src0,
554+ Value *src1, Value *src2, Type *Ty ,
555+ hlsl::OP *hlslOP, IRBuilder<> &Builder) {
553556 Constant *opArg = hlslOP->GetU32Const ((unsigned )opcode);
554557 Value *args[] = {opArg, src0, src1, src2};
555558
556559 return TrivialDxilOperation (opcode, args, Ty, Ty, hlslOP, Builder);
557560}
558561
559- Value *TrivialDxilVectorTrinaryOperationRet (OP::OpCode opcode, Value *src0, Value *src1,
560- Value *src2, Type *Ty, hlsl::OP *hlslOP,
561- IRBuilder<> &Builder) {
562+ Value *TrivialDxilVectorTrinaryOperationRet (OP::OpCode opcode, Value *src0,
563+ Value *src1, Value *src2, Type *Ty,
564+ hlsl::OP *hlslOP,
565+ IRBuilder<> &Builder) {
562566 Constant *opArg = hlslOP->GetU32Const ((unsigned )opcode);
563567 Value *args[] = {opArg, src0, src1, src2};
564568
565569 Function *dxilFunc = hlslOP->GetOpFunc (opcode, Ty);
566570
567- return TrivialDxilVectorOperation (dxilFunc, opcode, args, Ty, hlslOP, Builder);
571+ return TrivialDxilVectorOperation (dxilFunc, opcode, args, Ty, hlslOP,
572+ Builder);
568573}
569574
570575Value *TrivialUnaryOperation (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
@@ -579,22 +584,20 @@ Value *TrivialUnaryOperation(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
579584 return retVal;
580585}
581586
582- Value *TrivialVectorizableUnaryOperation (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
583- HLOperationLowerHelper &helper ,
584- HLObjectOperationLowerHelper *pObjHelper,
585- bool &Translated) {
587+ Value *TrivialVectorizableUnaryOperation (
588+ CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode ,
589+ HLOperationLowerHelper &helper, HLObjectOperationLowerHelper *pObjHelper,
590+ bool &Translated) {
586591 Value *src0 = CI->getArgOperand (HLOperandIndex::kUnaryOpSrc0Idx );
587592 Type *Ty = CI->getType ();
588593 IRBuilder<> Builder (CI);
589594 hlsl::OP *hlslOP = &helper.hlslOP ;
590595
591- if (Ty->isVectorTy () &&
592- helper.M .GetShaderModel ()->IsSM69Plus ())
593- return TrivialDxilVectorUnaryOperationRet (opcode, src0, Ty,
594- hlslOP, Builder);
596+ if (Ty->isVectorTy () && helper.M .GetShaderModel ()->IsSM69Plus ())
597+ return TrivialDxilVectorUnaryOperationRet (opcode, src0, Ty, hlslOP,
598+ Builder);
595599 else
596- return TrivialDxilUnaryOperationRet (opcode, src0, Ty,
597- hlslOP, Builder);
600+ return TrivialDxilUnaryOperationRet (opcode, src0, Ty, hlslOP, Builder);
598601}
599602
600603Value *TrivialBinaryOperation (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
@@ -611,10 +614,11 @@ Value *TrivialBinaryOperation(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
611614 return binOp;
612615}
613616
614- Value *TrivialVectorBinaryOperation (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
615- HLOperationLowerHelper &helper,
616- HLObjectOperationLowerHelper *pObjHelper,
617- bool &Translated) {
617+ Value *TrivialVectorBinaryOperation (CallInst *CI, IntrinsicOp IOP,
618+ OP::OpCode opcode,
619+ HLOperationLowerHelper &helper,
620+ HLObjectOperationLowerHelper *pObjHelper,
621+ bool &Translated) {
618622 hlsl::OP *hlslOP = &helper.hlslOP ;
619623 Value *src0 = CI->getArgOperand (HLOperandIndex::kBinaryOpSrc0Idx );
620624 Value *src1 = CI->getArgOperand (HLOperandIndex::kBinaryOpSrc1Idx );
@@ -626,21 +630,22 @@ Value *TrivialVectorBinaryOperation(CallInst *CI, IntrinsicOp IOP, OP::OpCode op
626630}
627631
628632Value *TranslateFMA (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
629- HLOperationLowerHelper &helper,
630- HLObjectOperationLowerHelper *pObjHelper,
631- bool &Translated) {
633+ HLOperationLowerHelper &helper,
634+ HLObjectOperationLowerHelper *pObjHelper,
635+ bool &Translated) {
632636 hlsl::OP *hlslOP = &helper.hlslOP ;
633637 Type *Ty = CI->getType ();
634638 Value *src0 = CI->getArgOperand (HLOperandIndex::kTrinaryOpSrc0Idx );
635639 Value *src1 = CI->getArgOperand (HLOperandIndex::kTrinaryOpSrc1Idx );
636640 Value *src2 = CI->getArgOperand (HLOperandIndex::kTrinaryOpSrc2Idx );
637641 IRBuilder<> Builder (CI);
638642
639- if (Ty->isVectorTy () &&
640- helper. M . GetShaderModel ()-> IsSM69Plus ())
641- return TrivialDxilVectorTrinaryOperationRet (opcode, src0, src1, src2, Ty, hlslOP, Builder);
643+ if (Ty->isVectorTy () && helper. M . GetShaderModel ()-> IsSM69Plus ())
644+ return TrivialDxilVectorTrinaryOperationRet (opcode, src0, src1, src2, Ty,
645+ hlslOP, Builder);
642646 else
643- return TrivialDxilTrinaryOperationRet (opcode, src0, src1, src2, Ty, hlslOP, Builder);
647+ return TrivialDxilTrinaryOperationRet (opcode, src0, src1, src2, Ty, hlslOP,
648+ Builder);
644649}
645650
646651Value *TrivialIsSpecialFloat (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
@@ -1986,15 +1991,16 @@ Value *TranslateClamp(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
19861991
19871992 IRBuilder<> Builder (CI);
19881993 // min(max(x, minVal), maxVal).
1989- if (Ty->isVectorTy () &&
1990- helper.M .GetShaderModel ()->IsSM69Plus ()) {
1994+ if (Ty->isVectorTy () && helper.M .GetShaderModel ()->IsSM69Plus ()) {
19911995 Value *maxXMinVal =
1992- TrivialDxilVectorBinaryOperation (maxOp, x, minVal, hlslOP, Builder);
1993- return TrivialDxilVectorBinaryOperation (minOp, maxXMinVal, maxVal, hlslOP, Builder);
1996+ TrivialDxilVectorBinaryOperation (maxOp, x, minVal, hlslOP, Builder);
1997+ return TrivialDxilVectorBinaryOperation (minOp, maxXMinVal, maxVal, hlslOP,
1998+ Builder);
19941999 } else {
19952000 Value *maxXMinVal =
1996- TrivialDxilBinaryOperation (maxOp, x, minVal, hlslOP, Builder);
1997- return TrivialDxilBinaryOperation (minOp, maxXMinVal, maxVal, hlslOP, Builder);
2001+ TrivialDxilBinaryOperation (maxOp, x, minVal, hlslOP, Builder);
2002+ return TrivialDxilBinaryOperation (minOp, maxXMinVal, maxVal, hlslOP,
2003+ Builder);
19982004 }
19992005}
20002006
@@ -2308,11 +2314,12 @@ Value *TranslateExp(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
23082314 ConstantVector::getSplat (Ty->getVectorNumElements (), log2eConst);
23092315 }
23102316 val = Builder.CreateFMul (log2eConst, val);
2311- if (Ty->isVectorTy () &&
2312- helper. M . GetShaderModel ()-> IsSM69Plus ())
2313- return TrivialDxilVectorUnaryOperationRet (OP::OpCode::Exp, val, Ty, hlslOP, Builder);
2317+ if (Ty->isVectorTy () && helper. M . GetShaderModel ()-> IsSM69Plus ())
2318+ return TrivialDxilVectorUnaryOperationRet (OP::OpCode::Exp, val, Ty, hlslOP,
2319+ Builder);
23142320 else
2315- return TrivialDxilUnaryOperationRet (OP::OpCode::Exp, val, Ty, hlslOP, Builder);
2321+ return TrivialDxilUnaryOperationRet (OP::OpCode::Exp, val, Ty, hlslOP,
2322+ Builder);
23162323}
23172324
23182325Value *TranslateLog (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
@@ -2328,11 +2335,12 @@ Value *TranslateLog(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
23282335 ln2Const = ConstantVector::getSplat (Ty->getVectorNumElements (), ln2Const);
23292336 }
23302337 Value *log = nullptr ;
2331- if (Ty->isVectorTy () &&
2332- helper. M . GetShaderModel ()-> IsSM69Plus ())
2333- log = TrivialDxilVectorUnaryOperationRet (OP::OpCode::Log, val, Ty, hlslOP, Builder);
2338+ if (Ty->isVectorTy () && helper. M . GetShaderModel ()-> IsSM69Plus ())
2339+ log = TrivialDxilVectorUnaryOperationRet (OP::OpCode::Log, val, Ty, hlslOP,
2340+ Builder);
23342341 else
2335- log = TrivialDxilUnaryOperationRet (OP::OpCode::Log, val, Ty, hlslOP, Builder);
2342+ log =
2343+ TrivialDxilUnaryOperationRet (OP::OpCode::Log, val, Ty, hlslOP, Builder);
23362344
23372345 return Builder.CreateFMul (ln2Const, log);
23382346}
@@ -2392,13 +2400,12 @@ Value *TranslateFUIBinary(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
23922400 break ;
23932401 }
23942402 }
2395- if (CI->getType ()->isVectorTy () &&
2396- helper.M .GetShaderModel ()->IsSM69Plus ())
2403+ if (CI->getType ()->isVectorTy () && helper.M .GetShaderModel ()->IsSM69Plus ())
23972404 return TrivialVectorBinaryOperation (CI, IOP, opcode, helper, pObjHelper,
2398- Translated);
2405+ Translated);
23992406 else
24002407 return TrivialBinaryOperation (CI, IOP, opcode, helper, pObjHelper,
2401- Translated);
2408+ Translated);
24022409}
24032410
24042411Value *TranslateFUITrinary (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
@@ -2423,7 +2430,8 @@ Value *TranslateFUITrinary(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
24232430 Value *src2 = CI->getArgOperand (HLOperandIndex::kTrinaryOpSrc2Idx );
24242431 IRBuilder<> Builder (CI);
24252432
2426- return TrivialDxilTrinaryOperationRet (opcode, src0, src1, src2, Ty, hlslOP, Builder);
2433+ return TrivialDxilTrinaryOperationRet (opcode, src0, src1, src2, Ty, hlslOP,
2434+ Builder);
24272435}
24282436
24292437Value *TranslateFrexp (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
@@ -2547,9 +2555,8 @@ Value *TrivialDotOperation(OP::OpCode opcode, Value *src0, Value *src1,
25472555
25482556// Instead of using a DXIL intrinsic, implement a dot product operation using
25492557// multiply and add operations. Used for integer dots and long vectors.
2550- Value *ExpandDot (Value *arg0, Value *arg1, unsigned vecSize,
2551- hlsl::OP *hlslOP, IRBuilder<> &Builder,
2552- bool Unsigned = false ) {
2558+ Value *ExpandDot (Value *arg0, Value *arg1, unsigned vecSize, hlsl::OP *hlslOP,
2559+ IRBuilder<> &Builder, bool Unsigned = false ) {
25532560 auto madOpCode = Unsigned ? DXIL::OpCode::UMad : DXIL::OpCode::IMad;
25542561 if (arg0->getType ()->getScalarType ()->isFloatingPointTy ())
25552562 madOpCode = DXIL::OpCode::FMad;
@@ -2559,8 +2566,8 @@ Value *ExpandDot(Value *arg0, Value *arg1, unsigned vecSize,
25592566 for (unsigned Elt = 1 ; Elt < vecSize; ++Elt) {
25602567 Elt0 = Builder.CreateExtractElement (arg0, Elt);
25612568 Elt1 = Builder.CreateExtractElement (arg1, Elt);
2562- Result = TrivialDxilTrinaryOperationRet (madOpCode, Elt0, Elt1, Result, Elt0-> getType (), hlslOP,
2563- Builder);
2569+ Result = TrivialDxilTrinaryOperationRet (madOpCode, Elt0, Elt1, Result,
2570+ Elt0-> getType (), hlslOP, Builder);
25642571 }
25652572
25662573 return Result;
@@ -2598,11 +2605,12 @@ Value *TranslateDot(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
25982605 unsigned vecSize = Ty->getVectorNumElements ();
25992606 Value *arg1 = CI->getArgOperand (HLOperandIndex::kBinaryOpSrc1Idx );
26002607 IRBuilder<> Builder (CI);
2601- if (Ty->getScalarType ()->isFloatingPointTy () && Ty->getVectorNumElements () <= 4 ) {
2608+ if (Ty->getScalarType ()->isFloatingPointTy () &&
2609+ Ty->getVectorNumElements () <= 4 ) {
26022610 return TranslateFDot (arg0, arg1, vecSize, hlslOP, Builder);
26032611 } else {
26042612 return ExpandDot (arg0, arg1, vecSize, hlslOP, Builder,
2605- IOP == IntrinsicOp::IOP_udot);
2613+ IOP == IntrinsicOp::IOP_udot);
26062614 }
26072615}
26082616
@@ -2785,8 +2793,9 @@ Value *TranslateMSad4(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
27852793 byteSrc = Builder.CreateInsertElement (byteSrc, byteSrcElt, 3 );
27862794
27872795 // Msad on vecref and byteSrc.
2788- return TrivialDxilTrinaryOperationRet (DXIL::OpCode::Msad, vecRef, byteSrc, accum,
2789- vecRef->getType (), hlslOP, Builder);
2796+ return TrivialDxilTrinaryOperationRet (DXIL::OpCode::Msad, vecRef, byteSrc,
2797+ accum, vecRef->getType (), hlslOP,
2798+ Builder);
27902799}
27912800
27922801Value *TranslateRCP (CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
@@ -3151,7 +3160,7 @@ Value *TranslateMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
31513160 return TranslateFDot (arg0, arg1, vecSize, hlslOP, Builder);
31523161 } else {
31533162 return ExpandDot (arg0, arg1, vecSize, hlslOP, Builder,
3154- IOP == IntrinsicOp::IOP_umul);
3163+ IOP == IntrinsicOp::IOP_umul);
31553164 }
31563165 } else {
31573166 // mul(vector, scalar) == vector * scalar-splat
@@ -6554,7 +6563,8 @@ IntrinsicLower gLowerTable[] = {
65546563 {IntrinsicOp::IOP_asint16, TranslateBitcast, DXIL::OpCode::NumOpCodes},
65556564 {IntrinsicOp::IOP_asuint, TranslateAsUint, DXIL::OpCode::SplitDouble},
65566565 {IntrinsicOp::IOP_asuint16, TranslateAsUint, DXIL::OpCode::NumOpCodes},
6557- {IntrinsicOp::IOP_atan, TrivialVectorizableUnaryOperation, DXIL::OpCode::Atan},
6566+ {IntrinsicOp::IOP_atan, TrivialVectorizableUnaryOperation,
6567+ DXIL::OpCode::Atan},
65586568 {IntrinsicOp::IOP_atan2, TranslateAtan2, DXIL::OpCode::NumOpCodes},
65596569 {IntrinsicOp::IOP_ceil, TrivialUnaryOperation, DXIL::OpCode::Round_pi},
65606570 {IntrinsicOp::IOP_clamp, TranslateClamp, DXIL::OpCode::NumOpCodes},
@@ -6645,7 +6655,8 @@ IntrinsicLower gLowerTable[] = {
66456655 {IntrinsicOp::IOP_sqrt, TrivialUnaryOperation, DXIL::OpCode::Sqrt},
66466656 {IntrinsicOp::IOP_step, TranslateStep, DXIL::OpCode::NumOpCodes},
66476657 {IntrinsicOp::IOP_tan, TrivialUnaryOperation, DXIL::OpCode::Tan},
6648- {IntrinsicOp::IOP_tanh, TrivialVectorizableUnaryOperation, DXIL::OpCode::Htan},
6658+ {IntrinsicOp::IOP_tanh, TrivialVectorizableUnaryOperation,
6659+ DXIL::OpCode::Htan},
66496660 {IntrinsicOp::IOP_tex1D, EmptyLower, DXIL::OpCode::NumOpCodes},
66506661 {IntrinsicOp::IOP_tex1Dbias, EmptyLower, DXIL::OpCode::NumOpCodes},
66516662 {IntrinsicOp::IOP_tex1Dgrad, EmptyLower, DXIL::OpCode::NumOpCodes},
0 commit comments