From 75bb05ed473686d319356a33340ac0ae02ffdb63 Mon Sep 17 00:00:00 2001 From: anupamac Date: Wed, 26 Mar 2025 10:56:40 -0700 Subject: [PATCH 01/93] Implement MulAdd, OutProdAcc, VecAcc lowering --- docs/DXIL.rst | 699 ++-- include/dxc/DXIL/DxilConstants.h | 630 ++- include/dxc/DXIL/DxilInstructions.h | 2340 ++++------- include/dxc/HLSL/HLOperations.h | 46 + include/dxc/HlslIntrinsicOp.h | 10 +- lib/DXIL/DxilOperations.cpp | 6055 +++++---------------------- lib/DXIL/DxilShaderModel.cpp | 246 +- lib/HLSL/HLOperationLower.cpp | 153 + utils/hct/gen_intrin_main.txt | 8 + utils/hct/hctdb.py | 92 +- 10 files changed, 3065 insertions(+), 7214 deletions(-) diff --git a/docs/DXIL.rst b/docs/DXIL.rst index a68e31d0a9..3e1d884285 100644 --- a/docs/DXIL.rst +++ b/docs/DXIL.rst @@ -1984,54 +1984,57 @@ The following LLVM instructions are valid in a DXIL program, with the specified .. hctdb_instrhelp.get_instrs_rst() .. INSTR-RST:BEGIN -============= ======================================================================= ================= -Instruction Action Operand overloads -============= ======================================================================= ================= -Ret returns a value (possibly void), from a function. vhfd1wil -Br branches (conditional or unconditional) -Switch performs a multiway switch -Add returns the sum of its two operands wil -FAdd returns the sum of its two operands hfd -Sub returns the difference of its two operands wil -FSub returns the difference of its two operands hfd -Mul returns the product of its two operands wil -FMul returns the product of its two operands hfd -UDiv returns the quotient of its two unsigned operands wil -SDiv returns the quotient of its two signed operands wil -FDiv returns the quotient of its two operands hfd -URem returns the remainder from the unsigned division of its two operands wil -SRem returns the remainder from the signed division of its two operands wil -FRem returns the remainder from the division of its two operands hfd -Shl shifts left (logical) wil -LShr shifts right (logical), with zero bit fill wil -AShr shifts right (arithmetic), with 'a' operand sign bit fill wil -And returns a bitwise logical and of its two operands 1wil -Or returns a bitwise logical or of its two operands 1wil -Xor returns a bitwise logical xor of its two operands 1wil -Alloca allocates memory on the stack frame of the currently executing function -Load reads from memory -Store writes to memory -GetElementPtr gets the address of a subelement of an aggregate value -AtomicCmpXchg atomically modifies memory -AtomicRMW atomically modifies memory -Trunc truncates an integer 1wil -ZExt zero extends an integer 1wil -SExt sign extends an integer 1wil -FPToUI converts a floating point to UInt hfd1wil -FPToSI converts a floating point to SInt hfd1wil -UIToFP converts a UInt to floating point hfd1wil -SIToFP converts a SInt to floating point hfd1wil -FPTrunc truncates a floating point hfd -FPExt extends a floating point hfd -BitCast performs a bit-preserving type cast hfd1wil -AddrSpaceCast casts a value addrspace -ICmp compares integers 1wil -FCmp compares floating points hfd -PHI is a PHI node instruction -Call calls a function -Select selects an instruction -ExtractValue extracts from aggregate -============= ======================================================================= ================= +============== ======================================================================= ================= +Instruction Action Operand overloads +============== ======================================================================= ================= +Ret returns a value (possibly void), from a function. vhfd1wil +Br branches (conditional or unconditional) +Switch performs a multiway switch +Add returns the sum of its two operands wil +FAdd returns the sum of its two operands hfd +Sub returns the difference of its two operands wil +FSub returns the difference of its two operands hfd +Mul returns the product of its two operands wil +FMul returns the product of its two operands hfd +UDiv returns the quotient of its two unsigned operands wil +SDiv returns the quotient of its two signed operands wil +FDiv returns the quotient of its two operands hfd +URem returns the remainder from the unsigned division of its two operands wil +SRem returns the remainder from the signed division of its two operands wil +FRem returns the remainder from the division of its two operands hfd +Shl shifts left (logical) wil +LShr shifts right (logical), with zero bit fill wil +AShr shifts right (arithmetic), with 'a' operand sign bit fill wil +And returns a bitwise logical and of its two operands 1wil +Or returns a bitwise logical or of its two operands 1wil +Xor returns a bitwise logical xor of its two operands 1wil +Alloca allocates memory on the stack frame of the currently executing function +Load reads from memory +Store writes to memory +GetElementPtr gets the address of a subelement of an aggregate value +AtomicCmpXchg atomically modifies memory +AtomicRMW atomically modifies memory +Trunc truncates an integer 1wil +ZExt zero extends an integer 1wil +SExt sign extends an integer 1wil +FPToUI converts a floating point to UInt hfd1wil +FPToSI converts a floating point to SInt hfd1wil +UIToFP converts a UInt to floating point hfd1wil +SIToFP converts a SInt to floating point hfd1wil +FPTrunc truncates a floating point hfd +FPExt extends a floating point hfd +BitCast performs a bit-preserving type cast hfd1wil +AddrSpaceCast casts a value addrspace +ICmp compares integers 1wil +FCmp compares floating points hfd +PHI is a PHI node instruction +Call calls a function +Select selects an instruction +ExtractElement extracts from vector +InsertElement inserts into vector +ShuffleVector Shuffle two vectors +ExtractValue extracts from aggregate +============== ======================================================================= ================= FAdd @@ -2369,6 +2372,57 @@ ID Name Description 255 SampleCmpBias samples a texture after applying the input bias to the mipmap level and compares a single component against the specified comparison value 256 StartVertexLocation returns the BaseVertexLocation from DrawIndexedInstanced or StartVertexLocation from DrawInstanced 257 StartInstanceLocation returns the StartInstanceLocation from Draw*Instanced +258 AllocateRayQuery2 allocates space for RayQuery and return handle +259 ReservedA0 reserved +260 ReservedA1 reserved +261 ReservedA2 reserved +262 ReservedB0 reserved +263 ReservedB1 reserved +264 ReservedB2 reserved +265 HitObject_MakeMiss Creates a new HitObject representing a miss +266 HitObject_MakeNop Creates an empty nop HitObject +267 ReservedB5 reserved +268 ReservedB6 reserved +269 ReservedB7 reserved +270 ReservedB8 reserved +271 ReservedB9 reserved +272 ReservedB10 reserved +273 ReservedB11 reserved +274 ReservedB12 reserved +275 ReservedB13 reserved +276 ReservedB14 reserved +277 ReservedB15 reserved +278 ReservedB16 reserved +279 ReservedB17 reserved +280 ReservedB18 reserved +281 ReservedB19 reserved +282 ReservedB20 reserved +283 ReservedB21 reserved +284 ReservedB22 reserved +285 ReservedB23 reserved +286 ReservedB24 reserved +287 ReservedB25 reserved +288 ReservedB26 reserved +289 ReservedB27 reserved +290 ReservedB28 reserved +291 ReservedB29 reserved +292 ReservedB30 reserved +293 ReservedC0 reserved +294 ReservedC1 reserved +295 ReservedC2 reserved +296 ReservedC3 reserved +297 ReservedC4 reserved +298 ReservedC5 reserved +299 ReservedC6 reserved +300 ReservedC7 reserved +301 ReservedC8 reserved +302 ReservedC9 reserved +303 RawBufferVectorLoad reads from a raw buffer and structured buffer +304 RawBufferVectorStore writes to a RWByteAddressBuffer or RWStructuredBuffer +305 MatVecMul Matrix-Vector Multiply +306 MatVecMulAdd Matrix-Vector Multiply Add +307 OuterProductAccumulate Outer Product Accumulate +308 VectorAccumulate Vector Accumulate === ===================================================== ======================================================================================================================================================================================================================= @@ -3015,277 +3069,284 @@ The set of validation rules that are known to hold for a DXIL program is identif .. hctdb_instrhelp.get_valrules_rst() .. VALRULES-RST:BEGIN -========================================= ======================================================================================================================================================================================================================================================================================================== -Rule Code Description -========================================= ======================================================================================================================================================================================================================================================================================================== -BITCODE.VALID Module must be bitcode-valid -CONTAINER.PARTINVALID DXIL Container must not contain unknown parts -CONTAINER.PARTMATCHES DXIL Container Parts must match Module -CONTAINER.PARTMISSING DXIL Container requires certain parts, corresponding to module -CONTAINER.PARTREPEATED DXIL Container must have only one of each part type -CONTAINER.ROOTSIGNATUREINCOMPATIBLE Root Signature in DXIL Container must be compatible with shader -DECL.ATTRSTRUCT Attributes parameter must be struct type -DECL.DXILFNEXTERN External function must be a DXIL function -DECL.DXILNSRESERVED The DXIL reserved prefixes must only be used by built-in functions and types -DECL.EXTRAARGS Extra arguments not allowed for shader functions -DECL.FNATTRIBUTE Functions should only contain known function attributes -DECL.FNFLATTENPARAM Function parameters must not use struct types -DECL.FNISCALLED Functions can only be used by call instructions -DECL.MULTIPLENODEINPUTS A node shader may not have more than one input record -DECL.NODELAUNCHINPUTTYPE Invalid input record type for node launch type -DECL.NOTUSEDEXTERNAL External declaration should not be used -DECL.PARAMSTRUCT Callable function parameter must be struct type -DECL.PAYLOADSTRUCT Payload parameter must be struct type -DECL.RAYQUERYINFNSIG Rayquery objects not allowed in function signatures -DECL.RESOURCEINFNSIG Resources not allowed in function signatures -DECL.SHADERMISSINGARG payload/params/attributes parameter is required for certain shader types -DECL.SHADERRETURNVOID Shader functions must return void -DECL.USEDEXTERNALFUNCTION External function must be used -DECL.USEDINTERNAL Internal declaration must be used -FLOW.DEADLOOP Loop must have break. -FLOW.FUNCTIONCALL Function with parameter is not permitted -FLOW.NORECURSION Recursion is not permitted. -FLOW.REDUCIBLE Execution flow must be reducible. -INSTR.ALLOWED Instructions must be of an allowed type. -INSTR.ATOMICCONST Constant destination to atomic. -INSTR.ATOMICINTRINNONUAV Non-UAV destination to atomic intrinsic. -INSTR.ATOMICOPNONGROUPSHAREDORRECORD Non-groupshared or node record destination to atomic operation. -INSTR.ATTRIBUTEATVERTEXNOINTERPOLATION Attribute %0 must have nointerpolation mode in order to use GetAttributeAtVertex function. -INSTR.BARRIERFLAGINVALID Invalid %0 flags on DXIL operation '%1' -INSTR.BARRIERMODEFORNONCS sync in a non-Compute/Amplification/Mesh/Node Shader must only sync UAV (sync_uglobal). -INSTR.BARRIERMODENOMEMORY sync must include some form of memory barrier - _u (UAV) and/or _g (Thread Group Shared Memory). Only _t (thread group sync) is optional. -INSTR.BARRIERMODEUSELESSUGROUP sync can't specify both _ugroup and _uglobal. If both are needed, just specify _uglobal. -INSTR.BARRIERNONCONSTANTFLAGARGUMENT Memory type, access, or sync flag is not constant -INSTR.BARRIERREQUIRESNODE sync in a non-Node Shader must not sync node record memory. -INSTR.BUFFERUPDATECOUNTERONRESHASCOUNTER BufferUpdateCounter valid only when HasCounter is true. -INSTR.BUFFERUPDATECOUNTERONUAV BufferUpdateCounter valid only on UAV. -INSTR.CALLOLOAD Call to DXIL intrinsic must match overload signature -INSTR.CANNOTPULLPOSITION pull-model evaluation of position disallowed -INSTR.CBUFFERCLASSFORCBUFFERHANDLE Expect Cbuffer for CBufferLoad handle. -INSTR.CBUFFEROUTOFBOUND Cbuffer access out of bound. -INSTR.CHECKACCESSFULLYMAPPED CheckAccessFullyMapped should only be used on resource status. -INSTR.COORDINATECOUNTFORRAWTYPEDBUF raw/typed buffer don't need 2 coordinates. -INSTR.COORDINATECOUNTFORSTRUCTBUF structured buffer require 2 coordinates. -INSTR.CREATEHANDLEIMMRANGEID Local resource must map to global resource. -INSTR.DXILSTRUCTUSER Dxil struct types should only be used by ExtractValue. -INSTR.DXILSTRUCTUSEROUTOFBOUND Index out of bound when extract value from dxil struct types. -INSTR.EVALINTERPOLATIONMODE Interpolation mode on %0 used with eval_* instruction must be linear, linear_centroid, linear_noperspective, linear_noperspective_centroid, linear_sample or linear_noperspective_sample. -INSTR.EXTRACTVALUE ExtractValue should only be used on dxil struct types and cmpxchg. -INSTR.FAILTORESLOVETGSMPOINTER TGSM pointers must originate from an unambiguous TGSM global variable. -INSTR.HANDLENOTFROMCREATEHANDLE Resource handle should returned by createHandle. -INSTR.ILLEGALDXILOPCODE DXILOpCode must be [0..%0]. %1 specified. -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.MINPRECISIONNOTPRECISE Instructions marked precise may not refer to minprecision values. -INSTR.MINPRECISONBITCAST Bitcast on minprecison types is not allowed. -INSTR.MIPLEVELFORGETDIMENSION Use mip level on buffer when GetDimensions. -INSTR.MIPONUAVLOAD uav load don't support mipLevel/sampleIndex. -INSTR.MISSINGSETMESHOUTPUTCOUNTS Missing SetMeshOutputCounts call. -INSTR.MULTIPLEGETMESHPAYLOAD GetMeshPayload cannot be called multiple times. -INSTR.MULTIPLESETMESHOUTPUTCOUNTS SetMeshOUtputCounts cannot be called multiple times. -INSTR.NODERECORDHANDLEUSEAFTERCOMPLETE Invalid use of completed record handle. -INSTR.NOGENERICPTRADDRSPACECAST Address space cast between pointer types must have one part to be generic address space. -INSTR.NOIDIVBYZERO No signed integer division by zero. -INSTR.NOINDEFINITEACOS No indefinite arccosine. -INSTR.NOINDEFINITEASIN No indefinite arcsine. -INSTR.NOINDEFINITEDSXY No indefinite derivative calculation. -INSTR.NOINDEFINITELOG No indefinite logarithm. -INSTR.NONDOMINATINGDISPATCHMESH Non-Dominating DispatchMesh call. -INSTR.NONDOMINATINGSETMESHOUTPUTCOUNTS Non-Dominating SetMeshOutputCounts call. -INSTR.NOREADINGUNINITIALIZED Instructions should not read uninitialized value. -INSTR.NOTONCEDISPATCHMESH DispatchMesh must be called exactly once in an Amplification shader. -INSTR.NOUDIVBYZERO No unsigned integer division by zero. -INSTR.OFFSETONUAVLOAD uav load don't support offset. -INSTR.OLOAD DXIL intrinsic overload must be valid. -INSTR.ONLYONEALLOCCONSUME RWStructuredBuffers may increment or decrement their counters, but not both. -INSTR.OPCODERESERVED Instructions must not reference reserved opcodes. -INSTR.OPCONST DXIL intrinsic requires an immediate constant operand -INSTR.OPCONSTRANGE Constant values must be in-range for operation. -INSTR.OPERANDRANGE DXIL intrinsic operand must be within defined range -INSTR.PTRBITCAST Pointer type bitcast must be have same size. -INSTR.RESOURCECLASSFORLOAD load can only run on UAV/SRV resource. -INSTR.RESOURCECLASSFORSAMPLERGATHER sample, lod and gather should be on srv resource. -INSTR.RESOURCECLASSFORUAVSTORE store should be on uav resource. -INSTR.RESOURCECOORDINATEMISS coord uninitialized. -INSTR.RESOURCECOORDINATETOOMANY out of bound coord must be undef. -INSTR.RESOURCEKINDFORBUFFERLOADSTORE buffer load/store only works on Raw/Typed/StructuredBuffer. -INSTR.RESOURCEKINDFORCALCLOD lod requires resource declared as texture1D/2D/3D/Cube/CubeArray/1DArray/2DArray. -INSTR.RESOURCEKINDFORGATHER gather requires resource declared as texture/2D/Cube/2DArray/CubeArray. -INSTR.RESOURCEKINDFORGETDIM Invalid resource kind on GetDimensions. -INSTR.RESOURCEKINDFORSAMPLE sample/_l/_d requires resource declared as texture1D/2D/3D/Cube/1DArray/2DArray/CubeArray. -INSTR.RESOURCEKINDFORSAMPLEC samplec requires resource declared as texture1D/2D/Cube/1DArray/2DArray/CubeArray. -INSTR.RESOURCEKINDFORTEXTURELOAD texture load only works on Texture1D/1DArray/2D/2DArray/3D/MS2D/MS2DArray. -INSTR.RESOURCEKINDFORTEXTURESTORE texture store only works on Texture1D/1DArray/2D/2DArray/3D. -INSTR.RESOURCEKINDFORTRACERAY TraceRay should only use RTAccelerationStructure. -INSTR.RESOURCEMAPTOSINGLEENTRY Fail to map resource to resource table. -INSTR.RESOURCEOFFSETMISS offset uninitialized. -INSTR.RESOURCEOFFSETTOOMANY out of bound offset must be undef. -INSTR.RESOURCEUSER Resource should only be used by Load/GEP/Call. -INSTR.SAMPLECOMPTYPE sample_* instructions require resource to be declared to return UNORM, SNORM or FLOAT. -INSTR.SAMPLEINDEXFORLOAD2DMS load on Texture2DMS/2DMSArray require sampleIndex. -INSTR.SAMPLERMODEFORLOD lod instruction requires sampler declared in default mode. -INSTR.SAMPLERMODEFORSAMPLE sample/_l/_d/_cl_s/gather instruction requires sampler declared in default mode. -INSTR.SAMPLERMODEFORSAMPLEC sample_c_*/gather_c instructions require sampler declared in comparison mode. -INSTR.SIGNATUREOPERATIONNOTINENTRY Dxil operation for input output signature must be in entryPoints. -INSTR.STATUS Resource status should only be used by CheckAccessFullyMapped. -INSTR.STRUCTBITCAST Bitcast on struct types is not allowed. -INSTR.SVCONFLICTINGLAUNCHMODE Input system values are compatible with node shader launch mode. -INSTR.TEXTUREOFFSET offset texture instructions must take offset which can resolve to integer literal in the range -8 to 7. -INSTR.TGSMRACECOND Race condition writing to shared memory detected, consider making this write conditional. -INSTR.UNDEFINEDVALUEFORUAVSTORE Assignment of undefined values to UAV. -INSTR.UNDEFRESULTFORGETDIMENSION GetDimensions used undef dimension %0 on %1. -INSTR.WRITEMASKFORTYPEDUAVSTORE store on typed uav must write to all four components of the UAV. -INSTR.WRITEMASKGAPFORUAV UAV write mask must be contiguous, starting at x: .x, .xy, .xyz, or .xyzw. -INSTR.WRITEMASKMATCHVALUEFORUAVSTORE uav store write mask must match store value mask, write mask is %0 and store value mask is %1. -META.BARYCENTRICSFLOAT3 only 'float3' type is allowed for SV_Barycentrics. -META.BARYCENTRICSINTERPOLATION SV_Barycentrics cannot be used with 'nointerpolation' type. -META.BARYCENTRICSTWOPERSPECTIVES There can only be up to two input attributes of SV_Barycentrics with different perspective interpolation mode. -META.BRANCHFLATTEN Can't use branch and flatten attributes together. -META.CLIPCULLMAXCOMPONENTS Combined elements of SV_ClipDistance and SV_CullDistance must fit in 8 components -META.CLIPCULLMAXROWS Combined elements of SV_ClipDistance and SV_CullDistance must fit in two rows. -META.COMPUTEWITHNODE Compute entry must not have node metadata -META.CONTROLFLOWHINTNOTONCONTROLFLOW Control flow hint only works on control flow inst. -META.DENSERESIDS Resource identifiers must be zero-based and dense. -META.DUPLICATESYSVALUE System value may only appear once in signature -META.ENTRYFUNCTION entrypoint not found. -META.FLAGSUSAGE Flags must match usage. -META.FORCECASEONSWITCH Attribute forcecase only works for switch. -META.GLCNOTONAPPENDCONSUME globallycoherent cannot be used with append/consume buffers: '%0'. -META.INTEGERINTERPMODE Interpolation mode on integer must be Constant -META.INTERPMODEINONEROW Interpolation mode must be identical for all elements packed into the same row. -META.INTERPMODEVALID Interpolation mode must be valid -META.INVALIDCONTROLFLOWHINT Invalid control flow hint. -META.KNOWN Named metadata should be known -META.MAXTESSFACTOR Hull Shader MaxTessFactor must be [%0..%1]. %2 specified. -META.NOENTRYPROPSFORENTRY Entry point %0 must have entry properties. -META.NOSEMANTICOVERLAP Semantics must not overlap -META.REQUIRED Required metadata missing. -META.SEMAKINDMATCHESNAME Semantic name must match system value, when defined. -META.SEMAKINDVALID Semantic kind must be valid -META.SEMANTICCOMPTYPE %0 must be %1. -META.SEMANTICINDEXMAX System value semantics have a maximum valid semantic index -META.SEMANTICLEN Semantic length must be at least 1 and at most 64. -META.SEMANTICSHOULDBEALLOCATED Semantic should have a valid packing location -META.SEMANTICSHOULDNOTBEALLOCATED Semantic should have a packing location of -1 -META.SIGNATURECOMPTYPE signature %0 specifies unrecognized or invalid component type. -META.SIGNATUREDATAWIDTH Data width must be identical for all elements packed into the same row. -META.SIGNATUREILLEGALCOMPONENTORDER Component ordering for packed elements must be: arbitrary < system value < system generated value -META.SIGNATUREINDEXCONFLICT Only elements with compatible indexing rules may be packed together -META.SIGNATUREOUTOFRANGE Signature elements must fit within maximum signature size -META.SIGNATUREOVERLAP Signature elements may not overlap in packing location. -META.STRUCTBUFALIGNMENT StructuredBuffer stride not aligned -META.STRUCTBUFALIGNMENTOUTOFBOUND StructuredBuffer stride out of bounds -META.SYSTEMVALUEROWS System value may only have 1 row -META.TARGET Target triple must be 'dxil-ms-dx' -META.TESSELLATOROUTPUTPRIMITIVE Invalid Tessellator Output Primitive specified. Must be point, line, triangleCW or triangleCCW. -META.TESSELLATORPARTITION Invalid Tessellator Partitioning specified. Must be integer, pow2, fractional_odd or fractional_even. -META.TEXTURETYPE elements of typed buffers and textures must fit in four 32-bit quantities. -META.USED All metadata must be used by dxil. -META.VALIDSAMPLERMODE Invalid sampler mode on sampler . -META.VALUERANGE Metadata value must be within range. -META.VERSIONSUPPORTED Version in metadata must be supported. -META.WELLFORMED Metadata must be well-formed in operand count and types. -SM.64BITRAWBUFFERLOADSTORE i64/f64 rawBufferLoad/Store overloads are allowed after SM 6.3. -SM.AMPLIFICATIONSHADERPAYLOADSIZE For amplification shader with entry '%0', payload size %1 is greater than maximum size of %2 bytes. -SM.AMPLIFICATIONSHADERPAYLOADSIZEDECLARED For amplification shader with entry '%0', payload size %1 is greater than declared size of %2 bytes. -SM.APPENDANDCONSUMEONSAMEUAV BufferUpdateCounter inc and dec on a given UAV (%d) cannot both be in the same shader for shader model less than 5.1. -SM.CBUFFERARRAYOFFSETALIGNMENT CBuffer array offset must be aligned to 16-bytes -SM.CBUFFERELEMENTOVERFLOW CBuffer elements must not overflow -SM.CBUFFEROFFSETOVERLAP CBuffer offsets must not overlap -SM.CBUFFERSIZE CBuffer size must not exceed 65536 bytes -SM.CBUFFERTEMPLATETYPEMUSTBESTRUCT D3D12 constant/texture buffer template element can only be a struct. -SM.COMPLETEPOSITION Not all elements of SV_Position were written. -SM.CONSTANTINTERPMODE Interpolation mode must be constant for MS primitive output. -SM.COUNTERONLYONSTRUCTBUF BufferUpdateCounter valid only on structured buffers. -SM.CSNOSIGNATURES Compute shaders must not have shader signatures. -SM.DOMAINLOCATIONIDXOOB DomainLocation component index out of bounds for the domain. -SM.DSINPUTCONTROLPOINTCOUNTRANGE DS input control point count must be [0..%0]. %1 specified. -SM.DXILVERSION Target shader model requires specific Dxil Version -SM.GSINSTANCECOUNTRANGE GS instance count must be [1..%0]. %1 specified. -SM.GSOUTPUTVERTEXCOUNTRANGE GS output vertex count must be [0..%0]. %1 specified. -SM.GSTOTALOUTPUTVERTEXDATARANGE Declared output vertex count (%0) multiplied by the total number of declared scalar components of output data (%1) equals %2. This value cannot be greater than %3. -SM.GSVALIDINPUTPRIMITIVE GS input primitive unrecognized. -SM.GSVALIDOUTPUTPRIMITIVETOPOLOGY GS output primitive topology unrecognized. -SM.HSINPUTCONTROLPOINTCOUNTRANGE HS input control point count must be [0..%0]. %1 specified. -SM.HULLPASSTHRUCONTROLPOINTCOUNTMATCH For pass thru hull shader, input control point count must match output control point count -SM.INCOMPATIBLECALLINENTRY Features used in internal function calls must be compatible with entry -SM.INCOMPATIBLEDERIVINCOMPUTESHADERMODEL Derivatives in compute-model shaders require shader model 6.6 and above -SM.INCOMPATIBLEDERIVLAUNCH Node shaders only support derivatives in broadcasting launch mode -SM.INCOMPATIBLEOPERATION Operations used in entry function must be compatible with shader stage and other properties -SM.INCOMPATIBLEREQUIRESGROUP Functions requiring groupshared memory must be called from shaders with a visible group -SM.INCOMPATIBLESHADERMODEL Functions may only use features available in the current shader model -SM.INCOMPATIBLESTAGE Functions may only use features available in the entry function's stage -SM.INCOMPATIBLETHREADGROUPDIM When derivatives are used in compute-model shaders, the thread group dimensions must be compatible -SM.INSIDETESSFACTORSIZEMATCHDOMAIN InsideTessFactor rows, columns (%0, %1) invalid for domain %2. Expected %3 rows and 1 column. -SM.INVALIDRESOURCECOMPTYPE Invalid resource return type. -SM.INVALIDRESOURCEKIND Invalid resources kind. -SM.INVALIDSAMPLERFEEDBACKTYPE Invalid sampler feedback type. -SM.INVALIDTEXTUREKINDONUAV TextureCube[Array] resources are not supported with UAVs. -SM.ISOLINEOUTPUTPRIMITIVEMISMATCH Hull Shader declared with IsoLine Domain must specify output primitive point or line. Triangle_cw or triangle_ccw output are not compatible with the IsoLine Domain. -SM.MAXMSSMSIZE Total Thread Group Shared Memory storage is %0, exceeded %1. -SM.MAXTGSMSIZE Total Thread Group Shared Memory storage is %0, exceeded %1. -SM.MAXTHEADGROUP Declared Thread Group Count %0 (X*Y*Z) is beyond the valid maximum of %1. -SM.MESHPSIGROWCOUNT For shader '%0', primitive output signatures are taking up more than %1 rows. -SM.MESHSHADERINOUTSIZE For shader '%0', payload plus output size is greater than %1. -SM.MESHSHADERMAXPRIMITIVECOUNT MS max primitive output count must be [0..%0]. %1 specified. -SM.MESHSHADERMAXVERTEXCOUNT MS max vertex output count must be [0..%0]. %1 specified. -SM.MESHSHADEROUTPUTSIZE For shader '%0', vertex plus primitive output size is greater than %1. -SM.MESHSHADERPAYLOADSIZE For mesh shader with entry '%0', payload size %1 is greater than maximum size of %2 bytes. -SM.MESHSHADERPAYLOADSIZEDECLARED For mesh shader with entry '%0', payload size %1 is greater than declared size of %2 bytes. -SM.MESHTOTALSIGROWCOUNT For shader '%0', vertex and primitive output signatures are taking up more than %1 rows. -SM.MESHVSIGROWCOUNT For shader '%0', vertex output signatures are taking up more than %1 rows. -SM.MULTISTREAMMUSTBEPOINT When multiple GS output streams are used they must be pointlists -SM.NAME Target shader model name must be known -SM.NOINTERPMODE Interpolation mode must be undefined for VS input/PS output/patch constant. -SM.NOPSOUTPUTIDX Pixel shader output registers are not indexable. -SM.OPCODE Opcode must be defined in target shader model -SM.OPCODEININVALIDFUNCTION Invalid DXIL opcode usage like StorePatchConstant in patch constant function -SM.OPERAND Operand must be defined in target shader model. -SM.OUTPUTCONTROLPOINTCOUNTRANGE output control point count must be [%0..%1]. %2 specified. -SM.OUTPUTCONTROLPOINTSTOTALSCALARS Total number of scalars across all HS output control points must not exceed . -SM.PATCHCONSTANTONLYFORHSDS patch constant signature only valid in HS and DS. -SM.PSCONSISTENTINTERP Interpolation mode for PS input position must be linear_noperspective_centroid or linear_noperspective_sample when outputting oDepthGE or oDepthLE and not running at sample frequency (which is forced by inputting SV_SampleIndex or declaring an input linear_sample or linear_noperspective_sample). -SM.PSCOVERAGEANDINNERCOVERAGE InnerCoverage and Coverage are mutually exclusive. -SM.PSMULTIPLEDEPTHSEMANTIC Pixel Shader only allows one type of depth semantic to be declared. -SM.PSOUTPUTSEMANTIC Pixel Shader allows output semantics to be SV_Target, SV_Depth, SV_DepthGreaterEqual, SV_DepthLessEqual, SV_Coverage or SV_StencilRef, %0 found. -SM.PSTARGETCOL0 SV_Target packed location must start at column 0. -SM.PSTARGETINDEXMATCHESROW SV_Target semantic index must match packed row location. -SM.RAYSHADERPAYLOADSIZE For shader '%0', %1 size is smaller than argument's allocation size. -SM.RAYSHADERSIGNATURES Ray tracing shader '%0' should not have any shader signatures. -SM.RESOURCERANGEOVERLAP Resource ranges must not overlap -SM.ROVONLYINPS RasterizerOrdered objects are only allowed in 5.0+ pixel shaders. -SM.SAMPLECOUNTONLYON2DMS Only Texture2DMS/2DMSArray could has sample count. -SM.SEMANTIC Semantic must be defined in target shader model -SM.STREAMINDEXRANGE Stream index (%0) must between 0 and %1. -SM.TESSFACTORFORDOMAIN Required TessFactor for domain not found declared anywhere in Patch Constant data. -SM.TESSFACTORSIZEMATCHDOMAIN TessFactor rows, columns (%0, %1) invalid for domain %2. Expected %3 rows and 1 column. -SM.TGSMUNSUPPORTED Thread Group Shared Memory not supported %0. -SM.THREADGROUPCHANNELRANGE Declared Thread Group %0 size %1 outside valid range [%2..%3]. -SM.TRIOUTPUTPRIMITIVEMISMATCH Hull Shader declared with Tri Domain must specify output primitive point, triangle_cw or triangle_ccw. Line output is not compatible with the Tri domain. -SM.UNDEFINEDOUTPUT Not all elements of output %0 were written. -SM.VALIDDOMAIN Invalid Tessellator Domain specified. Must be isoline, tri or quad. -SM.VIEWIDNEEDSSLOT ViewID requires compatible space in pixel shader input signature -SM.WAVESIZEALLZEROWHENUNDEFINED WaveSize Max and Preferred must be 0 when Min is 0 -SM.WAVESIZEEXPECTSONEPARAM WaveSize tag expects exactly 1 parameter. -SM.WAVESIZEMAXANDPREFERREDZEROWHENNORANGE WaveSize Max and Preferred must be 0 to encode min==max -SM.WAVESIZEMAXGREATERTHANMIN WaveSize Max must greater than Min -SM.WAVESIZENEEDSCONSTANTOPERANDS WaveSize metadata operands must be constant values. -SM.WAVESIZENEEDSSM66OR67 WaveSize is valid only for Shader Model 6.6 and 6.7. -SM.WAVESIZEONCOMPUTEORNODE WaveSize only allowed on compute or node shaders -SM.WAVESIZEPREFERREDINRANGE WaveSize Preferred must be within Min..Max range -SM.WAVESIZERANGEEXPECTSTHREEPARAMS WaveSize Range tag expects exactly 3 parameters. -SM.WAVESIZERANGENEEDSSM68PLUS WaveSize Range is valid only for Shader Model 6.8 and higher. -SM.WAVESIZETAGDUPLICATE WaveSize or WaveSizeRange tag may only appear once per entry point. -SM.WAVESIZEVALUE WaveSize value must be a power of 2 in range [4..128] -SM.ZEROHSINPUTCONTROLPOINTWITHINPUT When HS input control point count is 0, no input signature should exist. -TYPES.DEFINED Type must be defined based on DXIL primitives -TYPES.I8 I8 can only be used as immediate value for intrinsic or as i8* via bitcast by lifetime intrinsics. -TYPES.INTWIDTH Int type must be of valid width -TYPES.NOMULTIDIM Only one dimension allowed for array type. -TYPES.NOPTRTOPTR Pointers to pointers, or pointers in structures are not allowed. -TYPES.NOVECTOR Vector types must not be present -========================================= ======================================================================================================================================================================================================================================================================================================== +===================================================== ======================================================================================================================================================================================================================================================================================================== +Rule Code Description +===================================================== ======================================================================================================================================================================================================================================================================================================== +BITCODE.VALID Module must be bitcode-valid +CONTAINER.CONTENTINVALID DXIL Container Content is well-formed +CONTAINER.CONTENTMATCHES DXIL Container Content must match Module +CONTAINER.PARTINVALID DXIL Container must not contain unknown parts +CONTAINER.PARTMATCHES DXIL Container Parts must match Module +CONTAINER.PARTMISSING DXIL Container requires certain parts, corresponding to module +CONTAINER.PARTREPEATED DXIL Container must have only one of each part type +CONTAINER.ROOTSIGNATUREINCOMPATIBLE Root Signature in DXIL Container must be compatible with shader +CONTAINER.UNUSEDITEMINTABLE Items in Table must be used +DECL.ALLOCATERAYQUERY2FLAGSARECONST constRayFlags and RayQueryFlags for AllocateRayQuery2 must be constant +DECL.ALLOCATERAYQUERYFLAGSARECONST RayFlags for AllocateRayQuery must be constant +DECL.ALLOWOPACITYMICROMAPSEXPECTEDGIVENFORCEOMM2STATE When the ForceOMM2State ConstRayFlag is given as an argument to a RayQuery object, AllowOpacityMicromaps is expected as a RayQueryFlag argument +DECL.ATTRSTRUCT Attributes parameter must be struct type +DECL.DXILFNEXTERN External function must be a DXIL function +DECL.DXILNSRESERVED The DXIL reserved prefixes must only be used by built-in functions and types +DECL.EXTRAARGS Extra arguments not allowed for shader functions +DECL.FNATTRIBUTE Functions should only contain known function attributes +DECL.FNFLATTENPARAM Function parameters must not use struct types +DECL.FNISCALLED Functions can only be used by call instructions +DECL.MULTIPLENODEINPUTS A node shader may not have more than one input record +DECL.NODELAUNCHINPUTTYPE Invalid input record type for node launch type +DECL.NOTUSEDEXTERNAL External declaration should not be used +DECL.PARAMSTRUCT Callable function parameter must be struct type +DECL.PAYLOADSTRUCT Payload parameter must be struct type +DECL.RAYQUERYINFNSIG Rayquery objects not allowed in function signatures +DECL.RESOURCEINFNSIG Resources not allowed in function signatures +DECL.SHADERMISSINGARG payload/params/attributes parameter is required for certain shader types +DECL.SHADERRETURNVOID Shader functions must return void +DECL.USEDEXTERNALFUNCTION External function must be used +DECL.USEDINTERNAL Internal declaration must be used +FLOW.DEADLOOP Loop must have break. +FLOW.FUNCTIONCALL Function with parameter is not permitted +FLOW.NORECURSION Recursion is not permitted. +FLOW.REDUCIBLE Execution flow must be reducible. +INSTR.ALLOWED Instructions must be of an allowed type. +INSTR.ATOMICCONST Constant destination to atomic. +INSTR.ATOMICINTRINNONUAV Non-UAV destination to atomic intrinsic. +INSTR.ATOMICOPNONGROUPSHAREDORRECORD Non-groupshared or node record destination to atomic operation. +INSTR.ATTRIBUTEATVERTEXNOINTERPOLATION Attribute %0 must have nointerpolation mode in order to use GetAttributeAtVertex function. +INSTR.BARRIERFLAGINVALID Invalid %0 flags on DXIL operation '%1' +INSTR.BARRIERMODEFORNONCS sync in a non-Compute/Amplification/Mesh/Node Shader must only sync UAV (sync_uglobal). +INSTR.BARRIERMODENOMEMORY sync must include some form of memory barrier - _u (UAV) and/or _g (Thread Group Shared Memory). Only _t (thread group sync) is optional. +INSTR.BARRIERMODEUSELESSUGROUP sync can't specify both _ugroup and _uglobal. If both are needed, just specify _uglobal. +INSTR.BARRIERNONCONSTANTFLAGARGUMENT Memory type, access, or sync flag is not constant +INSTR.BARRIERREQUIRESNODE sync in a non-Node Shader must not sync node record memory. +INSTR.BUFFERUPDATECOUNTERONRESHASCOUNTER BufferUpdateCounter valid only when HasCounter is true. +INSTR.BUFFERUPDATECOUNTERONUAV BufferUpdateCounter valid only on UAV. +INSTR.CALLOLOAD Call to DXIL intrinsic must match overload signature +INSTR.CANNOTPULLPOSITION pull-model evaluation of position disallowed +INSTR.CBUFFERCLASSFORCBUFFERHANDLE Expect Cbuffer for CBufferLoad handle. +INSTR.CBUFFEROUTOFBOUND Cbuffer access out of bound. +INSTR.CHECKACCESSFULLYMAPPED CheckAccessFullyMapped should only be used on resource status. +INSTR.COORDINATECOUNTFORRAWTYPEDBUF raw/typed buffer don't need 2 coordinates. +INSTR.COORDINATECOUNTFORSTRUCTBUF structured buffer require 2 coordinates. +INSTR.CREATEHANDLEIMMRANGEID Local resource must map to global resource. +INSTR.DXILSTRUCTUSER Dxil struct types should only be used by ExtractValue. +INSTR.DXILSTRUCTUSEROUTOFBOUND Index out of bound when extract value from dxil struct types. +INSTR.EVALINTERPOLATIONMODE Interpolation mode on %0 used with eval_* instruction must be linear, linear_centroid, linear_noperspective, linear_noperspective_centroid, linear_sample or linear_noperspective_sample. +INSTR.EXTRACTVALUE ExtractValue should only be used on dxil struct types and cmpxchg. +INSTR.FAILTORESLOVETGSMPOINTER TGSM pointers must originate from an unambiguous TGSM global variable. +INSTR.HANDLENOTFROMCREATEHANDLE Resource handle should returned by createHandle. +INSTR.ILLEGALDXILOPCODE DXILOpCode must be [0..%0]. %1 specified. +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.MINPRECISIONNOTPRECISE Instructions marked precise may not refer to minprecision values. +INSTR.MINPRECISONBITCAST Bitcast on minprecison types is not allowed. +INSTR.MIPLEVELFORGETDIMENSION Use mip level on buffer when GetDimensions. +INSTR.MIPONUAVLOAD uav load don't support mipLevel/sampleIndex. +INSTR.MISSINGSETMESHOUTPUTCOUNTS Missing SetMeshOutputCounts call. +INSTR.MULTIPLEGETMESHPAYLOAD GetMeshPayload cannot be called multiple times. +INSTR.MULTIPLESETMESHOUTPUTCOUNTS SetMeshOUtputCounts cannot be called multiple times. +INSTR.NODERECORDHANDLEUSEAFTERCOMPLETE Invalid use of completed record handle. +INSTR.NOGENERICPTRADDRSPACECAST Address space cast between pointer types must have one part to be generic address space. +INSTR.NOIDIVBYZERO No signed integer division by zero. +INSTR.NOINDEFINITEACOS No indefinite arccosine. +INSTR.NOINDEFINITEASIN No indefinite arcsine. +INSTR.NOINDEFINITEDSXY No indefinite derivative calculation. +INSTR.NOINDEFINITELOG No indefinite logarithm. +INSTR.NONDOMINATINGDISPATCHMESH Non-Dominating DispatchMesh call. +INSTR.NONDOMINATINGSETMESHOUTPUTCOUNTS Non-Dominating SetMeshOutputCounts call. +INSTR.NOREADINGUNINITIALIZED Instructions should not read uninitialized value. +INSTR.NOTONCEDISPATCHMESH DispatchMesh must be called exactly once in an Amplification shader. +INSTR.NOUDIVBYZERO No unsigned integer division by zero. +INSTR.OFFSETONUAVLOAD uav load don't support offset. +INSTR.OLOAD DXIL intrinsic overload must be valid. +INSTR.ONLYONEALLOCCONSUME RWStructuredBuffers may increment or decrement their counters, but not both. +INSTR.OPCODERESERVED Instructions must not reference reserved opcodes. +INSTR.OPCONST DXIL intrinsic requires an immediate constant operand +INSTR.OPCONSTRANGE Constant values must be in-range for operation. +INSTR.OPERANDRANGE DXIL intrinsic operand must be within defined range +INSTR.PTRBITCAST Pointer type bitcast must be have same size. +INSTR.RESOURCECLASSFORLOAD load can only run on UAV/SRV resource. +INSTR.RESOURCECLASSFORSAMPLERGATHER sample, lod and gather should be on srv resource. +INSTR.RESOURCECLASSFORUAVSTORE store should be on uav resource. +INSTR.RESOURCECOORDINATEMISS coord uninitialized. +INSTR.RESOURCECOORDINATETOOMANY out of bound coord must be undef. +INSTR.RESOURCEKINDFORBUFFERLOADSTORE buffer load/store only works on Raw/Typed/StructuredBuffer. +INSTR.RESOURCEKINDFORCALCLOD lod requires resource declared as texture1D/2D/3D/Cube/CubeArray/1DArray/2DArray. +INSTR.RESOURCEKINDFORGATHER gather requires resource declared as texture/2D/Cube/2DArray/CubeArray. +INSTR.RESOURCEKINDFORGETDIM Invalid resource kind on GetDimensions. +INSTR.RESOURCEKINDFORSAMPLE sample/_l/_d requires resource declared as texture1D/2D/3D/Cube/1DArray/2DArray/CubeArray. +INSTR.RESOURCEKINDFORSAMPLEC samplec requires resource declared as texture1D/2D/Cube/1DArray/2DArray/CubeArray. +INSTR.RESOURCEKINDFORTEXTURELOAD texture load only works on Texture1D/1DArray/2D/2DArray/3D/MS2D/MS2DArray. +INSTR.RESOURCEKINDFORTEXTURESTORE texture store only works on Texture1D/1DArray/2D/2DArray/3D. +INSTR.RESOURCEKINDFORTRACERAY TraceRay should only use RTAccelerationStructure. +INSTR.RESOURCEMAPTOSINGLEENTRY Fail to map resource to resource table. +INSTR.RESOURCEOFFSETMISS offset uninitialized. +INSTR.RESOURCEOFFSETTOOMANY out of bound offset must be undef. +INSTR.RESOURCEUSER Resource should only be used by Load/GEP/Call. +INSTR.SAMPLECOMPTYPE sample_* instructions require resource to be declared to return UNORM, SNORM or FLOAT. +INSTR.SAMPLEINDEXFORLOAD2DMS load on Texture2DMS/2DMSArray require sampleIndex. +INSTR.SAMPLERMODEFORLOD lod instruction requires sampler declared in default mode. +INSTR.SAMPLERMODEFORSAMPLE sample/_l/_d/_cl_s/gather instruction requires sampler declared in default mode. +INSTR.SAMPLERMODEFORSAMPLEC sample_c_*/gather_c instructions require sampler declared in comparison mode. +INSTR.SIGNATUREOPERATIONNOTINENTRY Dxil operation for input output signature must be in entryPoints. +INSTR.STATUS Resource status should only be used by CheckAccessFullyMapped. +INSTR.STRUCTBITCAST Bitcast on struct types is not allowed. +INSTR.SVCONFLICTINGLAUNCHMODE Input system values are compatible with node shader launch mode. +INSTR.TEXTUREOFFSET offset texture instructions must take offset which can resolve to integer literal in the range -8 to 7. +INSTR.TGSMRACECOND Race condition writing to shared memory detected, consider making this write conditional. +INSTR.UNDEFINEDVALUEFORUAVSTORE Assignment of undefined values to UAV. +INSTR.UNDEFRESULTFORGETDIMENSION GetDimensions used undef dimension %0 on %1. +INSTR.WRITEMASKFORTYPEDUAVSTORE store on typed uav must write to all four components of the UAV. +INSTR.WRITEMASKGAPFORUAV UAV write mask must be contiguous, starting at x: .x, .xy, .xyz, or .xyzw. +INSTR.WRITEMASKMATCHVALUEFORUAVSTORE uav store write mask must match store value mask, write mask is %0 and store value mask is %1. +META.BARYCENTRICSFLOAT3 only 'float3' type is allowed for SV_Barycentrics. +META.BARYCENTRICSINTERPOLATION SV_Barycentrics cannot be used with 'nointerpolation' type. +META.BARYCENTRICSTWOPERSPECTIVES There can only be up to two input attributes of SV_Barycentrics with different perspective interpolation mode. +META.BRANCHFLATTEN Can't use branch and flatten attributes together. +META.CLIPCULLMAXCOMPONENTS Combined elements of SV_ClipDistance and SV_CullDistance must fit in 8 components +META.CLIPCULLMAXROWS Combined elements of SV_ClipDistance and SV_CullDistance must fit in two rows. +META.COMPUTEWITHNODE Compute entry must not have node metadata +META.CONTROLFLOWHINTNOTONCONTROLFLOW Control flow hint only works on control flow inst. +META.DENSERESIDS Resource identifiers must be zero-based and dense. +META.DUPLICATESYSVALUE System value may only appear once in signature +META.ENTRYFUNCTION entrypoint not found. +META.FLAGSUSAGE Flags must match usage. +META.FORCECASEONSWITCH Attribute forcecase only works for switch. +META.GLCNOTONAPPENDCONSUME globallycoherent cannot be used with append/consume buffers: '%0'. +META.INTEGERINTERPMODE Interpolation mode on integer must be Constant +META.INTERPMODEINONEROW Interpolation mode must be identical for all elements packed into the same row. +META.INTERPMODEVALID Interpolation mode must be valid +META.INVALIDCONTROLFLOWHINT Invalid control flow hint. +META.KNOWN Named metadata should be known +META.MAXTESSFACTOR Hull Shader MaxTessFactor must be [%0..%1]. %2 specified. +META.NOENTRYPROPSFORENTRY Entry point %0 must have entry properties. +META.NOSEMANTICOVERLAP Semantics must not overlap +META.REQUIRED Required metadata missing. +META.SEMAKINDMATCHESNAME Semantic name must match system value, when defined. +META.SEMAKINDVALID Semantic kind must be valid +META.SEMANTICCOMPTYPE %0 must be %1. +META.SEMANTICINDEXMAX System value semantics have a maximum valid semantic index +META.SEMANTICLEN Semantic length must be at least 1 and at most 64. +META.SEMANTICSHOULDBEALLOCATED Semantic should have a valid packing location +META.SEMANTICSHOULDNOTBEALLOCATED Semantic should have a packing location of -1 +META.SIGNATURECOMPTYPE signature %0 specifies unrecognized or invalid component type. +META.SIGNATUREDATAWIDTH Data width must be identical for all elements packed into the same row. +META.SIGNATUREILLEGALCOMPONENTORDER Component ordering for packed elements must be: arbitrary < system value < system generated value +META.SIGNATUREINDEXCONFLICT Only elements with compatible indexing rules may be packed together +META.SIGNATUREOUTOFRANGE Signature elements must fit within maximum signature size +META.SIGNATUREOVERLAP Signature elements may not overlap in packing location. +META.STRUCTBUFALIGNMENT StructuredBuffer stride not aligned +META.STRUCTBUFALIGNMENTOUTOFBOUND StructuredBuffer stride out of bounds +META.SYSTEMVALUEROWS System value may only have 1 row +META.TARGET Target triple must be 'dxil-ms-dx' +META.TESSELLATOROUTPUTPRIMITIVE Invalid Tessellator Output Primitive specified. Must be point, line, triangleCW or triangleCCW. +META.TESSELLATORPARTITION Invalid Tessellator Partitioning specified. Must be integer, pow2, fractional_odd or fractional_even. +META.TEXTURETYPE elements of typed buffers and textures must fit in four 32-bit quantities. +META.USED All metadata must be used by dxil. +META.VALIDSAMPLERMODE Invalid sampler mode on sampler . +META.VALUERANGE Metadata value must be within range. +META.VERSIONSUPPORTED Version in metadata must be supported. +META.WELLFORMED Metadata must be well-formed in operand count and types. +SM.64BITRAWBUFFERLOADSTORE i64/f64 rawBufferLoad/Store overloads are allowed after SM 6.3. +SM.AMPLIFICATIONSHADERPAYLOADSIZE For amplification shader with entry '%0', payload size %1 is greater than maximum size of %2 bytes. +SM.AMPLIFICATIONSHADERPAYLOADSIZEDECLARED For amplification shader with entry '%0', payload size %1 is greater than declared size of %2 bytes. +SM.APPENDANDCONSUMEONSAMEUAV BufferUpdateCounter inc and dec on a given UAV (%d) cannot both be in the same shader for shader model less than 5.1. +SM.CBUFFERARRAYOFFSETALIGNMENT CBuffer array offset must be aligned to 16-bytes +SM.CBUFFERELEMENTOVERFLOW CBuffer elements must not overflow +SM.CBUFFEROFFSETOVERLAP CBuffer offsets must not overlap +SM.CBUFFERSIZE CBuffer size must not exceed 65536 bytes +SM.CBUFFERTEMPLATETYPEMUSTBESTRUCT D3D12 constant/texture buffer template element can only be a struct. +SM.COMPLETEPOSITION Not all elements of SV_Position were written. +SM.CONSTANTINTERPMODE Interpolation mode must be constant for MS primitive output. +SM.COUNTERONLYONSTRUCTBUF BufferUpdateCounter valid only on structured buffers. +SM.CSNOSIGNATURES Compute shaders must not have shader signatures. +SM.DOMAINLOCATIONIDXOOB DomainLocation component index out of bounds for the domain. +SM.DSINPUTCONTROLPOINTCOUNTRANGE DS input control point count must be [0..%0]. %1 specified. +SM.DXILVERSION Target shader model requires specific Dxil Version +SM.GSINSTANCECOUNTRANGE GS instance count must be [1..%0]. %1 specified. +SM.GSOUTPUTVERTEXCOUNTRANGE GS output vertex count must be [0..%0]. %1 specified. +SM.GSTOTALOUTPUTVERTEXDATARANGE Declared output vertex count (%0) multiplied by the total number of declared scalar components of output data (%1) equals %2. This value cannot be greater than %3. +SM.GSVALIDINPUTPRIMITIVE GS input primitive unrecognized. +SM.GSVALIDOUTPUTPRIMITIVETOPOLOGY GS output primitive topology unrecognized. +SM.HSINPUTCONTROLPOINTCOUNTRANGE HS input control point count must be [0..%0]. %1 specified. +SM.HULLPASSTHRUCONTROLPOINTCOUNTMATCH For pass thru hull shader, input control point count must match output control point count +SM.INCOMPATIBLECALLINENTRY Features used in internal function calls must be compatible with entry +SM.INCOMPATIBLEDERIVINCOMPUTESHADERMODEL Derivatives in compute-model shaders require shader model 6.6 and above +SM.INCOMPATIBLEDERIVLAUNCH Node shaders only support derivatives in broadcasting launch mode +SM.INCOMPATIBLEOPERATION Operations used in entry function must be compatible with shader stage and other properties +SM.INCOMPATIBLEREQUIRESGROUP Functions requiring groupshared memory must be called from shaders with a visible group +SM.INCOMPATIBLESHADERMODEL Functions may only use features available in the current shader model +SM.INCOMPATIBLESTAGE Functions may only use features available in the entry function's stage +SM.INCOMPATIBLETHREADGROUPDIM When derivatives are used in compute-model shaders, the thread group dimensions must be compatible +SM.INSIDETESSFACTORSIZEMATCHDOMAIN InsideTessFactor rows, columns (%0, %1) invalid for domain %2. Expected %3 rows and 1 column. +SM.INVALIDRESOURCECOMPTYPE Invalid resource return type. +SM.INVALIDRESOURCEKIND Invalid resources kind. +SM.INVALIDSAMPLERFEEDBACKTYPE Invalid sampler feedback type. +SM.INVALIDTEXTUREKINDONUAV TextureCube[Array] resources are not supported with UAVs. +SM.ISOLINEOUTPUTPRIMITIVEMISMATCH Hull Shader declared with IsoLine Domain must specify output primitive point or line. Triangle_cw or triangle_ccw output are not compatible with the IsoLine Domain. +SM.MAXMSSMSIZE Total Thread Group Shared Memory storage is %0, exceeded %1. +SM.MAXTGSMSIZE Total Thread Group Shared Memory storage is %0, exceeded %1. +SM.MAXTHEADGROUP Declared Thread Group Count %0 (X*Y*Z) is beyond the valid maximum of %1. +SM.MESHPSIGROWCOUNT For shader '%0', primitive output signatures are taking up more than %1 rows. +SM.MESHSHADERINOUTSIZE For shader '%0', payload plus output size is greater than %1. +SM.MESHSHADERMAXPRIMITIVECOUNT MS max primitive output count must be [0..%0]. %1 specified. +SM.MESHSHADERMAXVERTEXCOUNT MS max vertex output count must be [0..%0]. %1 specified. +SM.MESHSHADEROUTPUTSIZE For shader '%0', vertex plus primitive output size is greater than %1. +SM.MESHSHADERPAYLOADSIZE For mesh shader with entry '%0', payload size %1 is greater than maximum size of %2 bytes. +SM.MESHSHADERPAYLOADSIZEDECLARED For mesh shader with entry '%0', payload size %1 is greater than declared size of %2 bytes. +SM.MESHTOTALSIGROWCOUNT For shader '%0', vertex and primitive output signatures are taking up more than %1 rows. +SM.MESHVSIGROWCOUNT For shader '%0', vertex output signatures are taking up more than %1 rows. +SM.MULTISTREAMMUSTBEPOINT When multiple GS output streams are used they must be pointlists +SM.NAME Target shader model name must be known +SM.NOINTERPMODE Interpolation mode must be undefined for VS input/PS output/patch constant. +SM.NOPSOUTPUTIDX Pixel shader output registers are not indexable. +SM.OPCODE Opcode must be defined in target shader model +SM.OPCODEININVALIDFUNCTION Invalid DXIL opcode usage like StorePatchConstant in patch constant function +SM.OPERAND Operand must be defined in target shader model. +SM.OUTPUTCONTROLPOINTCOUNTRANGE output control point count must be [%0..%1]. %2 specified. +SM.OUTPUTCONTROLPOINTSTOTALSCALARS Total number of scalars across all HS output control points must not exceed . +SM.PATCHCONSTANTONLYFORHSDS patch constant signature only valid in HS and DS. +SM.PROGRAMVERSION Program Version in Dxil Container does not match Dxil Module shader model version +SM.PSCONSISTENTINTERP Interpolation mode for PS input position must be linear_noperspective_centroid or linear_noperspective_sample when outputting oDepthGE or oDepthLE and not running at sample frequency (which is forced by inputting SV_SampleIndex or declaring an input linear_sample or linear_noperspective_sample). +SM.PSCOVERAGEANDINNERCOVERAGE InnerCoverage and Coverage are mutually exclusive. +SM.PSMULTIPLEDEPTHSEMANTIC Pixel Shader only allows one type of depth semantic to be declared. +SM.PSOUTPUTSEMANTIC Pixel Shader allows output semantics to be SV_Target, SV_Depth, SV_DepthGreaterEqual, SV_DepthLessEqual, SV_Coverage or SV_StencilRef, %0 found. +SM.PSTARGETCOL0 SV_Target packed location must start at column 0. +SM.PSTARGETINDEXMATCHESROW SV_Target semantic index must match packed row location. +SM.RAYSHADERPAYLOADSIZE For shader '%0', %1 size is smaller than argument's allocation size. +SM.RAYSHADERSIGNATURES Ray tracing shader '%0' should not have any shader signatures. +SM.RESOURCERANGEOVERLAP Resource ranges must not overlap +SM.ROVONLYINPS RasterizerOrdered objects are only allowed in 5.0+ pixel shaders. +SM.SAMPLECOUNTONLYON2DMS Only Texture2DMS/2DMSArray could has sample count. +SM.SEMANTIC Semantic must be defined in target shader model +SM.STREAMINDEXRANGE Stream index (%0) must between 0 and %1. +SM.TESSFACTORFORDOMAIN Required TessFactor for domain not found declared anywhere in Patch Constant data. +SM.TESSFACTORSIZEMATCHDOMAIN TessFactor rows, columns (%0, %1) invalid for domain %2. Expected %3 rows and 1 column. +SM.TGSMUNSUPPORTED Thread Group Shared Memory not supported %0. +SM.THREADGROUPCHANNELRANGE Declared Thread Group %0 size %1 outside valid range [%2..%3]. +SM.TRIOUTPUTPRIMITIVEMISMATCH Hull Shader declared with Tri Domain must specify output primitive point, triangle_cw or triangle_ccw. Line output is not compatible with the Tri domain. +SM.UNDEFINEDOUTPUT Not all elements of output %0 were written. +SM.VALIDDOMAIN Invalid Tessellator Domain specified. Must be isoline, tri or quad. +SM.VIEWIDNEEDSSLOT ViewID requires compatible space in pixel shader input signature +SM.WAVESIZEALLZEROWHENUNDEFINED WaveSize Max and Preferred must be 0 when Min is 0 +SM.WAVESIZEEXPECTSONEPARAM WaveSize tag expects exactly 1 parameter. +SM.WAVESIZEMAXANDPREFERREDZEROWHENNORANGE WaveSize Max and Preferred must be 0 to encode min==max +SM.WAVESIZEMAXGREATERTHANMIN WaveSize Max must greater than Min +SM.WAVESIZENEEDSCONSTANTOPERANDS WaveSize metadata operands must be constant values. +SM.WAVESIZENEEDSSM66OR67 WaveSize is valid only for Shader Model 6.6 and 6.7. +SM.WAVESIZEONCOMPUTEORNODE WaveSize only allowed on compute or node shaders +SM.WAVESIZEPREFERREDINRANGE WaveSize Preferred must be within Min..Max range +SM.WAVESIZERANGEEXPECTSTHREEPARAMS WaveSize Range tag expects exactly 3 parameters. +SM.WAVESIZERANGENEEDSSM68PLUS WaveSize Range is valid only for Shader Model 6.8 and higher. +SM.WAVESIZETAGDUPLICATE WaveSize or WaveSizeRange tag may only appear once per entry point. +SM.WAVESIZEVALUE WaveSize value must be a power of 2 in range [4..128] +SM.ZEROHSINPUTCONTROLPOINTWITHINPUT When HS input control point count is 0, no input signature should exist. +TYPES.DEFINED Type must be defined based on DXIL primitives +TYPES.I8 I8 can only be used as immediate value for intrinsic or as i8* via bitcast by lifetime intrinsics. +TYPES.INTWIDTH Int type must be of valid width +TYPES.NOMULTIDIM Only one dimension allowed for array type. +TYPES.NOPTRTOPTR Pointers to pointers, or pointers in structures are not allowed. +TYPES.NOVECTOR Vector types must not be present +===================================================== ======================================================================================================================================================================================================================================================================================================== .. VALRULES-RST:END diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index 4bf98e3771..4524cf7c80 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -291,30 +291,28 @@ enum class SemanticKind : unsigned { /* hctdb_instrhelp.get_enum_decl("SigPointKind", hide_val=True, sort_val=False)*/ // clang-format on // SigPointKind-ENUM:BEGIN -// Signature Point is more specific than shader stage or signature as it is -// unique in both stage and item dimensionality or frequency. +// Signature Point is more specific than shader stage or signature as it is unique in both stage and item dimensionality or frequency. enum class SigPointKind : unsigned { - VSIn, // Ordinary Vertex Shader input from Input Assembler - VSOut, // Ordinary Vertex Shader output that may feed Rasterizer - PCIn, // Patch Constant function non-patch inputs - HSIn, // Hull Shader function non-patch inputs - HSCPIn, // Hull Shader patch inputs - Control Points + VSIn, // Ordinary Vertex Shader input from Input Assembler + VSOut, // Ordinary Vertex Shader output that may feed Rasterizer + PCIn, // Patch Constant function non-patch inputs + HSIn, // Hull Shader function non-patch inputs + HSCPIn, // Hull Shader patch inputs - Control Points HSCPOut, // Hull Shader function output - Control Point - PCOut, // Patch Constant function output - Patch Constant data passed to - // Domain Shader + PCOut, // Patch Constant function output - Patch Constant data passed to Domain Shader DSIn, // Domain Shader regular input - Patch Constant data plus system values DSCPIn, // Domain Shader patch input - Control Points - DSOut, // Domain Shader output - vertex data that may feed Rasterizer - GSVIn, // Geometry Shader vertex input - qualified with primitive type - GSIn, // Geometry Shader non-vertex inputs (system values) - GSOut, // Geometry Shader output - vertex data that may feed Rasterizer - PSIn, // Pixel Shader input - PSOut, // Pixel Shader output - CSIn, // Compute Shader input - MSIn, // Mesh Shader input - MSOut, // Mesh Shader vertices output + DSOut, // Domain Shader output - vertex data that may feed Rasterizer + GSVIn, // Geometry Shader vertex input - qualified with primitive type + GSIn, // Geometry Shader non-vertex inputs (system values) + GSOut, // Geometry Shader output - vertex data that may feed Rasterizer + PSIn, // Pixel Shader input + PSOut, // Pixel Shader output + CSIn, // Compute Shader input + MSIn, // Mesh Shader input + MSOut, // Mesh Shader vertices output MSPOut, // Mesh Shader primitives output - ASIn, // Amplification Shader input + ASIn, // Amplification Shader input Invalid, }; // SigPointKind-ENUM:END @@ -326,16 +324,16 @@ enum class SigPointKind : unsigned { // SemanticInterpretationKind-ENUM:BEGIN // Defines how a semantic is interpreted at a particular SignaturePoint enum class SemanticInterpretationKind : unsigned { - NA, // Not Available - SV, // Normal System Value - SGV, // System Generated Value (sorted last) - Arb, // Treated as Arbitrary - NotInSig, // Not included in signature (intrinsic access) - NotPacked, // Included in signature, but does not contribute to packing - Target, // Special handling for SV_Target + NA, // Not Available + SV, // Normal System Value + SGV, // System Generated Value (sorted last) + Arb, // Treated as Arbitrary + NotInSig, // Not included in signature (intrinsic access) + NotPacked, // Included in signature, but does not contribute to packing + Target, // Special handling for SV_Target TessFactor, // Special handling for tessellation factors - Shadow, // Shadow element must be added to a signature for compatibility - ClipCull, // Special packing rules for SV_ClipDistance or SV_CullDistance + Shadow, // Shadow element must be added to a signature for compatibility + ClipCull, // Special packing rules for SV_ClipDistance or SV_CullDistance Invalid, }; // SemanticInterpretationKind-ENUM:END @@ -347,11 +345,11 @@ enum class SemanticInterpretationKind : unsigned { // PackingKind-ENUM:BEGIN // Kind of signature point enum class PackingKind : unsigned { - None, // No packing should be performed + None, // No packing should be performed InputAssembler, // Vertex Shader input from Input Assembler - Vertex, // Vertex that may feed the Rasterizer - PatchConstant, // Patch constant signature - Target, // Render Target (Pixel Shader Output) + Vertex, // Vertex that may feed the Rasterizer + PatchConstant, // Patch constant signature + Target, // Render Target (Pixel Shader Output) Invalid, }; // PackingKind-ENUM:END @@ -363,9 +361,9 @@ enum class PackingKind : unsigned { // FPDenormMode-ENUM:BEGIN // float32 denorm behavior enum class Float32DenormMode : unsigned { - Any = 0, // Undefined behavior for denormal numbers + Any = 0, // Undefined behavior for denormal numbers Preserve = 1, // Preserve both input and output - FTZ = 2, // Preserve denormal inputs. Flush denorm outputs + FTZ = 2, // Preserve denormal inputs. Flush denorm outputs Reserve3 = 3, // Reserved Value. Not used for now Reserve4 = 4, // Reserved Value. Not used for now Reserve5 = 5, // Reserved Value. Not used for now @@ -486,27 +484,29 @@ inline bool IsFeedbackTexture(DXIL::ResourceKind ResourceKind) { // OPCODE-ENUM:BEGIN // Enumeration for operations specified by DXIL enum class OpCode : unsigned { - // + // + MatVecMul = 305, // Matrix-Vector Multiply + MatVecMulAdd = 306, // Matrix-Vector Multiply Add + OuterProductAccumulate = 307, // Outer Product Accumulate RawBufferVectorLoad = 303, // reads from a raw buffer and structured buffer - RawBufferVectorStore = - 304, // writes to a RWByteAddressBuffer or RWStructuredBuffer - Reserved0 = 226, // Reserved - Reserved1 = 227, // Reserved - Reserved10 = 236, // Reserved - Reserved11 = 237, // Reserved - Reserved2 = 228, // Reserved - Reserved3 = 229, // Reserved - Reserved4 = 230, // Reserved - Reserved5 = 231, // Reserved - Reserved6 = 232, // Reserved - Reserved7 = 233, // Reserved - Reserved8 = 234, // Reserved - Reserved9 = 235, // Reserved - ReservedA0 = 259, // reserved - ReservedA1 = 260, // reserved - ReservedA2 = 261, // reserved - ReservedB0 = 262, // reserved - ReservedB1 = 263, // reserved + RawBufferVectorStore = 304, // writes to a RWByteAddressBuffer or RWStructuredBuffer + Reserved0 = 226, // Reserved + Reserved1 = 227, // Reserved + Reserved10 = 236, // Reserved + Reserved11 = 237, // Reserved + Reserved2 = 228, // Reserved + Reserved3 = 229, // Reserved + Reserved4 = 230, // Reserved + Reserved5 = 231, // Reserved + Reserved6 = 232, // Reserved + Reserved7 = 233, // Reserved + Reserved8 = 234, // Reserved + Reserved9 = 235, // Reserved + ReservedA0 = 259, // reserved + ReservedA1 = 260, // reserved + ReservedA2 = 261, // reserved + ReservedB0 = 262, // reserved + ReservedB1 = 263, // reserved ReservedB10 = 272, // reserved ReservedB11 = 273, // reserved ReservedB12 = 274, // reserved @@ -517,7 +517,7 @@ enum class OpCode : unsigned { ReservedB17 = 279, // reserved ReservedB18 = 280, // reserved ReservedB19 = 281, // reserved - ReservedB2 = 264, // reserved + ReservedB2 = 264, // reserved ReservedB20 = 282, // reserved ReservedB21 = 283, // reserved ReservedB22 = 284, // reserved @@ -529,41 +529,36 @@ enum class OpCode : unsigned { ReservedB28 = 290, // reserved ReservedB29 = 291, // reserved ReservedB30 = 292, // reserved - ReservedB5 = 267, // reserved - ReservedB6 = 268, // reserved - ReservedB7 = 269, // reserved - ReservedB8 = 270, // reserved - ReservedB9 = 271, // reserved - ReservedC0 = 293, // reserved - ReservedC1 = 294, // reserved - ReservedC2 = 295, // reserved - ReservedC3 = 296, // reserved - ReservedC4 = 297, // reserved - ReservedC5 = 298, // reserved - ReservedC6 = 299, // reserved - ReservedC7 = 300, // reserved - ReservedC8 = 301, // reserved - ReservedC9 = 302, // reserved + ReservedB5 = 267, // reserved + ReservedB6 = 268, // reserved + ReservedB7 = 269, // reserved + ReservedB8 = 270, // reserved + ReservedB9 = 271, // reserved + ReservedC0 = 293, // reserved + ReservedC1 = 294, // reserved + ReservedC2 = 295, // reserved + ReservedC3 = 296, // reserved + ReservedC4 = 297, // reserved + ReservedC5 = 298, // reserved + ReservedC6 = 299, // reserved + ReservedC7 = 300, // reserved + ReservedC8 = 301, // reserved + ReservedC9 = 302, // reserved + VectorAccumulate = 308, // Vector Accumulate // Amplification shader instructions DispatchMesh = 173, // Amplification shader intrinsic DispatchMesh // AnyHit Terminals - AcceptHitAndEndSearch = - 156, // Used in an any hit shader to abort the ray query and the - // intersection shader (if any). The current hit is committed and - // execution passes to the closest hit shader with the closest hit - // recorded so far - IgnoreHit = 155, // Used in an any hit shader to reject an intersection and - // terminate the shader + AcceptHitAndEndSearch = 156, // Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far + IgnoreHit = 155, // Used in an any hit shader to reject an intersection and terminate the shader // Binary float FMax = 35, // returns a if a >= b, else b FMin = 36, // returns a if a < b, else b // Binary int with two outputs - IMul = 41, // multiply of 32-bit operands to produce the correct full 64-bit - // result. + IMul = 41, // multiply of 32-bit operands to produce the correct full 64-bit result. // Binary int IMax = 37, // IMax(a,b) returns a if a > b, else b @@ -574,10 +569,8 @@ enum class OpCode : unsigned { USubb = 45, // unsigned subtract of 32-bit operands with the borrow // Binary uint with two outputs - UDiv = 43, // unsigned divide of the 32-bit operand src0 by the 32-bit operand - // src1. - UMul = 42, // multiply of 32-bit operands to produce the correct full 64-bit - // result. + UDiv = 43, // unsigned divide of the 32-bit operand src0 by the 32-bit operand src1. + UMul = 42, // multiply of 32-bit operands to produce the correct full 64-bit result. // Binary uint UMax = 39, // unsigned integer maximum. UMax(a,b) = a > b ? a : b @@ -592,50 +585,41 @@ enum class OpCode : unsigned { BitcastI64toF64 = 128, // bitcast between different sizes // Comparison Samples - SampleCmpBias = 255, // samples a texture after applying the input bias to the - // mipmap level and compares a single component against - // the specified comparison value - SampleCmpGrad = - 254, // samples a texture using a gradient and compares a single component - // against the specified comparison value + SampleCmpBias = 255, // samples a texture after applying the input bias to the mipmap level and compares a single component against the specified comparison value + SampleCmpGrad = 254, // samples a texture using a gradient and compares a single component against the specified comparison value // Compute/Mesh/Amplification/Node shader - FlattenedThreadIdInGroup = 96, // provides a flattened index for a given - // thread within a given group (SV_GroupIndex) - GroupId = 94, // reads the group ID (SV_GroupID) - ThreadId = 93, // reads the thread ID - ThreadIdInGroup = - 95, // reads the thread ID within the group (SV_GroupThreadID) + FlattenedThreadIdInGroup = 96, // provides a flattened index for a given thread within a given group (SV_GroupIndex) + GroupId = 94, // reads the group ID (SV_GroupID) + ThreadId = 93, // reads the thread ID + ThreadIdInGroup = 95, // reads the thread ID within the group (SV_GroupThreadID) // Create/Annotate Node Handles AllocateNodeOutputRecords = 238, // returns a handle for the output records - AnnotateNodeHandle = 249, // annotate handle with node properties + AnnotateNodeHandle = 249, // annotate handle with node properties AnnotateNodeRecordHandle = 251, // annotate handle with node record properties CreateNodeInputRecordHandle = 250, // create a handle for an InputRecord - CreateNodeOutputHandle = 247, // Creates a handle to a NodeOutput - IndexNodeHandle = 248, // returns the handle for the location in the output - // node array at the indicated index + CreateNodeOutputHandle = 247, // Creates a handle to a NodeOutput + IndexNodeHandle = 248, // returns the handle for the location in the output node array at the indicated index // Derivatives CalculateLOD = 81, // calculates the level of detail DerivCoarseX = 83, // computes the rate of change per stamp in x direction. DerivCoarseY = 84, // computes the rate of change per stamp in y direction. - DerivFineX = 85, // computes the rate of change per pixel in x direction. - DerivFineY = 86, // computes the rate of change per pixel in y direction. + DerivFineX = 85, // computes the rate of change per pixel in x direction. + DerivFineY = 86, // computes the rate of change per pixel in y direction. // Domain and hull shader LoadOutputControlPoint = 103, // LoadOutputControlPoint - LoadPatchConstant = 104, // LoadPatchConstant + LoadPatchConstant = 104, // LoadPatchConstant // Domain shader DomainLocation = 105, // DomainLocation // Dot product with accumulate - Dot2AddHalf = 162, // 2D half dot product with accumulate to float - Dot4AddI8Packed = 163, // signed dot product of 4 x i8 vectors packed into - // i32, with accumulate to i32 - Dot4AddU8Packed = 164, // unsigned dot product of 4 x u8 vectors packed into - // i32, with accumulate to i32 + Dot2AddHalf = 162, // 2D half dot product with accumulate to float + Dot4AddI8Packed = 163, // signed dot product of 4 x i8 vectors packed into i32, with accumulate to i32 + Dot4AddU8Packed = 164, // unsigned dot product of 4 x u8 vectors packed into i32, with accumulate to i32 // Dot Dot2 = 54, // Two-dimensional vector dot-product @@ -643,34 +627,29 @@ enum class OpCode : unsigned { Dot4 = 56, // Four-dimensional vector dot-product // Double precision - LegacyDoubleToFloat = 132, // legacy fuction to convert double to float + LegacyDoubleToFloat = 132, // legacy fuction to convert double to float LegacyDoubleToSInt32 = 133, // legacy fuction to convert double to int32 LegacyDoubleToUInt32 = 134, // legacy fuction to convert double to uint32 - MakeDouble = 101, // creates a double value - SplitDouble = 102, // splits a double into low and high parts + MakeDouble = 101, // creates a double value + SplitDouble = 102, // splits a double into low and high parts // Extended Command Information - StartInstanceLocation = - 257, // returns the StartInstanceLocation from Draw*Instanced - StartVertexLocation = - 256, // returns the BaseVertexLocation from DrawIndexedInstanced or - // StartVertexLocation from DrawInstanced + StartInstanceLocation = 257, // returns the StartInstanceLocation from Draw*Instanced + StartVertexLocation = 256, // returns the BaseVertexLocation from DrawIndexedInstanced or StartVertexLocation from DrawInstanced // Geometry shader - CutStream = - 98, // completes the current primitive topology at the specified stream - EmitStream = 97, // emits a vertex to a given stream + CutStream = 98, // completes the current primitive topology at the specified stream + EmitStream = 97, // emits a vertex to a given stream EmitThenCutStream = 99, // equivalent to an EmitStream followed by a CutStream - GSInstanceID = 100, // GSInstanceID + GSInstanceID = 100, // GSInstanceID // Get Pointer to Node Record in Address Space 6 - GetNodeRecordPtr = - 239, // retrieve node input/output record pointer in address space 6 + GetNodeRecordPtr = 239, // retrieve node input/output record pointer in address space 6 // Get handle from heap - AnnotateHandle = 216, // annotate handle with resource properties + AnnotateHandle = 216, // annotate handle with resource properties CreateHandleFromBinding = 217, // create resource handle from binding - CreateHandleFromHeap = 218, // create resource handle from heap + CreateHandleFromHeap = 218, // create resource handle from heap // Graphics shader ViewID = 138, // returns the view index @@ -680,267 +659,189 @@ enum class OpCode : unsigned { // Hull shader OutputControlPointID = 107, // OutputControlPointID - StorePatchConstant = 106, // StorePatchConstant + StorePatchConstant = 106, // StorePatchConstant // Hull, Domain and Geometry shaders PrimitiveID = 108, // PrimitiveID // Indirect Shader Invocation - CallShader = 159, // Call a shader in the callable shader table supplied - // through the DispatchRays() API - ReportHit = 158, // returns true if hit was accepted - TraceRay = 157, // initiates raytrace + CallShader = 159, // Call a shader in the callable shader table supplied through the DispatchRays() API + ReportHit = 158, // returns true if hit was accepted + TraceRay = 157, // initiates raytrace // Inline Ray Query - AllocateRayQuery = 178, // allocates space for RayQuery and return handle + AllocateRayQuery = 178, // allocates space for RayQuery and return handle AllocateRayQuery2 = 258, // allocates space for RayQuery and return handle - RayQuery_Abort = 181, // aborts a ray query + RayQuery_Abort = 181, // aborts a ray query RayQuery_CandidateGeometryIndex = 203, // returns candidate hit geometry index - RayQuery_CandidateInstanceContributionToHitGroupIndex = - 214, // returns candidate hit InstanceContributionToHitGroupIndex - RayQuery_CandidateInstanceID = 202, // returns candidate hit instance ID + RayQuery_CandidateInstanceContributionToHitGroupIndex = 214, // returns candidate hit InstanceContributionToHitGroupIndex + RayQuery_CandidateInstanceID = 202, // returns candidate hit instance ID RayQuery_CandidateInstanceIndex = 201, // returns candidate hit instance index - RayQuery_CandidateObjectRayDirection = - 206, // returns candidate object ray direction - RayQuery_CandidateObjectRayOrigin = - 205, // returns candidate hit object ray origin - RayQuery_CandidateObjectToWorld3x4 = - 186, // returns matrix for transforming from object-space to world-space - // for a candidate hit. - RayQuery_CandidatePrimitiveIndex = - 204, // returns candidate hit geometry index - RayQuery_CandidateProceduralPrimitiveNonOpaque = - 190, // returns if current candidate procedural primitive is non opaque - RayQuery_CandidateTriangleBarycentrics = - 193, // returns candidate triangle hit barycentrics - RayQuery_CandidateTriangleFrontFace = - 191, // returns if current candidate triangle is front facing - RayQuery_CandidateTriangleRayT = - 199, // returns float representing the parametric point on the ray for the - // current candidate triangle hit. - RayQuery_CandidateType = - 185, // returns uint candidate type (CANDIDATE_TYPE) of the current hit - // candidate in a ray query, after Proceed() has returned true - RayQuery_CandidateWorldToObject3x4 = - 187, // returns matrix for transforming from world-space to object-space - // for a candidate hit. - RayQuery_CommitNonOpaqueTriangleHit = - 182, // commits a non opaque triangle hit - RayQuery_CommitProceduralPrimitiveHit = - 183, // commits a procedural primitive hit + RayQuery_CandidateObjectRayDirection = 206, // returns candidate object ray direction + RayQuery_CandidateObjectRayOrigin = 205, // returns candidate hit object ray origin + RayQuery_CandidateObjectToWorld3x4 = 186, // returns matrix for transforming from object-space to world-space for a candidate hit. + RayQuery_CandidatePrimitiveIndex = 204, // returns candidate hit geometry index + RayQuery_CandidateProceduralPrimitiveNonOpaque = 190, // returns if current candidate procedural primitive is non opaque + RayQuery_CandidateTriangleBarycentrics = 193, // returns candidate triangle hit barycentrics + RayQuery_CandidateTriangleFrontFace = 191, // returns if current candidate triangle is front facing + RayQuery_CandidateTriangleRayT = 199, // returns float representing the parametric point on the ray for the current candidate triangle hit. + RayQuery_CandidateType = 185, // returns uint candidate type (CANDIDATE_TYPE) of the current hit candidate in a ray query, after Proceed() has returned true + RayQuery_CandidateWorldToObject3x4 = 187, // returns matrix for transforming from world-space to object-space for a candidate hit. + RayQuery_CommitNonOpaqueTriangleHit = 182, // commits a non opaque triangle hit + RayQuery_CommitProceduralPrimitiveHit = 183, // commits a procedural primitive hit RayQuery_CommittedGeometryIndex = 209, // returns committed hit geometry index - RayQuery_CommittedInstanceContributionToHitGroupIndex = - 215, // returns committed hit InstanceContributionToHitGroupIndex - RayQuery_CommittedInstanceID = 208, // returns committed hit instance ID + RayQuery_CommittedInstanceContributionToHitGroupIndex = 215, // returns committed hit InstanceContributionToHitGroupIndex + RayQuery_CommittedInstanceID = 208, // returns committed hit instance ID RayQuery_CommittedInstanceIndex = 207, // returns committed hit instance index - RayQuery_CommittedObjectRayDirection = - 212, // returns committed object ray direction - RayQuery_CommittedObjectRayOrigin = - 211, // returns committed hit object ray origin - RayQuery_CommittedObjectToWorld3x4 = - 188, // returns matrix for transforming from object-space to world-space - // for a Committed hit. - RayQuery_CommittedPrimitiveIndex = - 210, // returns committed hit geometry index - RayQuery_CommittedRayT = - 200, // returns float representing the parametric point on the ray for the - // current committed hit. - RayQuery_CommittedStatus = 184, // returns uint status (COMMITTED_STATUS) of - // the committed hit in a ray query - RayQuery_CommittedTriangleBarycentrics = - 194, // returns committed triangle hit barycentrics - RayQuery_CommittedTriangleFrontFace = - 192, // returns if current committed triangle is front facing - RayQuery_CommittedWorldToObject3x4 = - 189, // returns matrix for transforming from world-space to object-space - // for a Committed hit. - RayQuery_Proceed = 180, // advances a ray query + RayQuery_CommittedObjectRayDirection = 212, // returns committed object ray direction + RayQuery_CommittedObjectRayOrigin = 211, // returns committed hit object ray origin + RayQuery_CommittedObjectToWorld3x4 = 188, // returns matrix for transforming from object-space to world-space for a Committed hit. + RayQuery_CommittedPrimitiveIndex = 210, // returns committed hit geometry index + RayQuery_CommittedRayT = 200, // returns float representing the parametric point on the ray for the current committed hit. + RayQuery_CommittedStatus = 184, // returns uint status (COMMITTED_STATUS) of the committed hit in a ray query + RayQuery_CommittedTriangleBarycentrics = 194, // returns committed triangle hit barycentrics + RayQuery_CommittedTriangleFrontFace = 192, // returns if current committed triangle is front facing + RayQuery_CommittedWorldToObject3x4 = 189, // returns matrix for transforming from world-space to object-space for a Committed hit. + RayQuery_Proceed = 180, // advances a ray query RayQuery_RayFlags = 195, // returns ray flags - RayQuery_RayTMin = 198, // returns float representing the parametric starting - // point for the ray. - RayQuery_TraceRayInline = 179, // initializes RayQuery for raytrace + RayQuery_RayTMin = 198, // returns float representing the parametric starting point for the ray. + RayQuery_TraceRayInline = 179, // initializes RayQuery for raytrace RayQuery_WorldRayDirection = 197, // returns world ray direction - RayQuery_WorldRayOrigin = 196, // returns world ray origin + RayQuery_WorldRayOrigin = 196, // returns world ray origin // Legacy floating-point - LegacyF16ToF32 = 131, // legacy fuction to convert half (f16) to float (f32) - // (this is not related to min-precision) - LegacyF32ToF16 = 130, // legacy fuction to convert float (f32) to half (f16) - // (this is not related to min-precision) + LegacyF16ToF32 = 131, // legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision) + LegacyF32ToF16 = 130, // legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision) // Library create handle from resource struct (like HL intrinsic) - CreateHandleForLib = - 160, // create resource handle from resource struct for library + CreateHandleForLib = 160, // create resource handle from resource struct for library // Mesh shader instructions EmitIndices = 169, // emit a primitive's vertex indices in a mesh shader - GetMeshPayload = - 170, // get the mesh payload which is from amplification shader + GetMeshPayload = 170, // get the mesh payload which is from amplification shader SetMeshOutputCounts = 168, // Mesh shader intrinsic SetMeshOutputCounts - StorePrimitiveOutput = - 172, // stores the value to mesh shader primitive output + StorePrimitiveOutput = 172, // stores the value to mesh shader primitive output StoreVertexOutput = 171, // stores the value to mesh shader vertex output // Other CycleCounterLegacy = 109, // CycleCounterLegacy // Packing intrinsics - Pack4x8 = 220, // packs vector of 4 signed or unsigned values into a packed - // datatype, drops or clamps unused bits + Pack4x8 = 220, // packs vector of 4 signed or unsigned values into a packed datatype, drops or clamps unused bits // Pixel shader - AttributeAtVertex = - 137, // returns the values of the attributes at the vertex. - Coverage = 91, // returns the coverage mask input in a pixel shader - Discard = 82, // discard the current pixel - EvalCentroid = 89, // evaluates an input attribute at pixel center + AttributeAtVertex = 137, // returns the values of the attributes at the vertex. + Coverage = 91, // returns the coverage mask input in a pixel shader + Discard = 82, // discard the current pixel + EvalCentroid = 89, // evaluates an input attribute at pixel center EvalSampleIndex = 88, // evaluates an input attribute at a sample location - EvalSnapped = - 87, // evaluates an input attribute at pixel center with an offset - InnerCoverage = 92, // returns underestimated coverage input from conservative - // rasterization in a pixel shader - SampleIndex = - 90, // returns the sample index in a sample-frequency pixel shader + EvalSnapped = 87, // evaluates an input attribute at pixel center with an offset + InnerCoverage = 92, // returns underestimated coverage input from conservative rasterization in a pixel shader + SampleIndex = 90, // returns the sample index in a sample-frequency pixel shader // Quad Wave Ops - QuadOp = 123, // returns the result of a quad-level operation + QuadOp = 123, // returns the result of a quad-level operation QuadReadLaneAt = 122, // reads from a lane in the quad - QuadVote = 222, // compares boolean accross a quad + QuadVote = 222, // compares boolean accross a quad // Quaternary - Bfi = 53, // Given a bit range from the LSB of a number, places that number of - // bits in another number at any offset + Bfi = 53, // Given a bit range from the LSB of a number, places that number of bits in another number at any offset // Ray Dispatch Arguments - DispatchRaysDimensions = - 146, // The Width and Height values from the D3D12_DISPATCH_RAYS_DESC - // structure provided to the originating DispatchRays() call. - DispatchRaysIndex = - 145, // The current x and y location within the Width and Height + DispatchRaysDimensions = 146, // The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call. + DispatchRaysIndex = 145, // The current x and y location within the Width and Height // Ray Transforms - ObjectToWorld = - 151, // Matrix for transforming from object-space to world-space. - WorldToObject = - 152, // Matrix for transforming from world-space to object-space. + ObjectToWorld = 151, // Matrix for transforming from object-space to world-space. + WorldToObject = 152, // Matrix for transforming from world-space to object-space. // Ray Vectors WorldRayDirection = 148, // The world-space direction for the current ray. - WorldRayOrigin = 147, // The world-space origin for the current ray. + WorldRayOrigin = 147, // The world-space origin for the current ray. // Ray object space Vectors ObjectRayDirection = 150, // Object-space direction for the current ray. - ObjectRayOrigin = 149, // Object-space origin for the current ray. + ObjectRayOrigin = 149, // Object-space origin for the current ray. // RayT - RayTCurrent = - 154, // float representing the current parametric ending point for the ray - RayTMin = - 153, // float representing the parametric starting point for the ray. + RayTCurrent = 154, // float representing the current parametric ending point for the ray + RayTMin = 153, // float representing the parametric starting point for the ray. // Raytracing hit uint System Values - HitKind = 143, // Returns the value passed as HitKind in ReportIntersection(). - // If intersection was reported by fixed-function triangle - // intersection, HitKind will be one of - // HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE. + HitKind = 143, // Returns the value passed as HitKind in ReportIntersection(). If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE. // Raytracing object space uint System Values, raytracing tier 1.1 - GeometryIndex = 213, // The autogenerated index of the current geometry in the - // bottom-level structure + GeometryIndex = 213, // The autogenerated index of the current geometry in the bottom-level structure // Raytracing object space uint System Values - InstanceID = - 141, // The user-provided InstanceID on the bottom-level acceleration - // structure instance within the top-level structure - InstanceIndex = 142, // The autogenerated index of the current instance in the - // top-level structure + InstanceID = 141, // The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure + InstanceIndex = 142, // The autogenerated index of the current instance in the top-level structure PrimitiveIndex = 161, // PrimitiveIndex for raytracing shaders // Raytracing uint System Values RayFlags = 144, // uint containing the current ray flags. // Resources - gather - TextureGather = 73, // gathers the four texels that would be used in a - // bi-linear filtering operation - TextureGatherCmp = 74, // same as TextureGather, except this instrution - // performs comparison on texels, similar to SampleCmp - TextureGatherRaw = 223, // Gather raw elements from 4 texels with no type - // conversions (SRV type is constrained) + TextureGather = 73, // gathers the four texels that would be used in a bi-linear filtering operation + TextureGatherCmp = 74, // same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp + TextureGatherRaw = 223, // Gather raw elements from 4 texels with no type conversions (SRV type is constrained) // Resources - sample - RenderTargetGetSampleCount = - 77, // gets the number of samples for a render target - RenderTargetGetSamplePosition = - 76, // gets the position of the specified sample + RenderTargetGetSampleCount = 77, // gets the number of samples for a render target + RenderTargetGetSamplePosition = 76, // gets the position of the specified sample Sample = 60, // samples a texture - SampleBias = - 61, // samples a texture after applying the input bias to the mipmap level - SampleCmp = 64, // samples a texture and compares a single component against - // the specified comparison value - SampleCmpLevel = 224, // samples a texture and compares a single component - // against the specified comparison value - SampleCmpLevelZero = 65, // samples a texture and compares a single component - // against the specified comparison value - SampleGrad = 63, // samples a texture using a gradient to influence the way - // the sample location is calculated + SampleBias = 61, // samples a texture after applying the input bias to the mipmap level + SampleCmp = 64, // samples a texture and compares a single component against the specified comparison value + SampleCmpLevel = 224, // samples a texture and compares a single component against the specified comparison value + SampleCmpLevelZero = 65, // samples a texture and compares a single component against the specified comparison value + SampleGrad = 63, // samples a texture using a gradient to influence the way the sample location is calculated SampleLevel = 62, // samples a texture using a mipmap-level offset - Texture2DMSGetSamplePosition = - 75, // gets the position of the specified sample + Texture2DMSGetSamplePosition = 75, // gets the position of the specified sample // Resources - BufferLoad = 68, // reads from a TypedBuffer - BufferStore = 69, // writes to a RWTypedBuffer - BufferUpdateCounter = 70, // atomically increments/decrements the hidden - // 32-bit counter stored with a Count or Append UAV - CBufferLoad = 58, // loads a value from a constant buffer resource - CBufferLoadLegacy = 59, // loads a value from a constant buffer resource - CheckAccessFullyMapped = - 71, // determines whether all values from a Sample, Gather, or Load - // operation accessed mapped tiles in a tiled resource - CreateHandle = 57, // creates the handle to a resource - GetDimensions = 72, // gets texture size information - RawBufferLoad = 139, // reads from a raw buffer and structured buffer + BufferLoad = 68, // reads from a TypedBuffer + BufferStore = 69, // writes to a RWTypedBuffer + BufferUpdateCounter = 70, // atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV + CBufferLoad = 58, // loads a value from a constant buffer resource + CBufferLoadLegacy = 59, // loads a value from a constant buffer resource + CheckAccessFullyMapped = 71, // determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource + CreateHandle = 57, // creates the handle to a resource + GetDimensions = 72, // gets texture size information + RawBufferLoad = 139, // reads from a raw buffer and structured buffer RawBufferStore = 140, // writes to a RWByteAddressBuffer or RWStructuredBuffer - TextureLoad = 66, // reads texel data without any filtering or sampling - TextureStore = 67, // reads texel data without any filtering or sampling + TextureLoad = 66, // reads texel data without any filtering or sampling + TextureStore = 67, // reads texel data without any filtering or sampling TextureStoreSample = 225, // stores texel data at specified sample index // Sampler Feedback - WriteSamplerFeedback = - 174, // updates a feedback texture for a sampling operation - WriteSamplerFeedbackBias = 175, // updates a feedback texture for a sampling - // operation with a bias on the mipmap level - WriteSamplerFeedbackGrad = 177, // updates a feedback texture for a sampling - // operation with explicit gradients - WriteSamplerFeedbackLevel = 176, // updates a feedback texture for a sampling - // operation with a mipmap-level offset + WriteSamplerFeedback = 174, // updates a feedback texture for a sampling operation + WriteSamplerFeedbackBias = 175, // updates a feedback texture for a sampling operation with a bias on the mipmap level + WriteSamplerFeedbackGrad = 177, // updates a feedback texture for a sampling operation with explicit gradients + WriteSamplerFeedbackLevel = 176, // updates a feedback texture for a sampling operation with a mipmap-level offset // Shader Execution Reordering HitObject_MakeMiss = 265, // Creates a new HitObject representing a miss - HitObject_MakeNop = 266, // Creates an empty nop HitObject + HitObject_MakeNop = 266, // Creates an empty nop HitObject // Synchronization - AtomicBinOp = 78, // performs an atomic operation on two operands + AtomicBinOp = 78, // performs an atomic operation on two operands AtomicCompareExchange = 79, // atomic compare and exchange to memory - Barrier = 80, // inserts a memory barrier in the shader - BarrierByMemoryHandle = - 245, // Request a barrier for just the memory used by the specified object - BarrierByMemoryType = 244, // Request a barrier for a set of memory types - // and/or thread group execution sync - BarrierByNodeRecordHandle = - 246, // Request a barrier for just the memory used by the node record + Barrier = 80, // inserts a memory barrier in the shader + BarrierByMemoryHandle = 245, // Request a barrier for just the memory used by the specified object + BarrierByMemoryType = 244, // Request a barrier for a set of memory types and/or thread group execution sync + BarrierByNodeRecordHandle = 246, // Request a barrier for just the memory used by the node record // Temporary, indexable, input, output registers - LoadInput = 4, // Loads the value from shader input - MinPrecXRegLoad = 2, // Helper load operation for minprecision + LoadInput = 4, // Loads the value from shader input + MinPrecXRegLoad = 2, // Helper load operation for minprecision MinPrecXRegStore = 3, // Helper store operation for minprecision - StoreOutput = 5, // Stores the value to shader output - TempRegLoad = 0, // Helper load operation - TempRegStore = 1, // Helper store operation + StoreOutput = 5, // Stores the value to shader output + TempRegLoad = 0, // Helper load operation + TempRegStore = 1, // Helper store operation // Tertiary float FMad = 46, // floating point multiply & add - Fma = 47, // fused multiply-add + Fma = 47, // fused multiply-add // Tertiary int IMad = 48, // Signed integer multiply & add @@ -955,87 +856,68 @@ enum class OpCode : unsigned { Round_ne = 26, // floating-point round to integral float. Round_ni = 27, // floating-point round to integral float. Round_pi = 28, // floating-point round to integral float. - Round_z = 29, // floating-point round to integral float. + Round_z = 29, // floating-point round to integral float. // Unary float - Acos = 15, // Returns the arccosine of the specified value. Input should be a - // floating-point value within the range of -1 to 1. - Asin = 16, // Returns the arccosine of the specified value. Input should be a - // floating-point value within the range of -1 to 1 - Atan = 17, // Returns the arctangent of the specified value. The return value - // is within the range of -PI/2 to PI/2. - Cos = 12, // returns cosine(theta) for theta in radians. - Exp = 21, // returns 2^exponent - FAbs = 6, // returns the absolute value of the input value. - Frc = 22, // extract fracitonal component. + Acos = 15, // Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1. + Asin = 16, // Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1 + Atan = 17, // Returns the arctangent of the specified value. The return value is within the range of -PI/2 to PI/2. + Cos = 12, // returns cosine(theta) for theta in radians. + Exp = 21, // returns 2^exponent + FAbs = 6, // returns the absolute value of the input value. + Frc = 22, // extract fracitonal component. Hcos = 18, // returns the hyperbolic cosine of the specified value. Hsin = 19, // returns the hyperbolic sine of the specified value. Htan = 20, // returns the hyperbolic tangent of the specified value. IsFinite = 10, // Returns true if x is finite, false otherwise. - IsInf = 9, // Returns true if x is +INF or -INF, false otherwise. - IsNaN = 8, // Returns true if x is NAN or QNAN, false otherwise. + IsInf = 9, // Returns true if x is +INF or -INF, false otherwise. + IsNaN = 8, // Returns true if x is NAN or QNAN, false otherwise. IsNormal = 11, // returns IsNormal - Log = 23, // returns log base 2. - Rsqrt = 25, // returns reciprocal square root (1 / sqrt(src) - Saturate = 7, // clamps the result of a single or double precision floating - // point value to [0.0f...1.0f] - Sin = 13, // returns sine(theta) for theta in radians. - Sqrt = 24, // returns square root - Tan = 14, // returns tan(theta) for theta in radians. + Log = 23, // returns log base 2. + Rsqrt = 25, // returns reciprocal square root (1 / sqrt(src) + Saturate = 7, // clamps the result of a single or double precision floating point value to [0.0f...1.0f] + Sin = 13, // returns sine(theta) for theta in radians. + Sqrt = 24, // returns square root + Tan = 14, // returns tan(theta) for theta in radians. // Unary int - Bfrev = 30, // Reverses the order of the bits. - Countbits = 31, // Counts the number of bits in the input integer. - FirstbitLo = 32, // Returns the location of the first set bit starting from - // the lowest order bit and working upward. - FirstbitSHi = 34, // Returns the location of the first set bit from the - // highest order bit based on the sign. + Bfrev = 30, // Reverses the order of the bits. + Countbits = 31, // Counts the number of bits in the input integer. + FirstbitLo = 32, // Returns the location of the first set bit starting from the lowest order bit and working upward. + FirstbitSHi = 34, // Returns the location of the first set bit from the highest order bit based on the sign. // Unary uint - FirstbitHi = 33, // Returns the location of the first set bit starting from - // the highest order bit and working downward. + FirstbitHi = 33, // Returns the location of the first set bit starting from the highest order bit and working downward. // Unpacking intrinsics - Unpack4x8 = 219, // unpacks 4 8-bit signed or unsigned values into int32 or - // int16 vector + Unpack4x8 = 219, // unpacks 4 8-bit signed or unsigned values into int32 or int16 vector // Wave WaveActiveAllEqual = 115, // returns 1 if all the lanes have the same value - WaveActiveBallot = 116, // returns a struct with a bit set for each lane where - // the condition is true - WaveActiveBit = 120, // returns the result of the operation across all lanes - WaveActiveOp = 119, // returns the result the operation across waves + WaveActiveBallot = 116, // returns a struct with a bit set for each lane where the condition is true + WaveActiveBit = 120, // returns the result of the operation across all lanes + WaveActiveOp = 119, // returns the result the operation across waves WaveAllBitCount = 135, // returns the count of bits set to 1 across the wave WaveAllTrue = 114, // returns 1 if all the lanes evaluate the value to true WaveAnyTrue = 113, // returns 1 if any of the lane evaluates the value to true WaveGetLaneCount = 112, // returns the number of lanes in the wave WaveGetLaneIndex = 111, // returns the index of the current lane in the wave - WaveIsFirstLane = 110, // returns 1 for the first lane in the wave - WaveMatch = - 165, // returns the bitmask of active lanes that have the same value - WaveMultiPrefixBitCount = 167, // returns the count of bits set to 1 on groups - // of lanes identified by a bitmask - WaveMultiPrefixOp = 166, // returns the result of the operation on groups of - // lanes identified by a bitmask + WaveIsFirstLane = 110, // returns 1 for the first lane in the wave + WaveMatch = 165, // returns the bitmask of active lanes that have the same value + WaveMultiPrefixBitCount = 167, // returns the count of bits set to 1 on groups of lanes identified by a bitmask + WaveMultiPrefixOp = 166, // returns the result of the operation on groups of lanes identified by a bitmask WavePrefixBitCount = 136, // returns the count of bits set to 1 on prior lanes - WavePrefixOp = 121, // returns the result of the operation on prior lanes - WaveReadLaneAt = 117, // returns the value from the specified lane + WavePrefixOp = 121, // returns the result of the operation on prior lanes + WaveReadLaneAt = 117, // returns the value from the specified lane WaveReadLaneFirst = 118, // returns the value from the first lane // Work Graph intrinsics - FinishedCrossGroupSharing = 243, // returns true if the current thread group - // is the last to access the input - GetInputRecordCount = 242, // returns the number of records that have been - // coalesced into the current thread group - GetRemainingRecursionLevels = - 253, // returns how many levels of recursion remain - IncrementOutputCount = - 240, // Select the next logical output count for an EmptyNodeOutput for - // the whole group or per thread. - NodeOutputIsValid = 252, // returns true if the specified output node is - // present in the work graph - OutputComplete = - 241, // indicates all outputs for a given records are complete + FinishedCrossGroupSharing = 243, // returns true if the current thread group is the last to access the input + GetInputRecordCount = 242, // returns the number of records that have been coalesced into the current thread group + GetRemainingRecursionLevels = 253, // returns how many levels of recursion remain + IncrementOutputCount = 240, // Select the next logical output count for an EmptyNodeOutput for the whole group or per thread. + NodeOutputIsValid = 252, // returns true if the specified output node is present in the work graph + OutputComplete = 241, // indicates all outputs for a given records are complete NumOpCodes_Dxil_1_0 = 137, NumOpCodes_Dxil_1_1 = 139, @@ -1046,9 +928,9 @@ enum class OpCode : unsigned { NumOpCodes_Dxil_1_6 = 222, NumOpCodes_Dxil_1_7 = 226, NumOpCodes_Dxil_1_8 = 258, - NumOpCodes_Dxil_1_9 = 305, + NumOpCodes_Dxil_1_9 = 309, - NumOpCodes = 305 // exclusive last value of enumeration + NumOpCodes = 309 // exclusive last value of enumeration }; // OPCODE-ENUM:END @@ -1059,10 +941,14 @@ enum class OpCode : unsigned { // OPCODECLASS-ENUM:BEGIN // Groups for DXIL operations with equivalent function templates enum class OpCodeClass : unsigned { - // + // + MatVecMul, + MatVecMulAdd, + OuterProductAccumulate, RawBufferVectorLoad, RawBufferVectorStore, Reserved, + VectorAccumulate, // Amplification shader instructions DispatchMesh, @@ -1361,9 +1247,9 @@ enum class OpCodeClass : unsigned { NumOpClasses_Dxil_1_6 = 149, NumOpClasses_Dxil_1_7 = 153, NumOpClasses_Dxil_1_8 = 174, - NumOpClasses_Dxil_1_9 = 179, + NumOpClasses_Dxil_1_9 = 183, - NumOpClasses = 179 // exclusive last value of enumeration + NumOpClasses = 183 // exclusive last value of enumeration }; // OPCODECLASS-ENUM:END @@ -1747,7 +1633,7 @@ enum class QuadOpKind { // Kind of bitwise cross-lane operation enum class WaveBitOpKind : unsigned { And = 0, // bitwise and of values - Or = 1, // bitwise or of values + Or = 1, // bitwise or of values Xor = 2, // bitwise xor of values }; // WAVEBITOPKIND-ENUM:END @@ -1759,10 +1645,10 @@ enum class WaveBitOpKind : unsigned { // WAVEOPKIND-ENUM:BEGIN // Kind of cross-lane operation enum class WaveOpKind : unsigned { - Max = 3, // maximum value - Min = 2, // minimum value + Max = 3, // maximum value + Min = 2, // minimum value Product = 1, // product of values - Sum = 0, // sum of values + Sum = 0, // sum of values }; // WAVEOPKIND-ENUM:END @@ -1773,11 +1659,11 @@ enum class WaveOpKind : unsigned { // WAVEMULTIPREFIXOPKIND-ENUM:BEGIN // Kind of cross-lane for multi-prefix operation enum class WaveMultiPrefixOpKind : unsigned { - And = 1, // bitwise and of values - Or = 2, // bitwise or of values + And = 1, // bitwise and of values + Or = 2, // bitwise or of values Product = 4, // product of values - Sum = 0, // sum of values - Xor = 3, // bitwise xor of values + Sum = 0, // sum of values + Xor = 3, // bitwise xor of values }; // WAVEMULTIPREFIXOPKIND-ENUM:END @@ -1788,7 +1674,7 @@ enum class WaveMultiPrefixOpKind : unsigned { // SIGNEDOPKIND-ENUM:BEGIN // Sign vs. unsigned operands for operation enum class SignedOpKind : unsigned { - Signed = 0, // signed integer or floating-point operands + Signed = 0, // signed integer or floating-point operands Unsigned = 1, // unsigned integer operands }; // SIGNEDOPKIND-ENUM:END diff --git a/include/dxc/DXIL/DxilInstructions.h b/include/dxc/DXIL/DxilInstructions.h index 5d78336d2a..8bd4244169 100644 --- a/include/dxc/DXIL/DxilInstructions.h +++ b/include/dxc/DXIL/DxilInstructions.h @@ -31,7 +31,9 @@ struct LlvmInst_Ret { llvm::Instruction *Instr; // Construction and identification LlvmInst_Ret(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::Ret; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::Ret; + } // Validation support bool isAllowed() const { return true; } }; @@ -41,7 +43,9 @@ struct LlvmInst_Br { llvm::Instruction *Instr; // Construction and identification LlvmInst_Br(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::Br; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::Br; + } // Validation support bool isAllowed() const { return true; } }; @@ -111,7 +115,9 @@ struct LlvmInst_Add { llvm::Instruction *Instr; // Construction and identification LlvmInst_Add(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::Add; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::Add; + } // Validation support bool isAllowed() const { return true; } }; @@ -133,7 +139,9 @@ struct LlvmInst_Sub { llvm::Instruction *Instr; // Construction and identification LlvmInst_Sub(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::Sub; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::Sub; + } // Validation support bool isAllowed() const { return true; } }; @@ -155,7 +163,9 @@ struct LlvmInst_Mul { llvm::Instruction *Instr; // Construction and identification LlvmInst_Mul(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::Mul; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::Mul; + } // Validation support bool isAllowed() const { return true; } }; @@ -208,8 +218,7 @@ struct LlvmInst_FDiv { bool isAllowed() const { return true; } }; -/// This instruction returns the remainder from the unsigned division of its two -/// operands +/// This instruction returns the remainder from the unsigned division of its two operands struct LlvmInst_URem { llvm::Instruction *Instr; // Construction and identification @@ -221,8 +230,7 @@ struct LlvmInst_URem { bool isAllowed() const { return true; } }; -/// This instruction returns the remainder from the signed division of its two -/// operands +/// This instruction returns the remainder from the signed division of its two operands struct LlvmInst_SRem { llvm::Instruction *Instr; // Construction and identification @@ -251,7 +259,9 @@ struct LlvmInst_Shl { llvm::Instruction *Instr; // Construction and identification LlvmInst_Shl(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::Shl; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::Shl; + } // Validation support bool isAllowed() const { return true; } }; @@ -285,7 +295,9 @@ struct LlvmInst_And { llvm::Instruction *Instr; // Construction and identification LlvmInst_And(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::And; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::And; + } // Validation support bool isAllowed() const { return true; } }; @@ -295,7 +307,9 @@ struct LlvmInst_Or { llvm::Instruction *Instr; // Construction and identification LlvmInst_Or(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::Or; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::Or; + } // Validation support bool isAllowed() const { return true; } }; @@ -305,13 +319,14 @@ struct LlvmInst_Xor { llvm::Instruction *Instr; // Construction and identification LlvmInst_Xor(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::Xor; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::Xor; + } // Validation support bool isAllowed() const { return true; } }; -/// This instruction allocates memory on the stack frame of the currently -/// executing function +/// This instruction allocates memory on the stack frame of the currently executing function struct LlvmInst_Alloca { llvm::Instruction *Instr; // Construction and identification @@ -580,7 +595,9 @@ struct LlvmInst_PHI { llvm::Instruction *Instr; // Construction and identification LlvmInst_PHI(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { return Instr->getOpcode() == llvm::Instruction::PHI; } + operator bool() const { + return Instr->getOpcode() == llvm::Instruction::PHI; + } // Validation support bool isAllowed() const { return true; } }; @@ -716,8 +733,7 @@ struct DxilInst_TempRegLoad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -737,14 +753,12 @@ struct DxilInst_TempRegStore { // Construction and identification DxilInst_TempRegStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::TempRegStore); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TempRegStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -767,14 +781,12 @@ struct DxilInst_MinPrecXRegLoad { // Construction and identification DxilInst_MinPrecXRegLoad(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::MinPrecXRegLoad); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MinPrecXRegLoad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -800,14 +812,12 @@ struct DxilInst_MinPrecXRegStore { // Construction and identification DxilInst_MinPrecXRegStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::MinPrecXRegStore); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MinPrecXRegStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -841,8 +851,7 @@ struct DxilInst_LoadInput { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -876,8 +885,7 @@ struct DxilInst_StoreOutput { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -911,8 +919,7 @@ struct DxilInst_FAbs { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -926,8 +933,7 @@ struct DxilInst_FAbs { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction clamps the result of a single or double precision floating -/// point value to [0.0f...1.0f] +/// This instruction clamps the result of a single or double precision floating point value to [0.0f...1.0f] struct DxilInst_Saturate { llvm::Instruction *Instr; // Construction and identification @@ -938,8 +944,7 @@ struct DxilInst_Saturate { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -964,8 +969,7 @@ struct DxilInst_IsNaN { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -990,8 +994,7 @@ struct DxilInst_IsInf { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1016,8 +1019,7 @@ struct DxilInst_IsFinite { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1042,8 +1044,7 @@ struct DxilInst_IsNormal { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1068,8 +1069,7 @@ struct DxilInst_Cos { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1094,8 +1094,7 @@ struct DxilInst_Sin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1120,8 +1119,7 @@ struct DxilInst_Tan { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1135,8 +1133,7 @@ struct DxilInst_Tan { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the arccosine of the specified value. Input should -/// be a floating-point value within the range of -1 to 1. +/// This instruction Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1. struct DxilInst_Acos { llvm::Instruction *Instr; // Construction and identification @@ -1147,8 +1144,7 @@ struct DxilInst_Acos { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1162,8 +1158,7 @@ struct DxilInst_Acos { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the arccosine of the specified value. Input should -/// be a floating-point value within the range of -1 to 1 +/// This instruction Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1 struct DxilInst_Asin { llvm::Instruction *Instr; // Construction and identification @@ -1174,8 +1169,7 @@ struct DxilInst_Asin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1189,8 +1183,7 @@ struct DxilInst_Asin { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the arctangent of the specified value. The return -/// value is within the range of -PI/2 to PI/2. +/// This instruction Returns the arctangent of the specified value. The return value is within the range of -PI/2 to PI/2. struct DxilInst_Atan { llvm::Instruction *Instr; // Construction and identification @@ -1201,8 +1194,7 @@ struct DxilInst_Atan { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1227,8 +1219,7 @@ struct DxilInst_Hcos { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1253,8 +1244,7 @@ struct DxilInst_Hsin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1279,8 +1269,7 @@ struct DxilInst_Htan { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1305,8 +1294,7 @@ struct DxilInst_Exp { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1331,8 +1319,7 @@ struct DxilInst_Frc { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1357,8 +1344,7 @@ struct DxilInst_Log { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1383,8 +1369,7 @@ struct DxilInst_Sqrt { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1409,8 +1394,7 @@ struct DxilInst_Rsqrt { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1435,8 +1419,7 @@ struct DxilInst_Round_ne { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1461,8 +1444,7 @@ struct DxilInst_Round_ni { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1487,8 +1469,7 @@ struct DxilInst_Round_pi { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1513,8 +1494,7 @@ struct DxilInst_Round_z { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1539,8 +1519,7 @@ struct DxilInst_Bfrev { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1565,8 +1544,7 @@ struct DxilInst_Countbits { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1580,8 +1558,7 @@ struct DxilInst_Countbits { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the location of the first set bit starting from the -/// lowest order bit and working upward. +/// This instruction Returns the location of the first set bit starting from the lowest order bit and working upward. struct DxilInst_FirstbitLo { llvm::Instruction *Instr; // Construction and identification @@ -1592,8 +1569,7 @@ struct DxilInst_FirstbitLo { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1607,8 +1583,7 @@ struct DxilInst_FirstbitLo { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the location of the first set bit starting from the -/// highest order bit and working downward. +/// This instruction Returns the location of the first set bit starting from the highest order bit and working downward. struct DxilInst_FirstbitHi { llvm::Instruction *Instr; // Construction and identification @@ -1619,8 +1594,7 @@ struct DxilInst_FirstbitHi { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1634,8 +1608,7 @@ struct DxilInst_FirstbitHi { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the location of the first set bit from the highest -/// order bit based on the sign. +/// This instruction Returns the location of the first set bit from the highest order bit based on the sign. struct DxilInst_FirstbitSHi { llvm::Instruction *Instr; // Construction and identification @@ -1646,8 +1619,7 @@ struct DxilInst_FirstbitSHi { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1672,8 +1644,7 @@ struct DxilInst_FMax { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1701,8 +1672,7 @@ struct DxilInst_FMin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1730,8 +1700,7 @@ struct DxilInst_IMax { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1759,8 +1728,7 @@ struct DxilInst_IMin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1788,8 +1756,7 @@ struct DxilInst_UMax { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1817,8 +1784,7 @@ struct DxilInst_UMin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1835,8 +1801,7 @@ struct DxilInst_UMin { void set_b(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction multiply of 32-bit operands to produce the correct full -/// 64-bit result. +/// This instruction multiply of 32-bit operands to produce the correct full 64-bit result. struct DxilInst_IMul { llvm::Instruction *Instr; // Construction and identification @@ -1847,8 +1812,7 @@ struct DxilInst_IMul { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1865,8 +1829,7 @@ struct DxilInst_IMul { void set_b(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction multiply of 32-bit operands to produce the correct full -/// 64-bit result. +/// This instruction multiply of 32-bit operands to produce the correct full 64-bit result. struct DxilInst_UMul { llvm::Instruction *Instr; // Construction and identification @@ -1877,8 +1840,7 @@ struct DxilInst_UMul { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1895,8 +1857,7 @@ struct DxilInst_UMul { void set_b(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction unsigned divide of the 32-bit operand src0 by the 32-bit -/// operand src1. +/// This instruction unsigned divide of the 32-bit operand src0 by the 32-bit operand src1. struct DxilInst_UDiv { llvm::Instruction *Instr; // Construction and identification @@ -1907,8 +1868,7 @@ struct DxilInst_UDiv { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1936,8 +1896,7 @@ struct DxilInst_UAddc { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1965,8 +1924,7 @@ struct DxilInst_USubb { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -1994,8 +1952,7 @@ struct DxilInst_FMad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2026,8 +1983,7 @@ struct DxilInst_Fma { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2058,8 +2014,7 @@ struct DxilInst_IMad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2090,8 +2045,7 @@ struct DxilInst_UMad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2122,8 +2076,7 @@ struct DxilInst_Msad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2154,8 +2107,7 @@ struct DxilInst_Ibfe { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2186,8 +2138,7 @@ struct DxilInst_Ubfe { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2207,8 +2158,7 @@ struct DxilInst_Ubfe { void set_c(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction Given a bit range from the LSB of a number, places that -/// number of bits in another number at any offset +/// This instruction Given a bit range from the LSB of a number, places that number of bits in another number at any offset struct DxilInst_Bfi { llvm::Instruction *Instr; // Construction and identification @@ -2219,8 +2169,7 @@ struct DxilInst_Bfi { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2254,8 +2203,7 @@ struct DxilInst_Dot2 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2289,8 +2237,7 @@ struct DxilInst_Dot3 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2330,8 +2277,7 @@ struct DxilInst_Dot4 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2372,14 +2318,12 @@ struct DxilInst_CreateHandle { // Construction and identification DxilInst_CreateHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::CreateHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2394,39 +2338,18 @@ struct DxilInst_CreateHandle { // Accessors llvm::Value *get_resourceClass() const { return Instr->getOperand(1); } void set_resourceClass(llvm::Value *val) { Instr->setOperand(1, val); } - int8_t get_resourceClass_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(1)) - ->getZExtValue()); - } - void set_resourceClass_val(int8_t val) { - Instr->setOperand(1, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_resourceClass_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } + void set_resourceClass_val(int8_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } llvm::Value *get_rangeId() const { return Instr->getOperand(2); } void set_rangeId(llvm::Value *val) { Instr->setOperand(2, val); } - int32_t get_rangeId_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_rangeId_val(int32_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_rangeId_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_rangeId_val(int32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } llvm::Value *get_index() const { return Instr->getOperand(3); } void set_index(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_nonUniformIndex() const { return Instr->getOperand(4); } void set_nonUniformIndex(llvm::Value *val) { Instr->setOperand(4, val); } - bool get_nonUniformIndex_val() const { - return (bool)(llvm::dyn_cast(Instr->getOperand(4)) - ->getZExtValue()); - } - void set_nonUniformIndex_val(bool val) { - Instr->setOperand(4, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 1), - llvm::APInt(1, (uint64_t)val))); - } + bool get_nonUniformIndex_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(4))->getZExtValue()); } + void set_nonUniformIndex_val(bool val) { Instr->setOperand(4, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } }; /// This instruction loads a value from a constant buffer resource @@ -2440,8 +2363,7 @@ struct DxilInst_CBufferLoad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2459,15 +2381,8 @@ struct DxilInst_CBufferLoad { void set_byteOffset(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_alignment() const { return Instr->getOperand(3); } void set_alignment(llvm::Value *val) { Instr->setOperand(3, val); } - uint32_t get_alignment_val() const { - return (uint32_t)(llvm::dyn_cast(Instr->getOperand(3)) - ->getZExtValue()); - } - void set_alignment_val(uint32_t val) { - Instr->setOperand(3, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + uint32_t get_alignment_val() const { return (uint32_t)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } + void set_alignment_val(uint32_t val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; /// This instruction loads a value from a constant buffer resource @@ -2476,14 +2391,12 @@ struct DxilInst_CBufferLoadLegacy { // Construction and identification DxilInst_CBufferLoadLegacy(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::CBufferLoadLegacy); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CBufferLoadLegacy); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2511,8 +2424,7 @@ struct DxilInst_Sample { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2553,8 +2465,7 @@ struct DxilInst_Sample { void set_clamp(llvm::Value *val) { Instr->setOperand(10, val); } }; -/// This instruction samples a texture after applying the input bias to the -/// mipmap level +/// This instruction samples a texture after applying the input bias to the mipmap level struct DxilInst_SampleBias { llvm::Instruction *Instr; // Construction and identification @@ -2565,8 +2476,7 @@ struct DxilInst_SampleBias { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2621,8 +2531,7 @@ struct DxilInst_SampleLevel { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2663,8 +2572,7 @@ struct DxilInst_SampleLevel { void set_LOD(llvm::Value *val) { Instr->setOperand(10, val); } }; -/// This instruction samples a texture using a gradient to influence the way the -/// sample location is calculated +/// This instruction samples a texture using a gradient to influence the way the sample location is calculated struct DxilInst_SampleGrad { llvm::Instruction *Instr; // Construction and identification @@ -2675,8 +2583,7 @@ struct DxilInst_SampleGrad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (17 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (17 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2735,8 +2642,7 @@ struct DxilInst_SampleGrad { void set_clamp(llvm::Value *val) { Instr->setOperand(16, val); } }; -/// This instruction samples a texture and compares a single component against -/// the specified comparison value +/// This instruction samples a texture and compares a single component against the specified comparison value struct DxilInst_SampleCmp { llvm::Instruction *Instr; // Construction and identification @@ -2747,8 +2653,7 @@ struct DxilInst_SampleCmp { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2792,21 +2697,18 @@ struct DxilInst_SampleCmp { void set_clamp(llvm::Value *val) { Instr->setOperand(11, val); } }; -/// This instruction samples a texture and compares a single component against -/// the specified comparison value +/// This instruction samples a texture and compares a single component against the specified comparison value struct DxilInst_SampleCmpLevelZero { llvm::Instruction *Instr; // Construction and identification DxilInst_SampleCmpLevelZero(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::SampleCmpLevelZero); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpLevelZero); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2858,8 +2760,7 @@ struct DxilInst_TextureLoad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2878,12 +2779,8 @@ struct DxilInst_TextureLoad { // Accessors llvm::Value *get_srv() const { return Instr->getOperand(1); } void set_srv(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_mipLevelOrSampleCount() const { - return Instr->getOperand(2); - } - void set_mipLevelOrSampleCount(llvm::Value *val) { - Instr->setOperand(2, val); - } + llvm::Value *get_mipLevelOrSampleCount() const { return Instr->getOperand(2); } + void set_mipLevelOrSampleCount(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_coord0() const { return Instr->getOperand(3); } void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_coord1() const { return Instr->getOperand(4); } @@ -2904,14 +2801,12 @@ struct DxilInst_TextureStore { // Construction and identification DxilInst_TextureStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::TextureStore); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2960,8 +2855,7 @@ struct DxilInst_BufferLoad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -2992,8 +2886,7 @@ struct DxilInst_BufferStore { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3028,21 +2921,18 @@ struct DxilInst_BufferStore { void set_mask(llvm::Value *val) { Instr->setOperand(8, val); } }; -/// This instruction atomically increments/decrements the hidden 32-bit counter -/// stored with a Count or Append UAV +/// This instruction atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV struct DxilInst_BufferUpdateCounter { llvm::Instruction *Instr; // Construction and identification DxilInst_BufferUpdateCounter(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::BufferUpdateCounter); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BufferUpdateCounter); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3059,21 +2949,18 @@ struct DxilInst_BufferUpdateCounter { void set_inc(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction determines whether all values from a Sample, Gather, or -/// Load operation accessed mapped tiles in a tiled resource +/// This instruction determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource struct DxilInst_CheckAccessFullyMapped { llvm::Instruction *Instr; // Construction and identification DxilInst_CheckAccessFullyMapped(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::CheckAccessFullyMapped); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CheckAccessFullyMapped); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3093,14 +2980,12 @@ struct DxilInst_GetDimensions { // Construction and identification DxilInst_GetDimensions(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::GetDimensions); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetDimensions); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3117,21 +3002,18 @@ struct DxilInst_GetDimensions { void set_mipLevel(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction gathers the four texels that would be used in a bi-linear -/// filtering operation +/// This instruction gathers the four texels that would be used in a bi-linear filtering operation struct DxilInst_TextureGather { llvm::Instruction *Instr; // Construction and identification DxilInst_TextureGather(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::TextureGather); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGather); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3169,21 +3051,18 @@ struct DxilInst_TextureGather { void set_channel(llvm::Value *val) { Instr->setOperand(9, val); } }; -/// This instruction same as TextureGather, except this instrution performs -/// comparison on texels, similar to SampleCmp +/// This instruction same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp struct DxilInst_TextureGatherCmp { llvm::Instruction *Instr; // Construction and identification DxilInst_TextureGatherCmp(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::TextureGatherCmp); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGatherCmp); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3228,17 +3107,14 @@ struct DxilInst_TextureGatherCmp { struct DxilInst_Texture2DMSGetSamplePosition { llvm::Instruction *Instr; // Construction and identification - DxilInst_Texture2DMSGetSamplePosition(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_Texture2DMSGetSamplePosition(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::Texture2DMSGetSamplePosition); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Texture2DMSGetSamplePosition); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3259,17 +3135,14 @@ struct DxilInst_Texture2DMSGetSamplePosition { struct DxilInst_RenderTargetGetSamplePosition { llvm::Instruction *Instr; // Construction and identification - DxilInst_RenderTargetGetSamplePosition(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RenderTargetGetSamplePosition(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RenderTargetGetSamplePosition); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RenderTargetGetSamplePosition); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3287,17 +3160,14 @@ struct DxilInst_RenderTargetGetSamplePosition { struct DxilInst_RenderTargetGetSampleCount { llvm::Instruction *Instr; // Construction and identification - DxilInst_RenderTargetGetSampleCount(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RenderTargetGetSampleCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RenderTargetGetSampleCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RenderTargetGetSampleCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3315,8 +3185,7 @@ struct DxilInst_AtomicBinOp { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3351,14 +3220,12 @@ struct DxilInst_AtomicCompareExchange { // Construction and identification DxilInst_AtomicCompareExchange(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::AtomicCompareExchange); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AtomicCompareExchange); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3398,8 +3265,7 @@ struct DxilInst_Barrier { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3411,15 +3277,8 @@ struct DxilInst_Barrier { // Accessors llvm::Value *get_barrierMode() const { return Instr->getOperand(1); } void set_barrierMode(llvm::Value *val) { Instr->setOperand(1, val); } - int32_t get_barrierMode_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(1)) - ->getZExtValue()); - } - void set_barrierMode_val(int32_t val) { - Instr->setOperand(1, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_barrierMode_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } + void set_barrierMode_val(int32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; /// This instruction calculates the level of detail @@ -3428,14 +3287,12 @@ struct DxilInst_CalculateLOD { // Construction and identification DxilInst_CalculateLOD(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::CalculateLOD); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CalculateLOD); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3475,8 +3332,7 @@ struct DxilInst_Discard { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3496,14 +3352,12 @@ struct DxilInst_DerivCoarseX { // Construction and identification DxilInst_DerivCoarseX(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::DerivCoarseX); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivCoarseX); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3523,14 +3377,12 @@ struct DxilInst_DerivCoarseY { // Construction and identification DxilInst_DerivCoarseY(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::DerivCoarseY); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivCoarseY); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3555,8 +3407,7 @@ struct DxilInst_DerivFineX { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3581,8 +3432,7 @@ struct DxilInst_DerivFineY { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3607,8 +3457,7 @@ struct DxilInst_EvalSnapped { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3640,14 +3489,12 @@ struct DxilInst_EvalSampleIndex { // Construction and identification DxilInst_EvalSampleIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::EvalSampleIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalSampleIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3676,14 +3523,12 @@ struct DxilInst_EvalCentroid { // Construction and identification DxilInst_EvalCentroid(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::EvalCentroid); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalCentroid); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3714,8 +3559,7 @@ struct DxilInst_SampleIndex { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3733,29 +3577,25 @@ struct DxilInst_Coverage { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction returns underestimated coverage input from conservative -/// rasterization in a pixel shader +/// This instruction returns underestimated coverage input from conservative rasterization in a pixel shader struct DxilInst_InnerCoverage { llvm::Instruction *Instr; // Construction and identification DxilInst_InnerCoverage(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::InnerCoverage); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::InnerCoverage); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3773,8 +3613,7 @@ struct DxilInst_ThreadId { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3799,8 +3638,7 @@ struct DxilInst_GroupId { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3820,14 +3658,12 @@ struct DxilInst_ThreadIdInGroup { // Construction and identification DxilInst_ThreadIdInGroup(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::ThreadIdInGroup); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ThreadIdInGroup); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3841,22 +3677,18 @@ struct DxilInst_ThreadIdInGroup { void set_component(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction provides a flattened index for a given thread within a -/// given group (SV_GroupIndex) +/// This instruction provides a flattened index for a given thread within a given group (SV_GroupIndex) struct DxilInst_FlattenedThreadIdInGroup { llvm::Instruction *Instr; // Construction and identification - DxilInst_FlattenedThreadIdInGroup(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_FlattenedThreadIdInGroup(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::FlattenedThreadIdInGroup); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FlattenedThreadIdInGroup); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3874,8 +3706,7 @@ struct DxilInst_EmitStream { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3889,8 +3720,7 @@ struct DxilInst_EmitStream { void set_streamId(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction completes the current primitive topology at the specified -/// stream +/// This instruction completes the current primitive topology at the specified stream struct DxilInst_CutStream { llvm::Instruction *Instr; // Construction and identification @@ -3901,8 +3731,7 @@ struct DxilInst_CutStream { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3922,14 +3751,12 @@ struct DxilInst_EmitThenCutStream { // Construction and identification DxilInst_EmitThenCutStream(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::EmitThenCutStream); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EmitThenCutStream); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3949,14 +3776,12 @@ struct DxilInst_GSInstanceID { // Construction and identification DxilInst_GSInstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::GSInstanceID); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GSInstanceID); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -3974,8 +3799,7 @@ struct DxilInst_MakeDouble { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4003,8 +3827,7 @@ struct DxilInst_SplitDouble { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4024,14 +3847,12 @@ struct DxilInst_LoadOutputControlPoint { // Construction and identification DxilInst_LoadOutputControlPoint(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::LoadOutputControlPoint); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadOutputControlPoint); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4060,14 +3881,12 @@ struct DxilInst_LoadPatchConstant { // Construction and identification DxilInst_LoadPatchConstant(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::LoadPatchConstant); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadPatchConstant); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4093,14 +3912,12 @@ struct DxilInst_DomainLocation { // Construction and identification DxilInst_DomainLocation(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::DomainLocation); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DomainLocation); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4112,15 +3929,8 @@ struct DxilInst_DomainLocation { // Accessors llvm::Value *get_component() const { return Instr->getOperand(1); } void set_component(llvm::Value *val) { Instr->setOperand(1, val); } - int8_t get_component_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(1)) - ->getZExtValue()); - } - void set_component_val(int8_t val) { - Instr->setOperand(1, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } + void set_component_val(int8_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction StorePatchConstant @@ -4129,14 +3939,12 @@ struct DxilInst_StorePatchConstant { // Construction and identification DxilInst_StorePatchConstant(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::StorePatchConstant); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StorePatchConstant); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4165,14 +3973,12 @@ struct DxilInst_OutputControlPointID { // Construction and identification DxilInst_OutputControlPointID(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::OutputControlPointID); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::OutputControlPointID); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4190,8 +3996,7 @@ struct DxilInst_PrimitiveID { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4204,14 +4009,12 @@ struct DxilInst_CycleCounterLegacy { // Construction and identification DxilInst_CycleCounterLegacy(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::CycleCounterLegacy); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CycleCounterLegacy); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4224,14 +4027,12 @@ struct DxilInst_WaveIsFirstLane { // Construction and identification DxilInst_WaveIsFirstLane(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveIsFirstLane); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveIsFirstLane); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4244,14 +4045,12 @@ struct DxilInst_WaveGetLaneIndex { // Construction and identification DxilInst_WaveGetLaneIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveGetLaneIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveGetLaneIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4264,14 +4063,12 @@ struct DxilInst_WaveGetLaneCount { // Construction and identification DxilInst_WaveGetLaneCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveGetLaneCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveGetLaneCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4289,8 +4086,7 @@ struct DxilInst_WaveAnyTrue { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4315,8 +4111,7 @@ struct DxilInst_WaveAllTrue { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4336,14 +4131,12 @@ struct DxilInst_WaveActiveAllEqual { // Construction and identification DxilInst_WaveActiveAllEqual(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveActiveAllEqual); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveAllEqual); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4357,21 +4150,18 @@ struct DxilInst_WaveActiveAllEqual { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns a struct with a bit set for each lane where the -/// condition is true +/// This instruction returns a struct with a bit set for each lane where the condition is true struct DxilInst_WaveActiveBallot { llvm::Instruction *Instr; // Construction and identification DxilInst_WaveActiveBallot(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveActiveBallot); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveBallot); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4391,14 +4181,12 @@ struct DxilInst_WaveReadLaneAt { // Construction and identification DxilInst_WaveReadLaneAt(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveReadLaneAt); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveReadLaneAt); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4421,14 +4209,12 @@ struct DxilInst_WaveReadLaneFirst { // Construction and identification DxilInst_WaveReadLaneFirst(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveReadLaneFirst); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveReadLaneFirst); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4448,14 +4234,12 @@ struct DxilInst_WaveActiveOp { // Construction and identification DxilInst_WaveActiveOp(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveActiveOp); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveOp); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4471,26 +4255,12 @@ struct DxilInst_WaveActiveOp { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_op_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } llvm::Value *get_sop() const { return Instr->getOperand(3); } void set_sop(llvm::Value *val) { Instr->setOperand(3, val); } - int8_t get_sop_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(3)) - ->getZExtValue()); - } - void set_sop_val(int8_t val) { - Instr->setOperand(3, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } + void set_sop_val(int8_t val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction returns the result of the operation across all lanes @@ -4499,14 +4269,12 @@ struct DxilInst_WaveActiveBit { // Construction and identification DxilInst_WaveActiveBit(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveActiveBit); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveBit); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4521,15 +4289,8 @@ struct DxilInst_WaveActiveBit { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_op_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction returns the result of the operation on prior lanes @@ -4538,14 +4299,12 @@ struct DxilInst_WavePrefixOp { // Construction and identification DxilInst_WavePrefixOp(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WavePrefixOp); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WavePrefixOp); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4561,26 +4320,12 @@ struct DxilInst_WavePrefixOp { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_op_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } llvm::Value *get_sop() const { return Instr->getOperand(3); } void set_sop(llvm::Value *val) { Instr->setOperand(3, val); } - int8_t get_sop_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(3)) - ->getZExtValue()); - } - void set_sop_val(int8_t val) { - Instr->setOperand(3, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } + void set_sop_val(int8_t val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction reads from a lane in the quad @@ -4589,14 +4334,12 @@ struct DxilInst_QuadReadLaneAt { // Construction and identification DxilInst_QuadReadLaneAt(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::QuadReadLaneAt); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::QuadReadLaneAt); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4624,8 +4367,7 @@ struct DxilInst_QuadOp { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4640,15 +4382,8 @@ struct DxilInst_QuadOp { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_op_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction bitcast between different sizes @@ -4657,14 +4392,12 @@ struct DxilInst_BitcastI16toF16 { // Construction and identification DxilInst_BitcastI16toF16(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::BitcastI16toF16); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI16toF16); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4684,14 +4417,12 @@ struct DxilInst_BitcastF16toI16 { // Construction and identification DxilInst_BitcastF16toI16(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::BitcastF16toI16); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF16toI16); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4711,14 +4442,12 @@ struct DxilInst_BitcastI32toF32 { // Construction and identification DxilInst_BitcastI32toF32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::BitcastI32toF32); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI32toF32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4738,14 +4467,12 @@ struct DxilInst_BitcastF32toI32 { // Construction and identification DxilInst_BitcastF32toI32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::BitcastF32toI32); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF32toI32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4765,14 +4492,12 @@ struct DxilInst_BitcastI64toF64 { // Construction and identification DxilInst_BitcastI64toF64(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::BitcastI64toF64); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI64toF64); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4792,14 +4517,12 @@ struct DxilInst_BitcastF64toI64 { // Construction and identification DxilInst_BitcastF64toI64(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::BitcastF64toI64); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF64toI64); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4813,21 +4536,18 @@ struct DxilInst_BitcastF64toI64 { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction legacy fuction to convert float (f32) to half (f16) (this -/// is not related to min-precision) +/// This instruction legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision) struct DxilInst_LegacyF32ToF16 { llvm::Instruction *Instr; // Construction and identification DxilInst_LegacyF32ToF16(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::LegacyF32ToF16); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyF32ToF16); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4841,21 +4561,18 @@ struct DxilInst_LegacyF32ToF16 { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction legacy fuction to convert half (f16) to float (f32) (this -/// is not related to min-precision) +/// This instruction legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision) struct DxilInst_LegacyF16ToF32 { llvm::Instruction *Instr; // Construction and identification DxilInst_LegacyF16ToF32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::LegacyF16ToF32); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyF16ToF32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4875,14 +4592,12 @@ struct DxilInst_LegacyDoubleToFloat { // Construction and identification DxilInst_LegacyDoubleToFloat(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::LegacyDoubleToFloat); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToFloat); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4902,14 +4617,12 @@ struct DxilInst_LegacyDoubleToSInt32 { // Construction and identification DxilInst_LegacyDoubleToSInt32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::LegacyDoubleToSInt32); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToSInt32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4929,14 +4642,12 @@ struct DxilInst_LegacyDoubleToUInt32 { // Construction and identification DxilInst_LegacyDoubleToUInt32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::LegacyDoubleToUInt32); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToUInt32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4956,14 +4667,12 @@ struct DxilInst_WaveAllBitCount { // Construction and identification DxilInst_WaveAllBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveAllBitCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveAllBitCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -4983,14 +4692,12 @@ struct DxilInst_WavePrefixBitCount { // Construction and identification DxilInst_WavePrefixBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WavePrefixBitCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WavePrefixBitCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5010,14 +4717,12 @@ struct DxilInst_AttributeAtVertex { // Construction and identification DxilInst_AttributeAtVertex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::AttributeAtVertex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AttributeAtVertex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5051,8 +4756,7 @@ struct DxilInst_ViewID { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5065,14 +4769,12 @@ struct DxilInst_RawBufferLoad { // Construction and identification DxilInst_RawBufferLoad(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::RawBufferLoad); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferLoad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5094,26 +4796,12 @@ struct DxilInst_RawBufferLoad { void set_elementOffset(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_mask() const { return Instr->getOperand(4); } void set_mask(llvm::Value *val) { Instr->setOperand(4, val); } - int8_t get_mask_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(4)) - ->getZExtValue()); - } - void set_mask_val(int8_t val) { - Instr->setOperand(4, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_mask_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(4))->getZExtValue()); } + void set_mask_val(int8_t val) { Instr->setOperand(4, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } llvm::Value *get_alignment() const { return Instr->getOperand(5); } void set_alignment(llvm::Value *val) { Instr->setOperand(5, val); } - int32_t get_alignment_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(5)) - ->getZExtValue()); - } - void set_alignment_val(int32_t val) { - Instr->setOperand(5, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(5))->getZExtValue()); } + void set_alignment_val(int32_t val) { Instr->setOperand(5, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; /// This instruction writes to a RWByteAddressBuffer or RWStructuredBuffer @@ -5122,14 +4810,12 @@ struct DxilInst_RawBufferStore { // Construction and identification DxilInst_RawBufferStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::RawBufferStore); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5163,30 +4849,15 @@ struct DxilInst_RawBufferStore { void set_value3(llvm::Value *val) { Instr->setOperand(7, val); } llvm::Value *get_mask() const { return Instr->getOperand(8); } void set_mask(llvm::Value *val) { Instr->setOperand(8, val); } - int8_t get_mask_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(8)) - ->getZExtValue()); - } - void set_mask_val(int8_t val) { - Instr->setOperand(8, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_mask_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(8))->getZExtValue()); } + void set_mask_val(int8_t val) { Instr->setOperand(8, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } llvm::Value *get_alignment() const { return Instr->getOperand(9); } void set_alignment(llvm::Value *val) { Instr->setOperand(9, val); } - int32_t get_alignment_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(9)) - ->getZExtValue()); - } - void set_alignment_val(int32_t val) { - Instr->setOperand(9, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(9))->getZExtValue()); } + void set_alignment_val(int32_t val) { Instr->setOperand(9, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; -/// This instruction The user-provided InstanceID on the bottom-level -/// acceleration structure instance within the top-level structure +/// This instruction The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure struct DxilInst_InstanceID { llvm::Instruction *Instr; // Construction and identification @@ -5197,39 +4868,32 @@ struct DxilInst_InstanceID { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction The autogenerated index of the current instance in the -/// top-level structure +/// This instruction The autogenerated index of the current instance in the top-level structure struct DxilInst_InstanceIndex { llvm::Instruction *Instr; // Construction and identification DxilInst_InstanceIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::InstanceIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::InstanceIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction Returns the value passed as HitKind in -/// ReportIntersection(). If intersection was reported by fixed-function -/// triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE -/// or HIT_KIND_TRIANGLE_BACK_FACE. +/// This instruction Returns the value passed as HitKind in ReportIntersection(). If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE. struct DxilInst_HitKind { llvm::Instruction *Instr; // Construction and identification @@ -5240,8 +4904,7 @@ struct DxilInst_HitKind { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5259,8 +4922,7 @@ struct DxilInst_RayFlags { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5273,14 +4935,12 @@ struct DxilInst_DispatchRaysIndex { // Construction and identification DxilInst_DispatchRaysIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::DispatchRaysIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DispatchRaysIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5294,22 +4954,18 @@ struct DxilInst_DispatchRaysIndex { void set_col(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction The Width and Height values from the -/// D3D12_DISPATCH_RAYS_DESC structure provided to the originating -/// DispatchRays() call. +/// This instruction The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call. struct DxilInst_DispatchRaysDimensions { llvm::Instruction *Instr; // Construction and identification DxilInst_DispatchRaysDimensions(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::DispatchRaysDimensions); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DispatchRaysDimensions); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5329,14 +4985,12 @@ struct DxilInst_WorldRayOrigin { // Construction and identification DxilInst_WorldRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WorldRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WorldRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5356,14 +5010,12 @@ struct DxilInst_WorldRayDirection { // Construction and identification DxilInst_WorldRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WorldRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WorldRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5383,14 +5035,12 @@ struct DxilInst_ObjectRayOrigin { // Construction and identification DxilInst_ObjectRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::ObjectRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ObjectRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5410,14 +5060,12 @@ struct DxilInst_ObjectRayDirection { // Construction and identification DxilInst_ObjectRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::ObjectRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ObjectRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5437,14 +5085,12 @@ struct DxilInst_ObjectToWorld { // Construction and identification DxilInst_ObjectToWorld(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::ObjectToWorld); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ObjectToWorld); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5467,14 +5113,12 @@ struct DxilInst_WorldToObject { // Construction and identification DxilInst_WorldToObject(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WorldToObject); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WorldToObject); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5491,8 +5135,7 @@ struct DxilInst_WorldToObject { void set_col(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction float representing the parametric starting point for the -/// ray. +/// This instruction float representing the parametric starting point for the ray. struct DxilInst_RayTMin { llvm::Instruction *Instr; // Construction and identification @@ -5503,16 +5146,14 @@ struct DxilInst_RayTMin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction float representing the current parametric ending point for -/// the ray +/// This instruction float representing the current parametric ending point for the ray struct DxilInst_RayTCurrent { llvm::Instruction *Instr; // Construction and identification @@ -5523,16 +5164,14 @@ struct DxilInst_RayTCurrent { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction Used in an any hit shader to reject an intersection and -/// terminate the shader +/// This instruction Used in an any hit shader to reject an intersection and terminate the shader struct DxilInst_IgnoreHit { llvm::Instruction *Instr; // Construction and identification @@ -5543,30 +5182,25 @@ struct DxilInst_IgnoreHit { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction Used in an any hit shader to abort the ray query and the -/// intersection shader (if any). The current hit is committed and execution -/// passes to the closest hit shader with the closest hit recorded so far +/// This instruction Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far struct DxilInst_AcceptHitAndEndSearch { llvm::Instruction *Instr; // Construction and identification DxilInst_AcceptHitAndEndSearch(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::AcceptHitAndEndSearch); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AcceptHitAndEndSearch); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5584,8 +5218,7 @@ struct DxilInst_TraceRay { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (16 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (16 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5609,32 +5242,16 @@ struct DxilInst_TraceRay { arg_payload = 15, }; // Accessors - llvm::Value *get_AccelerationStructure() const { - return Instr->getOperand(1); - } - void set_AccelerationStructure(llvm::Value *val) { - Instr->setOperand(1, val); - } + llvm::Value *get_AccelerationStructure() const { return Instr->getOperand(1); } + void set_AccelerationStructure(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_RayFlags() const { return Instr->getOperand(2); } void set_RayFlags(llvm::Value *val) { Instr->setOperand(2, val); } - llvm::Value *get_InstanceInclusionMask() const { - return Instr->getOperand(3); - } - void set_InstanceInclusionMask(llvm::Value *val) { - Instr->setOperand(3, val); - } - llvm::Value *get_RayContributionToHitGroupIndex() const { - return Instr->getOperand(4); - } - void set_RayContributionToHitGroupIndex(llvm::Value *val) { - Instr->setOperand(4, val); - } - llvm::Value *get_MultiplierForGeometryContributionToShaderIndex() const { - return Instr->getOperand(5); - } - void set_MultiplierForGeometryContributionToShaderIndex(llvm::Value *val) { - Instr->setOperand(5, val); - } + llvm::Value *get_InstanceInclusionMask() const { return Instr->getOperand(3); } + void set_InstanceInclusionMask(llvm::Value *val) { Instr->setOperand(3, val); } + llvm::Value *get_RayContributionToHitGroupIndex() const { return Instr->getOperand(4); } + void set_RayContributionToHitGroupIndex(llvm::Value *val) { Instr->setOperand(4, val); } + llvm::Value *get_MultiplierForGeometryContributionToShaderIndex() const { return Instr->getOperand(5); } + void set_MultiplierForGeometryContributionToShaderIndex(llvm::Value *val) { Instr->setOperand(5, val); } llvm::Value *get_MissShaderIndex() const { return Instr->getOperand(6); } void set_MissShaderIndex(llvm::Value *val) { Instr->setOperand(6, val); } llvm::Value *get_Origin_X() const { return Instr->getOperand(7); } @@ -5668,8 +5285,7 @@ struct DxilInst_ReportHit { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5689,8 +5305,7 @@ struct DxilInst_ReportHit { void set_Attributes(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction Call a shader in the callable shader table supplied through -/// the DispatchRays() API +/// This instruction Call a shader in the callable shader table supplied through the DispatchRays() API struct DxilInst_CallShader { llvm::Instruction *Instr; // Construction and identification @@ -5701,8 +5316,7 @@ struct DxilInst_CallShader { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5725,14 +5339,12 @@ struct DxilInst_CreateHandleForLib { // Construction and identification DxilInst_CreateHandleForLib(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::CreateHandleForLib); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandleForLib); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5752,14 +5364,12 @@ struct DxilInst_PrimitiveIndex { // Construction and identification DxilInst_PrimitiveIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::PrimitiveIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::PrimitiveIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5777,8 +5387,7 @@ struct DxilInst_Dot2AddHalf { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5804,21 +5413,18 @@ struct DxilInst_Dot2AddHalf { void set_by(llvm::Value *val) { Instr->setOperand(5, val); } }; -/// This instruction signed dot product of 4 x i8 vectors packed into i32, with -/// accumulate to i32 +/// This instruction signed dot product of 4 x i8 vectors packed into i32, with accumulate to i32 struct DxilInst_Dot4AddI8Packed { llvm::Instruction *Instr; // Construction and identification DxilInst_Dot4AddI8Packed(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::Dot4AddI8Packed); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot4AddI8Packed); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5838,21 +5444,18 @@ struct DxilInst_Dot4AddI8Packed { void set_b(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction unsigned dot product of 4 x u8 vectors packed into i32, -/// with accumulate to i32 +/// This instruction unsigned dot product of 4 x u8 vectors packed into i32, with accumulate to i32 struct DxilInst_Dot4AddU8Packed { llvm::Instruction *Instr; // Construction and identification DxilInst_Dot4AddU8Packed(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::Dot4AddU8Packed); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot4AddU8Packed); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5872,8 +5475,7 @@ struct DxilInst_Dot4AddU8Packed { void set_b(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns the bitmask of active lanes that have the same -/// value +/// This instruction returns the bitmask of active lanes that have the same value struct DxilInst_WaveMatch { llvm::Instruction *Instr; // Construction and identification @@ -5884,8 +5486,7 @@ struct DxilInst_WaveMatch { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5899,21 +5500,18 @@ struct DxilInst_WaveMatch { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns the result of the operation on groups of lanes -/// identified by a bitmask +/// This instruction returns the result of the operation on groups of lanes identified by a bitmask struct DxilInst_WaveMultiPrefixOp { llvm::Instruction *Instr; // Construction and identification DxilInst_WaveMultiPrefixOp(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::WaveMultiPrefixOp); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveMultiPrefixOp); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (8 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (8 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -5941,43 +5539,26 @@ struct DxilInst_WaveMultiPrefixOp { void set_mask3(llvm::Value *val) { Instr->setOperand(5, val); } llvm::Value *get_op() const { return Instr->getOperand(6); } void set_op(llvm::Value *val) { Instr->setOperand(6, val); } - int8_t get_op_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(6)) - ->getZExtValue()); - } - void set_op_val(int8_t val) { - Instr->setOperand(6, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(6))->getZExtValue()); } + void set_op_val(int8_t val) { Instr->setOperand(6, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } llvm::Value *get_sop() const { return Instr->getOperand(7); } void set_sop(llvm::Value *val) { Instr->setOperand(7, val); } - int8_t get_sop_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(7)) - ->getZExtValue()); - } - void set_sop_val(int8_t val) { - Instr->setOperand(7, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(7))->getZExtValue()); } + void set_sop_val(int8_t val) { Instr->setOperand(7, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; -/// This instruction returns the count of bits set to 1 on groups of lanes -/// identified by a bitmask +/// This instruction returns the count of bits set to 1 on groups of lanes identified by a bitmask struct DxilInst_WaveMultiPrefixBitCount { llvm::Instruction *Instr; // Construction and identification DxilInst_WaveMultiPrefixBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::WaveMultiPrefixBitCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveMultiPrefixBitCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6009,14 +5590,12 @@ struct DxilInst_SetMeshOutputCounts { // Construction and identification DxilInst_SetMeshOutputCounts(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::SetMeshOutputCounts); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SetMeshOutputCounts); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6044,8 +5623,7 @@ struct DxilInst_EmitIndices { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6074,14 +5652,12 @@ struct DxilInst_GetMeshPayload { // Construction and identification DxilInst_GetMeshPayload(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::GetMeshPayload); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetMeshPayload); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6094,14 +5670,12 @@ struct DxilInst_StoreVertexOutput { // Construction and identification DxilInst_StoreVertexOutput(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::StoreVertexOutput); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StoreVertexOutput); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6133,14 +5707,12 @@ struct DxilInst_StorePrimitiveOutput { // Construction and identification DxilInst_StorePrimitiveOutput(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::StorePrimitiveOutput); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StorePrimitiveOutput); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6172,14 +5744,12 @@ struct DxilInst_DispatchMesh { // Construction and identification DxilInst_DispatchMesh(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::DispatchMesh); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DispatchMesh); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6208,14 +5778,12 @@ struct DxilInst_WriteSamplerFeedback { // Construction and identification DxilInst_WriteSamplerFeedback(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::WriteSamplerFeedback); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WriteSamplerFeedback); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6250,22 +5818,18 @@ struct DxilInst_WriteSamplerFeedback { void set_clamp(llvm::Value *val) { Instr->setOperand(8, val); } }; -/// This instruction updates a feedback texture for a sampling operation with a -/// bias on the mipmap level +/// This instruction updates a feedback texture for a sampling operation with a bias on the mipmap level struct DxilInst_WriteSamplerFeedbackBias { llvm::Instruction *Instr; // Construction and identification - DxilInst_WriteSamplerFeedbackBias(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_WriteSamplerFeedbackBias(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::WriteSamplerFeedbackBias); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WriteSamplerFeedbackBias); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6303,22 +5867,18 @@ struct DxilInst_WriteSamplerFeedbackBias { void set_clamp(llvm::Value *val) { Instr->setOperand(9, val); } }; -/// This instruction updates a feedback texture for a sampling operation with a -/// mipmap-level offset +/// This instruction updates a feedback texture for a sampling operation with a mipmap-level offset struct DxilInst_WriteSamplerFeedbackLevel { llvm::Instruction *Instr; // Construction and identification - DxilInst_WriteSamplerFeedbackLevel(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_WriteSamplerFeedbackLevel(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::WriteSamplerFeedbackLevel); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WriteSamplerFeedbackLevel); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6353,22 +5913,18 @@ struct DxilInst_WriteSamplerFeedbackLevel { void set_lod(llvm::Value *val) { Instr->setOperand(8, val); } }; -/// This instruction updates a feedback texture for a sampling operation with -/// explicit gradients +/// This instruction updates a feedback texture for a sampling operation with explicit gradients struct DxilInst_WriteSamplerFeedbackGrad { llvm::Instruction *Instr; // Construction and identification - DxilInst_WriteSamplerFeedbackGrad(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_WriteSamplerFeedbackGrad(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::WriteSamplerFeedbackGrad); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WriteSamplerFeedbackGrad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (15 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (15 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6427,14 +5983,12 @@ struct DxilInst_AllocateRayQuery { // Construction and identification DxilInst_AllocateRayQuery(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::AllocateRayQuery); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AllocateRayQuery); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6446,15 +6000,8 @@ struct DxilInst_AllocateRayQuery { // Accessors llvm::Value *get_constRayFlags() const { return Instr->getOperand(1); } void set_constRayFlags(llvm::Value *val) { Instr->setOperand(1, val); } - uint32_t get_constRayFlags_val() const { - return (uint32_t)(llvm::dyn_cast(Instr->getOperand(1)) - ->getZExtValue()); - } - void set_constRayFlags_val(uint32_t val) { - Instr->setOperand(1, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + uint32_t get_constRayFlags_val() const { return (uint32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } + void set_constRayFlags_val(uint32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; /// This instruction initializes RayQuery for raytrace @@ -6463,14 +6010,12 @@ struct DxilInst_RayQuery_TraceRayInline { // Construction and identification DxilInst_RayQuery_TraceRayInline(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_TraceRayInline); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_TraceRayInline); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6493,20 +6038,12 @@ struct DxilInst_RayQuery_TraceRayInline { // Accessors llvm::Value *get_rayQueryHandle() const { return Instr->getOperand(1); } void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_accelerationStructure() const { - return Instr->getOperand(2); - } - void set_accelerationStructure(llvm::Value *val) { - Instr->setOperand(2, val); - } + llvm::Value *get_accelerationStructure() const { return Instr->getOperand(2); } + void set_accelerationStructure(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_rayFlags() const { return Instr->getOperand(3); } void set_rayFlags(llvm::Value *val) { Instr->setOperand(3, val); } - llvm::Value *get_instanceInclusionMask() const { - return Instr->getOperand(4); - } - void set_instanceInclusionMask(llvm::Value *val) { - Instr->setOperand(4, val); - } + llvm::Value *get_instanceInclusionMask() const { return Instr->getOperand(4); } + void set_instanceInclusionMask(llvm::Value *val) { Instr->setOperand(4, val); } llvm::Value *get_origin_X() const { return Instr->getOperand(5); } void set_origin_X(llvm::Value *val) { Instr->setOperand(5, val); } llvm::Value *get_origin_Y() const { return Instr->getOperand(6); } @@ -6531,14 +6068,12 @@ struct DxilInst_RayQuery_Proceed { // Construction and identification DxilInst_RayQuery_Proceed(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::RayQuery_Proceed); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_Proceed); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6558,14 +6093,12 @@ struct DxilInst_RayQuery_Abort { // Construction and identification DxilInst_RayQuery_Abort(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::RayQuery_Abort); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_Abort); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6583,17 +6116,14 @@ struct DxilInst_RayQuery_Abort { struct DxilInst_RayQuery_CommitNonOpaqueTriangleHit { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommitNonOpaqueTriangleHit(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommitNonOpaqueTriangleHit(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommitNonOpaqueTriangleHit); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommitNonOpaqueTriangleHit); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6611,17 +6141,14 @@ struct DxilInst_RayQuery_CommitNonOpaqueTriangleHit { struct DxilInst_RayQuery_CommitProceduralPrimitiveHit { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommitProceduralPrimitiveHit(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommitProceduralPrimitiveHit(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommitProceduralPrimitiveHit); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommitProceduralPrimitiveHit); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6638,22 +6165,18 @@ struct DxilInst_RayQuery_CommitProceduralPrimitiveHit { void set_t(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction returns uint status (COMMITTED_STATUS) of the committed hit -/// in a ray query +/// This instruction returns uint status (COMMITTED_STATUS) of the committed hit in a ray query struct DxilInst_RayQuery_CommittedStatus { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedStatus(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedStatus(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedStatus); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedStatus); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6667,21 +6190,18 @@ struct DxilInst_RayQuery_CommittedStatus { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns uint candidate type (CANDIDATE_TYPE) of the current -/// hit candidate in a ray query, after Proceed() has returned true +/// This instruction returns uint candidate type (CANDIDATE_TYPE) of the current hit candidate in a ray query, after Proceed() has returned true struct DxilInst_RayQuery_CandidateType { llvm::Instruction *Instr; // Construction and identification DxilInst_RayQuery_CandidateType(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateType); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateType); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6695,22 +6215,18 @@ struct DxilInst_RayQuery_CandidateType { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns matrix for transforming from object-space to -/// world-space for a candidate hit. +/// This instruction returns matrix for transforming from object-space to world-space for a candidate hit. struct DxilInst_RayQuery_CandidateObjectToWorld3x4 { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateObjectToWorld3x4(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateObjectToWorld3x4(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectToWorld3x4); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectToWorld3x4); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6730,22 +6246,18 @@ struct DxilInst_RayQuery_CandidateObjectToWorld3x4 { void set_col(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns matrix for transforming from world-space to -/// object-space for a candidate hit. +/// This instruction returns matrix for transforming from world-space to object-space for a candidate hit. struct DxilInst_RayQuery_CandidateWorldToObject3x4 { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateWorldToObject3x4(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateWorldToObject3x4(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateWorldToObject3x4); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateWorldToObject3x4); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6765,22 +6277,18 @@ struct DxilInst_RayQuery_CandidateWorldToObject3x4 { void set_col(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns matrix for transforming from object-space to -/// world-space for a Committed hit. +/// This instruction returns matrix for transforming from object-space to world-space for a Committed hit. struct DxilInst_RayQuery_CommittedObjectToWorld3x4 { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedObjectToWorld3x4(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedObjectToWorld3x4(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectToWorld3x4); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectToWorld3x4); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6800,22 +6308,18 @@ struct DxilInst_RayQuery_CommittedObjectToWorld3x4 { void set_col(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns matrix for transforming from world-space to -/// object-space for a Committed hit. +/// This instruction returns matrix for transforming from world-space to object-space for a Committed hit. struct DxilInst_RayQuery_CommittedWorldToObject3x4 { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedWorldToObject3x4(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedWorldToObject3x4(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedWorldToObject3x4); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedWorldToObject3x4); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6835,24 +6339,18 @@ struct DxilInst_RayQuery_CommittedWorldToObject3x4 { void set_col(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns if current candidate procedural primitive is non -/// opaque +/// This instruction returns if current candidate procedural primitive is non opaque struct DxilInst_RayQuery_CandidateProceduralPrimitiveNonOpaque { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateProceduralPrimitiveNonOpaque( - llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateProceduralPrimitiveNonOpaque(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, - hlsl::OP::OpCode::RayQuery_CandidateProceduralPrimitiveNonOpaque); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateProceduralPrimitiveNonOpaque); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6870,17 +6368,14 @@ struct DxilInst_RayQuery_CandidateProceduralPrimitiveNonOpaque { struct DxilInst_RayQuery_CandidateTriangleFrontFace { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateTriangleFrontFace(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateTriangleFrontFace(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleFrontFace); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleFrontFace); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6898,17 +6393,14 @@ struct DxilInst_RayQuery_CandidateTriangleFrontFace { struct DxilInst_RayQuery_CommittedTriangleFrontFace { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedTriangleFrontFace(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedTriangleFrontFace(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedTriangleFrontFace); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedTriangleFrontFace); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6926,17 +6418,14 @@ struct DxilInst_RayQuery_CommittedTriangleFrontFace { struct DxilInst_RayQuery_CandidateTriangleBarycentrics { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateTriangleBarycentrics(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateTriangleBarycentrics(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleBarycentrics); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleBarycentrics); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6951,32 +6440,22 @@ struct DxilInst_RayQuery_CandidateTriangleBarycentrics { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_component_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction returns committed triangle hit barycentrics struct DxilInst_RayQuery_CommittedTriangleBarycentrics { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedTriangleBarycentrics(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedTriangleBarycentrics(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedTriangleBarycentrics); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedTriangleBarycentrics); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -6991,15 +6470,8 @@ struct DxilInst_RayQuery_CommittedTriangleBarycentrics { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_component_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction returns ray flags @@ -7008,14 +6480,12 @@ struct DxilInst_RayQuery_RayFlags { // Construction and identification DxilInst_RayQuery_RayFlags(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::RayQuery_RayFlags); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_RayFlags); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7035,14 +6505,12 @@ struct DxilInst_RayQuery_WorldRayOrigin { // Construction and identification DxilInst_RayQuery_WorldRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_WorldRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_WorldRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7057,32 +6525,22 @@ struct DxilInst_RayQuery_WorldRayOrigin { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_component_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction returns world ray direction struct DxilInst_RayQuery_WorldRayDirection { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_WorldRayDirection(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_WorldRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_WorldRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_WorldRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7097,32 +6555,22 @@ struct DxilInst_RayQuery_WorldRayDirection { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_component_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; -/// This instruction returns float representing the parametric starting point -/// for the ray. +/// This instruction returns float representing the parametric starting point for the ray. struct DxilInst_RayQuery_RayTMin { llvm::Instruction *Instr; // Construction and identification DxilInst_RayQuery_RayTMin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::RayQuery_RayTMin); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_RayTMin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7136,22 +6584,18 @@ struct DxilInst_RayQuery_RayTMin { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns float representing the parametric point on the ray -/// for the current candidate triangle hit. +/// This instruction returns float representing the parametric point on the ray for the current candidate triangle hit. struct DxilInst_RayQuery_CandidateTriangleRayT { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateTriangleRayT(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateTriangleRayT(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleRayT); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleRayT); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7165,21 +6609,18 @@ struct DxilInst_RayQuery_CandidateTriangleRayT { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns float representing the parametric point on the ray -/// for the current committed hit. +/// This instruction returns float representing the parametric point on the ray for the current committed hit. struct DxilInst_RayQuery_CommittedRayT { llvm::Instruction *Instr; // Construction and identification DxilInst_RayQuery_CommittedRayT(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedRayT); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedRayT); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7197,17 +6638,14 @@ struct DxilInst_RayQuery_CommittedRayT { struct DxilInst_RayQuery_CandidateInstanceIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateInstanceIndex(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateInstanceIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7225,17 +6663,14 @@ struct DxilInst_RayQuery_CandidateInstanceIndex { struct DxilInst_RayQuery_CandidateInstanceID { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateInstanceID(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateInstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceID); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceID); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7253,17 +6688,14 @@ struct DxilInst_RayQuery_CandidateInstanceID { struct DxilInst_RayQuery_CandidateGeometryIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateGeometryIndex(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateGeometryIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateGeometryIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateGeometryIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7281,17 +6713,14 @@ struct DxilInst_RayQuery_CandidateGeometryIndex { struct DxilInst_RayQuery_CandidatePrimitiveIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidatePrimitiveIndex(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidatePrimitiveIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidatePrimitiveIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidatePrimitiveIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7309,17 +6738,14 @@ struct DxilInst_RayQuery_CandidatePrimitiveIndex { struct DxilInst_RayQuery_CandidateObjectRayOrigin { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateObjectRayOrigin(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateObjectRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7334,32 +6760,22 @@ struct DxilInst_RayQuery_CandidateObjectRayOrigin { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_component_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction returns candidate object ray direction struct DxilInst_RayQuery_CandidateObjectRayDirection { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateObjectRayDirection(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateObjectRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7374,32 +6790,22 @@ struct DxilInst_RayQuery_CandidateObjectRayDirection { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_component_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction returns committed hit instance index struct DxilInst_RayQuery_CommittedInstanceIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedInstanceIndex(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedInstanceIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7417,17 +6823,14 @@ struct DxilInst_RayQuery_CommittedInstanceIndex { struct DxilInst_RayQuery_CommittedInstanceID { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedInstanceID(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedInstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceID); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceID); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7445,17 +6848,14 @@ struct DxilInst_RayQuery_CommittedInstanceID { struct DxilInst_RayQuery_CommittedGeometryIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedGeometryIndex(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedGeometryIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedGeometryIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedGeometryIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7473,17 +6873,14 @@ struct DxilInst_RayQuery_CommittedGeometryIndex { struct DxilInst_RayQuery_CommittedPrimitiveIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedPrimitiveIndex(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedPrimitiveIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedPrimitiveIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedPrimitiveIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7501,17 +6898,14 @@ struct DxilInst_RayQuery_CommittedPrimitiveIndex { struct DxilInst_RayQuery_CommittedObjectRayOrigin { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedObjectRayOrigin(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedObjectRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7526,32 +6920,22 @@ struct DxilInst_RayQuery_CommittedObjectRayOrigin { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_component_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; /// This instruction returns committed object ray direction struct DxilInst_RayQuery_CommittedObjectRayDirection { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedObjectRayDirection(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedObjectRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7566,32 +6950,22 @@ struct DxilInst_RayQuery_CommittedObjectRayDirection { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_component_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; -/// This instruction The autogenerated index of the current geometry in the -/// bottom-level structure +/// This instruction The autogenerated index of the current geometry in the bottom-level structure struct DxilInst_GeometryIndex { llvm::Instruction *Instr; // Construction and identification DxilInst_GeometryIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::GeometryIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GeometryIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7602,19 +6976,14 @@ struct DxilInst_GeometryIndex { struct DxilInst_RayQuery_CandidateInstanceContributionToHitGroupIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateInstanceContributionToHitGroupIndex( - llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CandidateInstanceContributionToHitGroupIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode:: - RayQuery_CandidateInstanceContributionToHitGroupIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceContributionToHitGroupIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7632,19 +7001,14 @@ struct DxilInst_RayQuery_CandidateInstanceContributionToHitGroupIndex { struct DxilInst_RayQuery_CommittedInstanceContributionToHitGroupIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedInstanceContributionToHitGroupIndex( - llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_RayQuery_CommittedInstanceContributionToHitGroupIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode:: - RayQuery_CommittedInstanceContributionToHitGroupIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceContributionToHitGroupIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7664,14 +7028,12 @@ struct DxilInst_AnnotateHandle { // Construction and identification DxilInst_AnnotateHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::AnnotateHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AnnotateHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7694,14 +7056,12 @@ struct DxilInst_CreateHandleFromBinding { // Construction and identification DxilInst_CreateHandleFromBinding(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::CreateHandleFromBinding); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandleFromBinding); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7719,15 +7079,8 @@ struct DxilInst_CreateHandleFromBinding { void set_index(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_nonUniformIndex() const { return Instr->getOperand(3); } void set_nonUniformIndex(llvm::Value *val) { Instr->setOperand(3, val); } - bool get_nonUniformIndex_val() const { - return (bool)(llvm::dyn_cast(Instr->getOperand(3)) - ->getZExtValue()); - } - void set_nonUniformIndex_val(bool val) { - Instr->setOperand(3, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 1), - llvm::APInt(1, (uint64_t)val))); - } + bool get_nonUniformIndex_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } + void set_nonUniformIndex_val(bool val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } }; /// This instruction create resource handle from heap @@ -7736,14 +7089,12 @@ struct DxilInst_CreateHandleFromHeap { // Construction and identification DxilInst_CreateHandleFromHeap(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::CreateHandleFromHeap); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandleFromHeap); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7759,30 +7110,15 @@ struct DxilInst_CreateHandleFromHeap { void set_index(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_samplerHeap() const { return Instr->getOperand(2); } void set_samplerHeap(llvm::Value *val) { Instr->setOperand(2, val); } - bool get_samplerHeap_val() const { - return (bool)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_samplerHeap_val(bool val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 1), - llvm::APInt(1, (uint64_t)val))); - } + bool get_samplerHeap_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_samplerHeap_val(bool val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } llvm::Value *get_nonUniformIndex() const { return Instr->getOperand(3); } void set_nonUniformIndex(llvm::Value *val) { Instr->setOperand(3, val); } - bool get_nonUniformIndex_val() const { - return (bool)(llvm::dyn_cast(Instr->getOperand(3)) - ->getZExtValue()); - } - void set_nonUniformIndex_val(bool val) { - Instr->setOperand(3, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 1), - llvm::APInt(1, (uint64_t)val))); - } + bool get_nonUniformIndex_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } + void set_nonUniformIndex_val(bool val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } }; -/// This instruction unpacks 4 8-bit signed or unsigned values into int32 or -/// int16 vector +/// This instruction unpacks 4 8-bit signed or unsigned values into int32 or int16 vector struct DxilInst_Unpack4x8 { llvm::Instruction *Instr; // Construction and identification @@ -7793,8 +7129,7 @@ struct DxilInst_Unpack4x8 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7811,8 +7146,7 @@ struct DxilInst_Unpack4x8 { void set_pk(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction packs vector of 4 signed or unsigned values into a packed -/// datatype, drops or clamps unused bits +/// This instruction packs vector of 4 signed or unsigned values into a packed datatype, drops or clamps unused bits struct DxilInst_Pack4x8 { llvm::Instruction *Instr; // Construction and identification @@ -7823,8 +7157,7 @@ struct DxilInst_Pack4x8 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7856,14 +7189,12 @@ struct DxilInst_IsHelperLane { // Construction and identification DxilInst_IsHelperLane(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::IsHelperLane); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsHelperLane); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7881,8 +7212,7 @@ struct DxilInst_QuadVote { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7897,32 +7227,22 @@ struct DxilInst_QuadVote { void set_cond(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_op_val(int8_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } }; -/// This instruction Gather raw elements from 4 texels with no type conversions -/// (SRV type is constrained) +/// This instruction Gather raw elements from 4 texels with no type conversions (SRV type is constrained) struct DxilInst_TextureGatherRaw { llvm::Instruction *Instr; // Construction and identification DxilInst_TextureGatherRaw(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::TextureGatherRaw); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGatherRaw); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -7957,21 +7277,18 @@ struct DxilInst_TextureGatherRaw { void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); } }; -/// This instruction samples a texture and compares a single component against -/// the specified comparison value +/// This instruction samples a texture and compares a single component against the specified comparison value struct DxilInst_SampleCmpLevel { llvm::Instruction *Instr; // Construction and identification DxilInst_SampleCmpLevel(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::SampleCmpLevel); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpLevel); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8021,14 +7338,12 @@ struct DxilInst_TextureStoreSample { // Construction and identification DxilInst_TextureStoreSample(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::TextureStoreSample); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureStoreSample); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8065,15 +7380,8 @@ struct DxilInst_TextureStoreSample { void set_value3(llvm::Value *val) { Instr->setOperand(8, val); } llvm::Value *get_mask() const { return Instr->getOperand(9); } void set_mask(llvm::Value *val) { Instr->setOperand(9, val); } - int8_t get_mask_val() const { - return (int8_t)(llvm::dyn_cast(Instr->getOperand(9)) - ->getZExtValue()); - } - void set_mask_val(int8_t val) { - Instr->setOperand(9, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 8), - llvm::APInt(8, (uint64_t)val))); - } + int8_t get_mask_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(9))->getZExtValue()); } + void set_mask_val(int8_t val) { Instr->setOperand(9, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } llvm::Value *get_sampleIdx() const { return Instr->getOperand(10); } void set_sampleIdx(llvm::Value *val) { Instr->setOperand(10, val); } }; @@ -8082,17 +7390,14 @@ struct DxilInst_TextureStoreSample { struct DxilInst_AllocateNodeOutputRecords { llvm::Instruction *Instr; // Construction and identification - DxilInst_AllocateNodeOutputRecords(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_AllocateNodeOutputRecords(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::AllocateNodeOutputRecords); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AllocateNodeOutputRecords); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8110,32 +7415,22 @@ struct DxilInst_AllocateNodeOutputRecords { void set_numRecords(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_perThread() const { return Instr->getOperand(3); } void set_perThread(llvm::Value *val) { Instr->setOperand(3, val); } - bool get_perThread_val() const { - return (bool)(llvm::dyn_cast(Instr->getOperand(3)) - ->getZExtValue()); - } - void set_perThread_val(bool val) { - Instr->setOperand(3, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 1), - llvm::APInt(1, (uint64_t)val))); - } + bool get_perThread_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } + void set_perThread_val(bool val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } }; -/// This instruction retrieve node input/output record pointer in address space -/// 6 +/// This instruction retrieve node input/output record pointer in address space 6 struct DxilInst_GetNodeRecordPtr { llvm::Instruction *Instr; // Construction and identification DxilInst_GetNodeRecordPtr(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::GetNodeRecordPtr); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetNodeRecordPtr); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8152,21 +7447,18 @@ struct DxilInst_GetNodeRecordPtr { void set_arrayIndex(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction Select the next logical output count for an EmptyNodeOutput -/// for the whole group or per thread. +/// This instruction Select the next logical output count for an EmptyNodeOutput for the whole group or per thread. struct DxilInst_IncrementOutputCount { llvm::Instruction *Instr; // Construction and identification DxilInst_IncrementOutputCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::IncrementOutputCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IncrementOutputCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8184,15 +7476,8 @@ struct DxilInst_IncrementOutputCount { void set_count(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_perThread() const { return Instr->getOperand(3); } void set_perThread(llvm::Value *val) { Instr->setOperand(3, val); } - bool get_perThread_val() const { - return (bool)(llvm::dyn_cast(Instr->getOperand(3)) - ->getZExtValue()); - } - void set_perThread_val(bool val) { - Instr->setOperand(3, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 1), - llvm::APInt(1, (uint64_t)val))); - } + bool get_perThread_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } + void set_perThread_val(bool val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } }; /// This instruction indicates all outputs for a given records are complete @@ -8201,14 +7486,12 @@ struct DxilInst_OutputComplete { // Construction and identification DxilInst_OutputComplete(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::OutputComplete); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::OutputComplete); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8222,21 +7505,18 @@ struct DxilInst_OutputComplete { void set_output(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns the number of records that have been coalesced into -/// the current thread group +/// This instruction returns the number of records that have been coalesced into the current thread group struct DxilInst_GetInputRecordCount { llvm::Instruction *Instr; // Construction and identification DxilInst_GetInputRecordCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::GetInputRecordCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetInputRecordCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8250,22 +7530,18 @@ struct DxilInst_GetInputRecordCount { void set_input(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns true if the current thread group is the last to -/// access the input +/// This instruction returns true if the current thread group is the last to access the input struct DxilInst_FinishedCrossGroupSharing { llvm::Instruction *Instr; // Construction and identification - DxilInst_FinishedCrossGroupSharing(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_FinishedCrossGroupSharing(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::FinishedCrossGroupSharing); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FinishedCrossGroupSharing); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8279,21 +7555,18 @@ struct DxilInst_FinishedCrossGroupSharing { void set_input(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Request a barrier for a set of memory types and/or thread -/// group execution sync +/// This instruction Request a barrier for a set of memory types and/or thread group execution sync struct DxilInst_BarrierByMemoryType { llvm::Instruction *Instr; // Construction and identification DxilInst_BarrierByMemoryType(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::BarrierByMemoryType); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BarrierByMemoryType); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8306,43 +7579,26 @@ struct DxilInst_BarrierByMemoryType { // Accessors llvm::Value *get_MemoryTypeFlags() const { return Instr->getOperand(1); } void set_MemoryTypeFlags(llvm::Value *val) { Instr->setOperand(1, val); } - int32_t get_MemoryTypeFlags_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(1)) - ->getZExtValue()); - } - void set_MemoryTypeFlags_val(int32_t val) { - Instr->setOperand(1, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_MemoryTypeFlags_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } + void set_MemoryTypeFlags_val(int32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } llvm::Value *get_SemanticFlags() const { return Instr->getOperand(2); } void set_SemanticFlags(llvm::Value *val) { Instr->setOperand(2, val); } - int32_t get_SemanticFlags_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_SemanticFlags_val(int32_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_SemanticFlags_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_SemanticFlags_val(int32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; -/// This instruction Request a barrier for just the memory used by the specified -/// object +/// This instruction Request a barrier for just the memory used by the specified object struct DxilInst_BarrierByMemoryHandle { llvm::Instruction *Instr; // Construction and identification DxilInst_BarrierByMemoryHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::BarrierByMemoryHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BarrierByMemoryHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8357,33 +7613,22 @@ struct DxilInst_BarrierByMemoryHandle { void set_object(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_SemanticFlags() const { return Instr->getOperand(2); } void set_SemanticFlags(llvm::Value *val) { Instr->setOperand(2, val); } - int32_t get_SemanticFlags_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_SemanticFlags_val(int32_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_SemanticFlags_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_SemanticFlags_val(int32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; -/// This instruction Request a barrier for just the memory used by the node -/// record +/// This instruction Request a barrier for just the memory used by the node record struct DxilInst_BarrierByNodeRecordHandle { llvm::Instruction *Instr; // Construction and identification - DxilInst_BarrierByNodeRecordHandle(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_BarrierByNodeRecordHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::BarrierByNodeRecordHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BarrierByNodeRecordHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8398,15 +7643,8 @@ struct DxilInst_BarrierByNodeRecordHandle { void set_object(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_SemanticFlags() const { return Instr->getOperand(2); } void set_SemanticFlags(llvm::Value *val) { Instr->setOperand(2, val); } - int32_t get_SemanticFlags_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_SemanticFlags_val(int32_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_SemanticFlags_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_SemanticFlags_val(int32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; /// This instruction Creates a handle to a NodeOutput @@ -8415,14 +7653,12 @@ struct DxilInst_CreateNodeOutputHandle { // Construction and identification DxilInst_CreateNodeOutputHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::CreateNodeOutputHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateNodeOutputHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8434,32 +7670,22 @@ struct DxilInst_CreateNodeOutputHandle { // Accessors llvm::Value *get_MetadataIdx() const { return Instr->getOperand(1); } void set_MetadataIdx(llvm::Value *val) { Instr->setOperand(1, val); } - int32_t get_MetadataIdx_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(1)) - ->getZExtValue()); - } - void set_MetadataIdx_val(int32_t val) { - Instr->setOperand(1, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_MetadataIdx_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } + void set_MetadataIdx_val(int32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; -/// This instruction returns the handle for the location in the output node -/// array at the indicated index +/// This instruction returns the handle for the location in the output node array at the indicated index struct DxilInst_IndexNodeHandle { llvm::Instruction *Instr; // Construction and identification DxilInst_IndexNodeHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::IndexNodeHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IndexNodeHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8482,14 +7708,12 @@ struct DxilInst_AnnotateNodeHandle { // Construction and identification DxilInst_AnnotateNodeHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::AnnotateNodeHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AnnotateNodeHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8510,17 +7734,14 @@ struct DxilInst_AnnotateNodeHandle { struct DxilInst_CreateNodeInputRecordHandle { llvm::Instruction *Instr; // Construction and identification - DxilInst_CreateNodeInputRecordHandle(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_CreateNodeInputRecordHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::CreateNodeInputRecordHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateNodeInputRecordHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8532,32 +7753,22 @@ struct DxilInst_CreateNodeInputRecordHandle { // Accessors llvm::Value *get_MetadataIdx() const { return Instr->getOperand(1); } void set_MetadataIdx(llvm::Value *val) { Instr->setOperand(1, val); } - int32_t get_MetadataIdx_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(1)) - ->getZExtValue()); - } - void set_MetadataIdx_val(int32_t val) { - Instr->setOperand(1, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_MetadataIdx_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } + void set_MetadataIdx_val(int32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; /// This instruction annotate handle with node record properties struct DxilInst_AnnotateNodeRecordHandle { llvm::Instruction *Instr; // Construction and identification - DxilInst_AnnotateNodeRecordHandle(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_AnnotateNodeRecordHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::AnnotateNodeRecordHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AnnotateNodeRecordHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8574,21 +7785,18 @@ struct DxilInst_AnnotateNodeRecordHandle { void set_props(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction returns true if the specified output node is present in the -/// work graph +/// This instruction returns true if the specified output node is present in the work graph struct DxilInst_NodeOutputIsValid { llvm::Instruction *Instr; // Construction and identification DxilInst_NodeOutputIsValid(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::NodeOutputIsValid); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::NodeOutputIsValid); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8606,38 +7814,32 @@ struct DxilInst_NodeOutputIsValid { struct DxilInst_GetRemainingRecursionLevels { llvm::Instruction *Instr; // Construction and identification - DxilInst_GetRemainingRecursionLevels(llvm::Instruction *pInstr) - : Instr(pInstr) {} + DxilInst_GetRemainingRecursionLevels(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::GetRemainingRecursionLevels); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetRemainingRecursionLevels); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction samples a texture using a gradient and compares a single -/// component against the specified comparison value +/// This instruction samples a texture using a gradient and compares a single component against the specified comparison value struct DxilInst_SampleCmpGrad { llvm::Instruction *Instr; // Construction and identification DxilInst_SampleCmpGrad(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::SampleCmpGrad); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpGrad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (18 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (18 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8699,22 +7901,18 @@ struct DxilInst_SampleCmpGrad { void set_clamp(llvm::Value *val) { Instr->setOperand(17, val); } }; -/// This instruction samples a texture after applying the input bias to the -/// mipmap level and compares a single component against the specified -/// comparison value +/// This instruction samples a texture after applying the input bias to the mipmap level and compares a single component against the specified comparison value struct DxilInst_SampleCmpBias { llvm::Instruction *Instr; // Construction and identification DxilInst_SampleCmpBias(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::SampleCmpBias); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpBias); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8761,21 +7959,18 @@ struct DxilInst_SampleCmpBias { void set_clamp(llvm::Value *val) { Instr->setOperand(12, val); } }; -/// This instruction returns the BaseVertexLocation from DrawIndexedInstanced or -/// StartVertexLocation from DrawInstanced +/// This instruction returns the BaseVertexLocation from DrawIndexedInstanced or StartVertexLocation from DrawInstanced struct DxilInst_StartVertexLocation { llvm::Instruction *Instr; // Construction and identification DxilInst_StartVertexLocation(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::StartVertexLocation); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StartVertexLocation); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8788,14 +7983,12 @@ struct DxilInst_StartInstanceLocation { // Construction and identification DxilInst_StartInstanceLocation(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::StartInstanceLocation); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StartInstanceLocation); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8808,14 +8001,12 @@ struct DxilInst_AllocateRayQuery2 { // Construction and identification DxilInst_AllocateRayQuery2(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::AllocateRayQuery2); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AllocateRayQuery2); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8828,26 +8019,12 @@ struct DxilInst_AllocateRayQuery2 { // Accessors llvm::Value *get_constRayFlags() const { return Instr->getOperand(1); } void set_constRayFlags(llvm::Value *val) { Instr->setOperand(1, val); } - uint32_t get_constRayFlags_val() const { - return (uint32_t)(llvm::dyn_cast(Instr->getOperand(1)) - ->getZExtValue()); - } - void set_constRayFlags_val(uint32_t val) { - Instr->setOperand(1, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + uint32_t get_constRayFlags_val() const { return (uint32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } + void set_constRayFlags_val(uint32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } llvm::Value *get_constRayQueryFlags() const { return Instr->getOperand(2); } void set_constRayQueryFlags(llvm::Value *val) { Instr->setOperand(2, val); } - uint32_t get_constRayQueryFlags_val() const { - return (uint32_t)(llvm::dyn_cast(Instr->getOperand(2)) - ->getZExtValue()); - } - void set_constRayQueryFlags_val(uint32_t val) { - Instr->setOperand(2, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + uint32_t get_constRayQueryFlags_val() const { return (uint32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } + void set_constRayQueryFlags_val(uint32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; /// This instruction Creates a new HitObject representing a miss @@ -8856,14 +8033,12 @@ struct DxilInst_HitObject_MakeMiss { // Construction and identification DxilInst_HitObject_MakeMiss(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::HitObject_MakeMiss); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::HitObject_MakeMiss); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8910,14 +8085,12 @@ struct DxilInst_HitObject_MakeNop { // Construction and identification DxilInst_HitObject_MakeNop(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, - hlsl::OP::OpCode::HitObject_MakeNop); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::HitObject_MakeNop); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8930,14 +8103,12 @@ struct DxilInst_RawBufferVectorLoad { // Construction and identification DxilInst_RawBufferVectorLoad(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RawBufferVectorLoad); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferVectorLoad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -8958,15 +8129,8 @@ struct DxilInst_RawBufferVectorLoad { void set_elementOffset(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_alignment() const { return Instr->getOperand(4); } void set_alignment(llvm::Value *val) { Instr->setOperand(4, val); } - int32_t get_alignment_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(4)) - ->getZExtValue()); - } - void set_alignment_val(int32_t val) { - Instr->setOperand(4, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); - } + int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(4))->getZExtValue()); } + void set_alignment_val(int32_t val) { Instr->setOperand(4, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } }; /// This instruction writes to a RWByteAddressBuffer or RWStructuredBuffer @@ -8975,14 +8139,12 @@ struct DxilInst_RawBufferVectorStore { // Construction and identification DxilInst_RawBufferVectorStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst( - Instr, hlsl::OP::OpCode::RawBufferVectorStore); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferVectorStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) - return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; return true; } // Metadata @@ -9006,15 +8168,207 @@ struct DxilInst_RawBufferVectorStore { void set_value0(llvm::Value *val) { Instr->setOperand(4, val); } llvm::Value *get_alignment() const { return Instr->getOperand(5); } void set_alignment(llvm::Value *val) { Instr->setOperand(5, val); } - int32_t get_alignment_val() const { - return (int32_t)(llvm::dyn_cast(Instr->getOperand(5)) - ->getZExtValue()); + int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(5))->getZExtValue()); } + void set_alignment_val(int32_t val) { Instr->setOperand(5, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } +}; + +/// This instruction Matrix-Vector Multiply +struct DxilInst_MatVecMul { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_MatVecMul(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MatVecMul); } - void set_alignment_val(int32_t val) { - Instr->setOperand(5, llvm::Constant::getIntegerValue( - llvm::IntegerType::get(Instr->getContext(), 32), - llvm::APInt(32, (uint64_t)val))); + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + return true; } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_inputVector = 1, + arg_isInputSigned = 2, + arg_inputInterpretation = 3, + arg_matrixBuffer = 4, + arg_matrixOffset = 5, + arg_matrixIntepretation = 6, + arg_M = 7, + arg_K = 8, + arg_matrixLayout = 9, + arg_matrixTranspose = 10, + arg_matrixStride = 11, + arg_isOutputSigned = 12, + }; + // Accessors + llvm::Value *get_inputVector() const { return Instr->getOperand(1); } + void set_inputVector(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_isInputSigned() const { return Instr->getOperand(2); } + void set_isInputSigned(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_inputInterpretation() const { return Instr->getOperand(3); } + void set_inputInterpretation(llvm::Value *val) { Instr->setOperand(3, val); } + llvm::Value *get_matrixBuffer() const { return Instr->getOperand(4); } + void set_matrixBuffer(llvm::Value *val) { Instr->setOperand(4, val); } + llvm::Value *get_matrixOffset() const { return Instr->getOperand(5); } + void set_matrixOffset(llvm::Value *val) { Instr->setOperand(5, val); } + llvm::Value *get_matrixIntepretation() const { return Instr->getOperand(6); } + void set_matrixIntepretation(llvm::Value *val) { Instr->setOperand(6, val); } + llvm::Value *get_M() const { return Instr->getOperand(7); } + void set_M(llvm::Value *val) { Instr->setOperand(7, val); } + llvm::Value *get_K() const { return Instr->getOperand(8); } + void set_K(llvm::Value *val) { Instr->setOperand(8, val); } + llvm::Value *get_matrixLayout() const { return Instr->getOperand(9); } + void set_matrixLayout(llvm::Value *val) { Instr->setOperand(9, val); } + llvm::Value *get_matrixTranspose() const { return Instr->getOperand(10); } + void set_matrixTranspose(llvm::Value *val) { Instr->setOperand(10, val); } + llvm::Value *get_matrixStride() const { return Instr->getOperand(11); } + void set_matrixStride(llvm::Value *val) { Instr->setOperand(11, val); } + llvm::Value *get_isOutputSigned() const { return Instr->getOperand(12); } + void set_isOutputSigned(llvm::Value *val) { Instr->setOperand(12, val); } +}; + +/// This instruction Matrix-Vector Multiply Add +struct DxilInst_MatVecMulAdd { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_MatVecMulAdd(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MatVecMulAdd); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (16 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_inputVector = 1, + arg_isInputSigned = 2, + arg_inputInterpretation = 3, + arg_matrixBuffer = 4, + arg_matrixOffset = 5, + arg_matrixIntepretation = 6, + arg_M = 7, + arg_K = 8, + arg_matrixLayout = 9, + arg_matrixTranspose = 10, + arg_matrixStride = 11, + arg_biasBuffer = 12, + arg_biasOffset = 13, + arg_biasIntepretation = 14, + arg_isOutputSigned = 15, + }; + // Accessors + llvm::Value *get_inputVector() const { return Instr->getOperand(1); } + void set_inputVector(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_isInputSigned() const { return Instr->getOperand(2); } + void set_isInputSigned(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_inputInterpretation() const { return Instr->getOperand(3); } + void set_inputInterpretation(llvm::Value *val) { Instr->setOperand(3, val); } + llvm::Value *get_matrixBuffer() const { return Instr->getOperand(4); } + void set_matrixBuffer(llvm::Value *val) { Instr->setOperand(4, val); } + llvm::Value *get_matrixOffset() const { return Instr->getOperand(5); } + void set_matrixOffset(llvm::Value *val) { Instr->setOperand(5, val); } + llvm::Value *get_matrixIntepretation() const { return Instr->getOperand(6); } + void set_matrixIntepretation(llvm::Value *val) { Instr->setOperand(6, val); } + llvm::Value *get_M() const { return Instr->getOperand(7); } + void set_M(llvm::Value *val) { Instr->setOperand(7, val); } + llvm::Value *get_K() const { return Instr->getOperand(8); } + void set_K(llvm::Value *val) { Instr->setOperand(8, val); } + llvm::Value *get_matrixLayout() const { return Instr->getOperand(9); } + void set_matrixLayout(llvm::Value *val) { Instr->setOperand(9, val); } + llvm::Value *get_matrixTranspose() const { return Instr->getOperand(10); } + void set_matrixTranspose(llvm::Value *val) { Instr->setOperand(10, val); } + llvm::Value *get_matrixStride() const { return Instr->getOperand(11); } + void set_matrixStride(llvm::Value *val) { Instr->setOperand(11, val); } + llvm::Value *get_biasBuffer() const { return Instr->getOperand(12); } + void set_biasBuffer(llvm::Value *val) { Instr->setOperand(12, val); } + llvm::Value *get_biasOffset() const { return Instr->getOperand(13); } + void set_biasOffset(llvm::Value *val) { Instr->setOperand(13, val); } + llvm::Value *get_biasIntepretation() const { return Instr->getOperand(14); } + void set_biasIntepretation(llvm::Value *val) { Instr->setOperand(14, val); } + llvm::Value *get_isOutputSigned() const { return Instr->getOperand(15); } + void set_isOutputSigned(llvm::Value *val) { Instr->setOperand(15, val); } +}; + +/// This instruction Outer Product Accumulate +struct DxilInst_OuterProductAccumulate { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_OuterProductAccumulate(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::OuterProductAccumulate); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (8 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_inputVector1 = 1, + arg_inputVector2 = 2, + arg_matrixBuffer = 3, + arg_matrixOffset = 4, + arg_matrixStride = 5, + arg_matrixIntepretation = 6, + arg_matrixLayout = 7, + }; + // Accessors + llvm::Value *get_inputVector1() const { return Instr->getOperand(1); } + void set_inputVector1(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_inputVector2() const { return Instr->getOperand(2); } + void set_inputVector2(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_matrixBuffer() const { return Instr->getOperand(3); } + void set_matrixBuffer(llvm::Value *val) { Instr->setOperand(3, val); } + llvm::Value *get_matrixOffset() const { return Instr->getOperand(4); } + void set_matrixOffset(llvm::Value *val) { Instr->setOperand(4, val); } + llvm::Value *get_matrixStride() const { return Instr->getOperand(5); } + void set_matrixStride(llvm::Value *val) { Instr->setOperand(5, val); } + llvm::Value *get_matrixIntepretation() const { return Instr->getOperand(6); } + void set_matrixIntepretation(llvm::Value *val) { Instr->setOperand(6, val); } + llvm::Value *get_matrixLayout() const { return Instr->getOperand(7); } + void set_matrixLayout(llvm::Value *val) { Instr->setOperand(7, val); } +}; + +/// This instruction Vector Accumulate +struct DxilInst_VectorAccumulate { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_VectorAccumulate(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::VectorAccumulate); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_inputVector = 1, + arg_arrayBuffer = 2, + arg_arrayOffset = 3, + }; + // Accessors + llvm::Value *get_inputVector() const { return Instr->getOperand(1); } + void set_inputVector(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_arrayBuffer() const { return Instr->getOperand(2); } + void set_arrayBuffer(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_arrayOffset() const { return Instr->getOperand(3); } + void set_arrayOffset(llvm::Value *val) { Instr->setOperand(3, val); } }; // INSTR-HELPER:END } // namespace hlsl diff --git a/include/dxc/HLSL/HLOperations.h b/include/dxc/HLSL/HLOperations.h index f87d324baf..b4838b6046 100644 --- a/include/dxc/HLSL/HLOperations.h +++ b/include/dxc/HLSL/HLOperations.h @@ -433,6 +433,52 @@ const unsigned kNodeHandleToResCastOpIdx = 1; const unsigned kAnnotateNodeHandleNodePropIdx = 2; const unsigned kAnnotateNodeRecordHandleNodeRecordPropIdx = 2; +// Linear Algebra Operations + +// MatVecMul +const unsigned kMatVecMulOutputVectorIdx = 1; +const unsigned kMatVecMulInputVectorIdx = 2; +const unsigned kMatVecMulInputInterpretationIdx = 3; +const unsigned kMatVecMulMatrixBufferIdx = 4; +const unsigned kMatVecMulMatrixOffsetIdx = 5; +const unsigned kMatVecMulMatrixInterpretationIdx = 6; +const unsigned kMatVecMulMatrixMIdx = 7; +const unsigned kMatVecMulMatrixKIdx = 8; +const unsigned kMatVecMulMatrixLayoutIdx = 9; +const unsigned kMatVecMulMatrixTransposeIdx = 10; +const unsigned kMatVecMulMatrixStrideIdx = 11; + + +// MatVecMulAdd +const unsigned kMatVecMulAddOutputVectorIdx = 1; +const unsigned kMatVecMulAddInputVectorIdx = 2; +const unsigned kMatVecMulAddInputInterpretationIdx = 3; +const unsigned kMatVecMulAddMatrixBufferIdx = 4; +const unsigned kMatVecMulAddMatrixOffsetIdx = 5; +const unsigned kMatVecMulAddMatrixInterpretationIdx = 6; +const unsigned kMatVecMulAddMatrixMIdx = 7; +const unsigned kMatVecMulAddMatrixKIdx = 8; +const unsigned kMatVecMulAddMatrixLayoutIdx = 9; +const unsigned kMatVecMulAddMatrixTransposeIdx = 10; +const unsigned kMatVecMulAddMatrixStrideIdx = 11; +const unsigned kMatVecMulAddBiasBufferIdx = 12; +const unsigned kMatVecMulAddBiasOffsetIdx = 13; +const unsigned kMatVecMulAddBiasInterpretationIdx = 14; + + +// OuterProductAccumulate +const unsigned kOuterProdAccInputVec1Idx = 1; +const unsigned kOuterProdAccInputVec2Idx = 2; +const unsigned kOuterProdAccMatrixIdx = 3; +const unsigned kOuterProdAccMatrixOffsetIdx = 4; +const unsigned kOuterProdAccMatrixInterpretationIdx = 5; +const unsigned kOuterProdAccMatrixLayoutIdx = 6; +const unsigned kOuterProdAccMatrixStrideIdx = 7; + +// Vector Accumulate +const unsigned kVectorAccInputVecIdx = 1; +const unsigned kVectorAccMatrixIdx = 2; +const unsigned kVectorAccMatrixOffsetIdx = 3; } // namespace HLOperandIndex llvm::Function *GetOrCreateHLFunction(llvm::Module &M, diff --git a/include/dxc/HlslIntrinsicOp.h b/include/dxc/HlslIntrinsicOp.h index 90f3fafd79..aaed521472 100644 --- a/include/dxc/HlslIntrinsicOp.h +++ b/include/dxc/HlslIntrinsicOp.h @@ -333,8 +333,6 @@ enum class IntrinsicOp { MOP_TraceRayInline = 325, MOP_WorldRayDirection = 326, MOP_WorldRayOrigin = 327, - MOP_DxHitObject_MakeNop = 358, - IOP_DxMaybeReorderThread = 359, MOP_Count = 328, MOP_FinishedCrossGroupSharing = 329, MOP_GetGroupNodeOutputRecords = 330, @@ -366,7 +364,13 @@ enum class IntrinsicOp { IOP_usign = 355, MOP_InterlockedUMax = 356, MOP_InterlockedUMin = 357, - Num_Intrinsics = 360, + MOP_DxHitObject_MakeNop = 358, + IOP_DxMaybeReorderThread = 359, + IOP___builtin_MatVecMul = 360, + IOP___builtin_MatVecMulAdd = 361, + IOP___builtin_OuterProductAccumulate = 362, + IOP___builtin_VectorAccumulate = 363, + Num_Intrinsics = 364, }; inline bool HasUnsignedIntrinsicOpcode(IntrinsicOp opcode) { switch (opcode) { diff --git a/lib/DXIL/DxilOperations.cpp b/lib/DXIL/DxilOperations.cpp index 5e0757aac1..2ee7d7923b 100644 --- a/lib/DXIL/DxilOperations.cpp +++ b/lib/DXIL/DxilOperations.cpp @@ -39,2616 +39,485 @@ import hctdb_instrhelp /* hctdb_instrhelp.get_oloads_props()*/ // OPCODE-OLOADS:BEGIN const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = { - // Temporary, indexable, input, output registers - {OC::TempRegLoad, - "TempRegLoad", - OCC::TempRegLoad, - "tempRegLoad", - Attribute::ReadOnly, - 1, - {{0x63}}, - {{0x0}}}, // Overloads: hfwi - {OC::TempRegStore, - "TempRegStore", - OCC::TempRegStore, - "tempRegStore", - Attribute::None, - 1, - {{0x63}}, - {{0x0}}}, // Overloads: hfwi - {OC::MinPrecXRegLoad, - "MinPrecXRegLoad", - OCC::MinPrecXRegLoad, - "minPrecXRegLoad", - Attribute::ReadOnly, - 1, - {{0x21}}, - {{0x0}}}, // Overloads: hw - {OC::MinPrecXRegStore, - "MinPrecXRegStore", - OCC::MinPrecXRegStore, - "minPrecXRegStore", - Attribute::None, - 1, - {{0x21}}, - {{0x0}}}, // Overloads: hw - {OC::LoadInput, - "LoadInput", - OCC::LoadInput, - "loadInput", - Attribute::ReadNone, - 1, - {{0x63}}, - {{0x0}}}, // Overloads: hfwi - {OC::StoreOutput, - "StoreOutput", - OCC::StoreOutput, - "storeOutput", - Attribute::None, - 1, - {{0x63}}, - {{0x0}}}, // Overloads: hfwi - - // Unary float - {OC::FAbs, - "FAbs", - OCC::Unary, - "unary", - Attribute::ReadNone, - 1, - {{0x7}}, - {{0x0}}}, // Overloads: hfd - {OC::Saturate, - "Saturate", - OCC::Unary, - "unary", - Attribute::ReadNone, - 1, - {{0x7}}, - {{0x0}}}, // Overloads: hfd - {OC::IsNaN, - "IsNaN", - OCC::IsSpecialFloat, - "isSpecialFloat", - Attribute::ReadNone, - 1, - {{0x3}}, - {{0x0}}}, // Overloads: hf - {OC::IsInf, - "IsInf", - OCC::IsSpecialFloat, - "isSpecialFloat", - Attribute::ReadNone, - 1, - {{0x3}}, - {{0x0}}}, // Overloads: hf - {OC::IsFinite, - "IsFinite", - OCC::IsSpecialFloat, - "isSpecialFloat", - Attribute::ReadNone, - 1, - {{0x3}}, - {{0x0}}}, // Overloads: hf - {OC::IsNormal, - "IsNormal", - OCC::IsSpecialFloat, - "isSpecialFloat", - Attribute::ReadNone, - 1, - {{0x3}}, - {{0x0}}}, // Overloads: hf - {OC::Cos, - "Cos", - OCC::Unary, - "unary", - Attribute::ReadNone, - 1, - {{0x403}}, - {{0x3}}}, // Overloads: hfhctdb_instrhelp.get_oloads_funcs()*/ switch (opCode) { // return opCode // OPCODE-OLOAD-FUNCS:BEGIN - // Temporary, indexable, input, output registers - case OpCode::TempRegLoad: - A(pETy); - A(pI32); - A(pI32); - break; - case OpCode::TempRegStore: - A(pV); - A(pI32); - A(pI32); - A(pETy); - break; - case OpCode::MinPrecXRegLoad: - A(pETy); - A(pI32); - A(pPF32); - A(pI32); - A(pI8); - break; - case OpCode::MinPrecXRegStore: - A(pV); - A(pI32); - A(pPF32); - A(pI32); - A(pI8); - A(pETy); - break; - case OpCode::LoadInput: - A(pETy); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pI32); - break; - case OpCode::StoreOutput: - A(pV); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pETy); - break; - - // Unary float - case OpCode::FAbs: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Saturate: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::IsNaN: - A(pI1); - A(pI32); - A(pETy); - break; - case OpCode::IsInf: - A(pI1); - A(pI32); - A(pETy); - break; - case OpCode::IsFinite: - A(pI1); - A(pI32); - A(pETy); - break; - case OpCode::IsNormal: - A(pI1); - A(pI32); - A(pETy); - break; - case OpCode::Cos: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Sin: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Tan: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Acos: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Asin: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Atan: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Hcos: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Hsin: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Htan: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Exp: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Frc: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Log: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Sqrt: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Rsqrt: - A(pETy); - A(pI32); - A(pETy); - break; - - // Unary float - rounding - case OpCode::Round_ne: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Round_ni: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Round_pi: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Round_z: - A(pETy); - A(pI32); - A(pETy); - break; - - // Unary int - case OpCode::Bfrev: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::Countbits: - A(pI32); - A(pI32); - A(pETy); - break; - case OpCode::FirstbitLo: - A(pI32); - A(pI32); - A(pETy); + // Temporary, indexable, input, output registers + case OpCode::TempRegLoad: A(pETy); A(pI32); A(pI32); break; + case OpCode::TempRegStore: A(pV); A(pI32); A(pI32); A(pETy); break; + case OpCode::MinPrecXRegLoad: A(pETy); A(pI32); A(pPF32);A(pI32); A(pI8); break; + case OpCode::MinPrecXRegStore: A(pV); A(pI32); A(pPF32);A(pI32); A(pI8); A(pETy); break; + case OpCode::LoadInput: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI32); break; + case OpCode::StoreOutput: A(pV); A(pI32); A(pI32); A(pI32); A(pI8); A(pETy); break; + + // Unary float + case OpCode::FAbs: A(pETy); A(pI32); A(pETy); break; + case OpCode::Saturate: A(pETy); A(pI32); A(pETy); break; + case OpCode::IsNaN: A(pI1); A(pI32); A(pETy); break; + case OpCode::IsInf: A(pI1); A(pI32); A(pETy); break; + case OpCode::IsFinite: A(pI1); A(pI32); A(pETy); break; + case OpCode::IsNormal: A(pI1); A(pI32); A(pETy); break; + case OpCode::Cos: A(pETy); A(pI32); A(pETy); break; + case OpCode::Sin: A(pETy); A(pI32); A(pETy); break; + case OpCode::Tan: A(pETy); A(pI32); A(pETy); break; + case OpCode::Acos: A(pETy); A(pI32); A(pETy); break; + case OpCode::Asin: A(pETy); A(pI32); A(pETy); break; + case OpCode::Atan: A(pETy); A(pI32); A(pETy); break; + case OpCode::Hcos: A(pETy); A(pI32); A(pETy); break; + case OpCode::Hsin: A(pETy); A(pI32); A(pETy); break; + case OpCode::Htan: A(pETy); A(pI32); A(pETy); break; + case OpCode::Exp: A(pETy); A(pI32); A(pETy); break; + case OpCode::Frc: A(pETy); A(pI32); A(pETy); break; + case OpCode::Log: A(pETy); A(pI32); A(pETy); break; + case OpCode::Sqrt: A(pETy); A(pI32); A(pETy); break; + case OpCode::Rsqrt: A(pETy); A(pI32); A(pETy); break; + + // Unary float - rounding + case OpCode::Round_ne: A(pETy); A(pI32); A(pETy); break; + case OpCode::Round_ni: A(pETy); A(pI32); A(pETy); break; + case OpCode::Round_pi: A(pETy); A(pI32); A(pETy); break; + case OpCode::Round_z: A(pETy); A(pI32); A(pETy); break; + + // Unary int + case OpCode::Bfrev: A(pETy); A(pI32); A(pETy); break; + case OpCode::Countbits: A(pI32); A(pI32); A(pETy); break; + case OpCode::FirstbitLo: A(pI32); A(pI32); A(pETy); break; + + // Unary uint + case OpCode::FirstbitHi: A(pI32); A(pI32); A(pETy); break; + + // Unary int + case OpCode::FirstbitSHi: A(pI32); A(pI32); A(pETy); break; + + // Binary float + case OpCode::FMax: A(pETy); A(pI32); A(pETy); A(pETy); break; + case OpCode::FMin: A(pETy); A(pI32); A(pETy); A(pETy); break; + + // Binary int + case OpCode::IMax: A(pETy); A(pI32); A(pETy); A(pETy); break; + case OpCode::IMin: A(pETy); A(pI32); A(pETy); A(pETy); break; + + // Binary uint + case OpCode::UMax: A(pETy); A(pI32); A(pETy); A(pETy); break; + case OpCode::UMin: A(pETy); A(pI32); A(pETy); A(pETy); break; + + // Binary int with two outputs + case OpCode::IMul: A(p2I32); A(pI32); A(pETy); A(pETy); break; + + // Binary uint with two outputs + case OpCode::UMul: A(p2I32); A(pI32); A(pETy); A(pETy); break; + case OpCode::UDiv: A(p2I32); A(pI32); A(pETy); A(pETy); break; + + // Binary uint with carry or borrow + case OpCode::UAddc: A(pI32C); A(pI32); A(pETy); A(pETy); break; + case OpCode::USubb: A(pI32C); A(pI32); A(pETy); A(pETy); break; + + // Tertiary float + case OpCode::FMad: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; + case OpCode::Fma: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; + + // Tertiary int + case OpCode::IMad: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; + + // Tertiary uint + case OpCode::UMad: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; + + // Tertiary int + case OpCode::Msad: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; + case OpCode::Ibfe: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; + + // Tertiary uint + case OpCode::Ubfe: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; + + // Quaternary + case OpCode::Bfi: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); break; + + // Dot + case OpCode::Dot2: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); break; + case OpCode::Dot3: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); break; + case OpCode::Dot4: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); break; + + // Resources + case OpCode::CreateHandle: A(pRes); A(pI32); A(pI8); A(pI32); A(pI32); A(pI1); break; + case OpCode::CBufferLoad: A(pETy); A(pI32); A(pRes); A(pI32); A(pI32); break; + case OpCode::CBufferLoadLegacy: CBRT(pETy); A(pI32); A(pRes); A(pI32); break; + + // Resources - sample + case OpCode::Sample: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); break; + case OpCode::SampleBias: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); break; + case OpCode::SampleLevel: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); break; + case OpCode::SampleGrad: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; + case OpCode::SampleCmp: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); break; + case OpCode::SampleCmpLevelZero: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); break; + + // Resources + case OpCode::TextureLoad: RRT(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); break; + case OpCode::TextureStore: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pI8); break; + case OpCode::BufferLoad: RRT(pETy); A(pI32); A(pRes); A(pI32); A(pI32); break; + case OpCode::BufferStore: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pI8); break; + case OpCode::BufferUpdateCounter: A(pI32); A(pI32); A(pRes); A(pI8); break; + case OpCode::CheckAccessFullyMapped: A(pI1); A(pI32); A(pI32); break; + case OpCode::GetDimensions: A(pDim); A(pI32); A(pRes); A(pI32); break; + + // Resources - gather + case OpCode::TextureGather: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); break; + case OpCode::TextureGatherCmp: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); break; + + // Resources - sample + case OpCode::Texture2DMSGetSamplePosition:A(pPos); A(pI32); A(pRes); A(pI32); break; + case OpCode::RenderTargetGetSamplePosition:A(pPos); A(pI32); A(pI32); break; + case OpCode::RenderTargetGetSampleCount:A(pI32); A(pI32); break; + + // Synchronization + case OpCode::AtomicBinOp: A(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pETy); break; + case OpCode::AtomicCompareExchange: A(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pETy); A(pETy); break; + case OpCode::Barrier: A(pV); A(pI32); A(pI32); break; + + // Derivatives + case OpCode::CalculateLOD: A(pF32); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pI1); break; + + // Pixel shader + case OpCode::Discard: A(pV); A(pI32); A(pI1); break; + + // Derivatives + case OpCode::DerivCoarseX: A(pETy); A(pI32); A(pETy); break; + case OpCode::DerivCoarseY: A(pETy); A(pI32); A(pETy); break; + case OpCode::DerivFineX: A(pETy); A(pI32); A(pETy); break; + case OpCode::DerivFineY: A(pETy); A(pI32); A(pETy); break; + + // Pixel shader + case OpCode::EvalSnapped: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI32); A(pI32); break; + case OpCode::EvalSampleIndex: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI32); break; + case OpCode::EvalCentroid: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); break; + case OpCode::SampleIndex: A(pI32); A(pI32); break; + case OpCode::Coverage: A(pI32); A(pI32); break; + case OpCode::InnerCoverage: A(pI32); A(pI32); break; + + // Compute/Mesh/Amplification/Node shader + case OpCode::ThreadId: A(pI32); A(pI32); A(pI32); break; + case OpCode::GroupId: A(pI32); A(pI32); A(pI32); break; + case OpCode::ThreadIdInGroup: A(pI32); A(pI32); A(pI32); break; + case OpCode::FlattenedThreadIdInGroup:A(pI32); A(pI32); break; + + // Geometry shader + case OpCode::EmitStream: A(pV); A(pI32); A(pI8); break; + case OpCode::CutStream: A(pV); A(pI32); A(pI8); break; + case OpCode::EmitThenCutStream: A(pV); A(pI32); A(pI8); break; + case OpCode::GSInstanceID: A(pI32); A(pI32); break; + + // Double precision + case OpCode::MakeDouble: A(pF64); A(pI32); A(pI32); A(pI32); break; + case OpCode::SplitDouble: A(pSDT); A(pI32); A(pF64); break; + + // Domain and hull shader + case OpCode::LoadOutputControlPoint: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI32); break; + case OpCode::LoadPatchConstant: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); break; + + // Domain shader + case OpCode::DomainLocation: A(pF32); A(pI32); A(pI8); break; + + // Hull shader + case OpCode::StorePatchConstant: A(pV); A(pI32); A(pI32); A(pI32); A(pI8); A(pETy); break; + case OpCode::OutputControlPointID: A(pI32); A(pI32); break; + + // Hull, Domain and Geometry shaders + case OpCode::PrimitiveID: A(pI32); A(pI32); break; + + // Other + case OpCode::CycleCounterLegacy: A(p2I32); A(pI32); break; + + // Wave + case OpCode::WaveIsFirstLane: A(pI1); A(pI32); break; + case OpCode::WaveGetLaneIndex: A(pI32); A(pI32); break; + case OpCode::WaveGetLaneCount: A(pI32); A(pI32); break; + case OpCode::WaveAnyTrue: A(pI1); A(pI32); A(pI1); break; + case OpCode::WaveAllTrue: A(pI1); A(pI32); A(pI1); break; + case OpCode::WaveActiveAllEqual: A(pI1); A(pI32); A(pETy); break; + case OpCode::WaveActiveBallot: A(p4I32); A(pI32); A(pI1); break; + case OpCode::WaveReadLaneAt: A(pETy); A(pI32); A(pETy); A(pI32); break; + case OpCode::WaveReadLaneFirst: A(pETy); A(pI32); A(pETy); break; + case OpCode::WaveActiveOp: A(pETy); A(pI32); A(pETy); A(pI8); A(pI8); break; + case OpCode::WaveActiveBit: A(pETy); A(pI32); A(pETy); A(pI8); break; + case OpCode::WavePrefixOp: A(pETy); A(pI32); A(pETy); A(pI8); A(pI8); break; + + // Quad Wave Ops + case OpCode::QuadReadLaneAt: A(pETy); A(pI32); A(pETy); A(pI32); break; + case OpCode::QuadOp: A(pETy); A(pI32); A(pETy); A(pI8); break; + + // Bitcasts with different sizes + case OpCode::BitcastI16toF16: A(pF16); A(pI32); A(pI16); break; + case OpCode::BitcastF16toI16: A(pI16); A(pI32); A(pF16); break; + case OpCode::BitcastI32toF32: A(pF32); A(pI32); A(pI32); break; + case OpCode::BitcastF32toI32: A(pI32); A(pI32); A(pF32); break; + case OpCode::BitcastI64toF64: A(pF64); A(pI32); A(pI64); break; + case OpCode::BitcastF64toI64: A(pI64); A(pI32); A(pF64); break; + + // Legacy floating-point + case OpCode::LegacyF32ToF16: A(pI32); A(pI32); A(pF32); break; + case OpCode::LegacyF16ToF32: A(pF32); A(pI32); A(pI32); break; + + // Double precision + case OpCode::LegacyDoubleToFloat: A(pF32); A(pI32); A(pF64); break; + case OpCode::LegacyDoubleToSInt32: A(pI32); A(pI32); A(pF64); break; + case OpCode::LegacyDoubleToUInt32: A(pI32); A(pI32); A(pF64); break; + + // Wave + case OpCode::WaveAllBitCount: A(pI32); A(pI32); A(pI1); break; + case OpCode::WavePrefixBitCount: A(pI32); A(pI32); A(pI1); break; + + // Pixel shader + case OpCode::AttributeAtVertex: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI8); break; + + // Graphics shader + case OpCode::ViewID: A(pI32); A(pI32); break; + + // Resources + case OpCode::RawBufferLoad: RRT(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI8); A(pI32); break; + case OpCode::RawBufferStore: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pI8); A(pI32); break; + + // Raytracing object space uint System Values + case OpCode::InstanceID: A(pI32); A(pI32); break; + case OpCode::InstanceIndex: A(pI32); A(pI32); break; + + // Raytracing hit uint System Values + case OpCode::HitKind: A(pI32); A(pI32); break; + + // Raytracing uint System Values + case OpCode::RayFlags: A(pI32); A(pI32); break; + + // Ray Dispatch Arguments + case OpCode::DispatchRaysIndex: A(pI32); A(pI32); A(pI8); break; + case OpCode::DispatchRaysDimensions: A(pI32); A(pI32); A(pI8); break; + + // Ray Vectors + case OpCode::WorldRayOrigin: A(pF32); A(pI32); A(pI8); break; + case OpCode::WorldRayDirection: A(pF32); A(pI32); A(pI8); break; + + // Ray object space Vectors + case OpCode::ObjectRayOrigin: A(pF32); A(pI32); A(pI8); break; + case OpCode::ObjectRayDirection: A(pF32); A(pI32); A(pI8); break; + + // Ray Transforms + case OpCode::ObjectToWorld: A(pF32); A(pI32); A(pI32); A(pI8); break; + case OpCode::WorldToObject: A(pF32); A(pI32); A(pI32); A(pI8); break; + + // RayT + case OpCode::RayTMin: A(pF32); A(pI32); break; + case OpCode::RayTCurrent: A(pF32); A(pI32); break; + + // AnyHit Terminals + case OpCode::IgnoreHit: A(pV); A(pI32); break; + case OpCode::AcceptHitAndEndSearch: A(pV); A(pI32); break; + + // Indirect Shader Invocation + case OpCode::TraceRay: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(udt); break; + case OpCode::ReportHit: A(pI1); A(pI32); A(pF32); A(pI32); A(udt); break; + case OpCode::CallShader: A(pV); A(pI32); A(pI32); A(udt); break; + + // Library create handle from resource struct (like HL intrinsic) + case OpCode::CreateHandleForLib: A(pRes); A(pI32); A(obj); break; + + // Raytracing object space uint System Values + case OpCode::PrimitiveIndex: A(pI32); A(pI32); break; + + // Dot product with accumulate + case OpCode::Dot2AddHalf: A(pETy); A(pI32); A(pETy); A(pF16); A(pF16); A(pF16); A(pF16); break; + case OpCode::Dot4AddI8Packed: A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); break; + case OpCode::Dot4AddU8Packed: A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); break; + + // Wave + case OpCode::WaveMatch: A(p4I32); A(pI32); A(pETy); break; + case OpCode::WaveMultiPrefixOp: A(pETy); A(pI32); A(pETy); A(pI32); A(pI32); A(pI32); A(pI32); A(pI8); A(pI8); break; + case OpCode::WaveMultiPrefixBitCount:A(pI32); A(pI32); A(pI1); A(pI32); A(pI32); A(pI32); A(pI32); break; + + // Mesh shader instructions + case OpCode::SetMeshOutputCounts: A(pV); A(pI32); A(pI32); A(pI32); break; + case OpCode::EmitIndices: A(pV); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); break; + case OpCode::GetMeshPayload: A(pETy); A(pI32); break; + case OpCode::StoreVertexOutput: A(pV); A(pI32); A(pI32); A(pI32); A(pI8); A(pETy); A(pI32); break; + case OpCode::StorePrimitiveOutput: A(pV); A(pI32); A(pI32); A(pI32); A(pI8); A(pETy); A(pI32); break; + + // Amplification shader instructions + case OpCode::DispatchMesh: A(pV); A(pI32); A(pI32); A(pI32); A(pI32); A(pETy); break; + + // Sampler Feedback + case OpCode::WriteSamplerFeedback: A(pV); A(pI32); A(pRes); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; + case OpCode::WriteSamplerFeedbackBias:A(pV); A(pI32); A(pRes); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; + case OpCode::WriteSamplerFeedbackLevel:A(pV); A(pI32); A(pRes); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; + case OpCode::WriteSamplerFeedbackGrad:A(pV); A(pI32); A(pRes); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; + + // Inline Ray Query + case OpCode::AllocateRayQuery: A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_TraceRayInline:A(pV); A(pI32); A(pI32); A(pRes); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; + case OpCode::RayQuery_Proceed: A(pI1); A(pI32); A(pI32); break; + case OpCode::RayQuery_Abort: A(pV); A(pI32); A(pI32); break; + case OpCode::RayQuery_CommitNonOpaqueTriangleHit:A(pV); A(pI32); A(pI32); break; + case OpCode::RayQuery_CommitProceduralPrimitiveHit:A(pV); A(pI32); A(pI32); A(pF32); break; + case OpCode::RayQuery_CommittedStatus:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidateType: A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidateObjectToWorld3x4:A(pF32); A(pI32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_CandidateWorldToObject3x4:A(pF32); A(pI32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_CommittedObjectToWorld3x4:A(pF32); A(pI32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_CommittedWorldToObject3x4:A(pF32); A(pI32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_CandidateProceduralPrimitiveNonOpaque:A(pI1); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidateTriangleFrontFace:A(pI1); A(pI32); A(pI32); break; + case OpCode::RayQuery_CommittedTriangleFrontFace:A(pI1); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidateTriangleBarycentrics:A(pF32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_CommittedTriangleBarycentrics:A(pF32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_RayFlags: A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_WorldRayOrigin:A(pF32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_WorldRayDirection:A(pF32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_RayTMin: A(pF32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidateTriangleRayT:A(pF32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CommittedRayT: A(pF32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidateInstanceIndex:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidateInstanceID:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidateGeometryIndex:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidatePrimitiveIndex:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CandidateObjectRayOrigin:A(pF32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_CandidateObjectRayDirection:A(pF32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_CommittedInstanceIndex:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CommittedInstanceID:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CommittedGeometryIndex:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CommittedPrimitiveIndex:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CommittedObjectRayOrigin:A(pF32); A(pI32); A(pI32); A(pI8); break; + case OpCode::RayQuery_CommittedObjectRayDirection:A(pF32); A(pI32); A(pI32); A(pI8); break; + + // Raytracing object space uint System Values, raytracing tier 1.1 + case OpCode::GeometryIndex: A(pI32); A(pI32); break; + + // Inline Ray Query + case OpCode::RayQuery_CandidateInstanceContributionToHitGroupIndex:A(pI32); A(pI32); A(pI32); break; + case OpCode::RayQuery_CommittedInstanceContributionToHitGroupIndex:A(pI32); A(pI32); A(pI32); break; + + // Get handle from heap + case OpCode::AnnotateHandle: A(pRes); A(pI32); A(pRes); A(resProperty);break; + case OpCode::CreateHandleFromBinding:A(pRes); A(pI32); A(resBind);A(pI32); A(pI1); break; + case OpCode::CreateHandleFromHeap: A(pRes); A(pI32); A(pI32); A(pI1); A(pI1); break; + + // Unpacking intrinsics + case OpCode::Unpack4x8: VEC4(pETy); A(pI32); A(pI8); A(pI32); break; + + // Packing intrinsics + case OpCode::Pack4x8: A(pI32); A(pI32); A(pI8); A(pETy); A(pETy); A(pETy); A(pETy); break; + + // Helper Lanes + case OpCode::IsHelperLane: A(pI1); A(pI32); break; + + // Quad Wave Ops + case OpCode::QuadVote: A(pI1); A(pI32); A(pI1); A(pI8); break; + + // Resources - gather + case OpCode::TextureGatherRaw: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); break; + + // Resources - sample + case OpCode::SampleCmpLevel: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); break; + + // Resources + case OpCode::TextureStoreSample: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pI8); A(pI32); break; + + // + case OpCode::Reserved0: A(pV); A(pI32); break; + case OpCode::Reserved1: A(pV); A(pI32); break; + case OpCode::Reserved2: A(pV); A(pI32); break; + case OpCode::Reserved3: A(pV); A(pI32); break; + case OpCode::Reserved4: A(pV); A(pI32); break; + case OpCode::Reserved5: A(pV); A(pI32); break; + case OpCode::Reserved6: A(pV); A(pI32); break; + case OpCode::Reserved7: A(pV); A(pI32); break; + case OpCode::Reserved8: A(pV); A(pI32); break; + case OpCode::Reserved9: A(pV); A(pI32); break; + case OpCode::Reserved10: A(pV); A(pI32); break; + case OpCode::Reserved11: A(pV); A(pI32); break; + + // Create/Annotate Node Handles + case OpCode::AllocateNodeOutputRecords:A(pNodeRecordHandle);A(pI32); A(pNodeHandle);A(pI32); A(pI1); break; + + // Get Pointer to Node Record in Address Space 6 + case OpCode::GetNodeRecordPtr: A(pETy); A(pI32); A(pNodeRecordHandle);A(pI32); break; + + // Work Graph intrinsics + case OpCode::IncrementOutputCount: A(pV); A(pI32); A(pNodeHandle);A(pI32); A(pI1); break; + case OpCode::OutputComplete: A(pV); A(pI32); A(pNodeRecordHandle);break; + case OpCode::GetInputRecordCount: A(pI32); A(pI32); A(pNodeRecordHandle);break; + case OpCode::FinishedCrossGroupSharing:A(pI1); A(pI32); A(pNodeRecordHandle);break; + + // Synchronization + case OpCode::BarrierByMemoryType: A(pV); A(pI32); A(pI32); A(pI32); break; + case OpCode::BarrierByMemoryHandle: A(pV); A(pI32); A(pRes); A(pI32); break; + case OpCode::BarrierByNodeRecordHandle:A(pV); A(pI32); A(pNodeRecordHandle);A(pI32); break; + + // Create/Annotate Node Handles + case OpCode::CreateNodeOutputHandle: A(pNodeHandle);A(pI32); A(pI32); break; + case OpCode::IndexNodeHandle: A(pNodeHandle);A(pI32); A(pNodeHandle);A(pI32); break; + case OpCode::AnnotateNodeHandle: A(pNodeHandle);A(pI32); A(pNodeHandle);A(nodeProperty);break; + case OpCode::CreateNodeInputRecordHandle:A(pNodeRecordHandle);A(pI32); A(pI32); break; + case OpCode::AnnotateNodeRecordHandle:A(pNodeRecordHandle);A(pI32); A(pNodeRecordHandle);A(nodeRecordProperty);break; + + // Work Graph intrinsics + case OpCode::NodeOutputIsValid: A(pI1); A(pI32); A(pNodeHandle);break; + case OpCode::GetRemainingRecursionLevels:A(pI32); A(pI32); break; + + // Comparison Samples + case OpCode::SampleCmpGrad: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; + case OpCode::SampleCmpBias: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); break; + + // Extended Command Information + case OpCode::StartVertexLocation: A(pI32); A(pI32); break; + case OpCode::StartInstanceLocation: A(pI32); A(pI32); break; + + // Inline Ray Query + case OpCode::AllocateRayQuery2: A(pI32); A(pI32); A(pI32); A(pI32); break; + + // + case OpCode::ReservedA0: A(pV); A(pI32); break; + case OpCode::ReservedA1: A(pV); A(pI32); break; + case OpCode::ReservedA2: A(pV); A(pI32); break; + case OpCode::ReservedB0: A(pV); A(pI32); break; + case OpCode::ReservedB1: A(pV); A(pI32); break; + case OpCode::ReservedB2: A(pV); A(pI32); break; + + // Shader Execution Reordering + case OpCode::HitObject_MakeMiss: A(pHit); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; + case OpCode::HitObject_MakeNop: A(pHit); A(pI32); break; + + // + case OpCode::ReservedB5: A(pV); A(pI32); break; + case OpCode::ReservedB6: A(pV); A(pI32); break; + case OpCode::ReservedB7: A(pV); A(pI32); break; + case OpCode::ReservedB8: A(pV); A(pI32); break; + case OpCode::ReservedB9: A(pV); A(pI32); break; + case OpCode::ReservedB10: A(pV); A(pI32); break; + case OpCode::ReservedB11: A(pV); A(pI32); break; + case OpCode::ReservedB12: A(pV); A(pI32); break; + case OpCode::ReservedB13: A(pV); A(pI32); break; + case OpCode::ReservedB14: A(pV); A(pI32); break; + case OpCode::ReservedB15: A(pV); A(pI32); break; + case OpCode::ReservedB16: A(pV); A(pI32); break; + case OpCode::ReservedB17: A(pV); A(pI32); break; + case OpCode::ReservedB18: A(pV); A(pI32); break; + case OpCode::ReservedB19: A(pV); A(pI32); break; + case OpCode::ReservedB20: A(pV); A(pI32); break; + case OpCode::ReservedB21: A(pV); A(pI32); break; + case OpCode::ReservedB22: A(pV); A(pI32); break; + case OpCode::ReservedB23: A(pV); A(pI32); break; + case OpCode::ReservedB24: A(pV); A(pI32); break; + case OpCode::ReservedB25: A(pV); A(pI32); break; + case OpCode::ReservedB26: A(pV); A(pI32); break; + case OpCode::ReservedB27: A(pV); A(pI32); break; + case OpCode::ReservedB28: A(pV); A(pI32); break; + case OpCode::ReservedB29: A(pV); A(pI32); break; + case OpCode::ReservedB30: A(pV); A(pI32); break; + case OpCode::ReservedC0: A(pV); A(pI32); break; + case OpCode::ReservedC1: A(pV); A(pI32); break; + case OpCode::ReservedC2: A(pV); A(pI32); break; + case OpCode::ReservedC3: A(pV); A(pI32); break; + case OpCode::ReservedC4: A(pV); A(pI32); break; + case OpCode::ReservedC5: A(pV); A(pI32); break; + case OpCode::ReservedC6: A(pV); A(pI32); break; + case OpCode::ReservedC7: A(pV); A(pI32); break; + case OpCode::ReservedC8: A(pV); A(pI32); break; + case OpCode::ReservedC9: A(pV); A(pI32); break; + case OpCode::RawBufferVectorLoad: RRT(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); break; + case OpCode::RawBufferVectorStore: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pETy); A(pI32); break; + case OpCode::MatVecMul: EXT(0); A(pI32); EXT(1); A(pI1); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pI1); A(pI32); A(pI1); break; + case OpCode::MatVecMulAdd: EXT(0); A(pI32); EXT(1); A(pI1); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pI1); A(pI32); A(pRes); A(pI32); A(pI32); A(pI1); break; + case OpCode::OuterProductAccumulate: A(pV); A(pI32); EXT(0); EXT(1); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); break; + case OpCode::VectorAccumulate: A(pV); A(pI32); A(pETy); A(pRes); A(pI32); break; + // OPCODE-OLOAD-FUNCS:END + default: + DXASSERT(false, "otherwise unhandled case"); break; + } +#undef RRT +#undef A - // Unary uint - case OpCode::FirstbitHi: - A(pI32); - A(pI32); - A(pETy); - break; + FunctionType *pFT; + DXASSERT(ArgTypes.size() > 1, "otherwise forgot to initialize arguments"); + pFT = FunctionType::get( + ArgTypes[0], ArrayRef(&ArgTypes[1], ArgTypes.size() - 1), false); - // Unary int - case OpCode::FirstbitSHi: - A(pI32); - A(pI32); - A(pETy); - break; + SmallVector FuncStorage; + StringRef FuncName = + ConstructOverloadName(pOverloadType, opCode, FuncStorage); - // Binary float - case OpCode::FMax: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - break; - case OpCode::FMin: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - break; + // Try to find existing function with the same name in the module. + // This needs to happen after the switch statement that constructs arguments + // and return values to ensure that ResRetType is constructed in the + // RefreshCache case. + if (Function *existF = m_pModule->getFunction(FuncName)) { + if (existF->getFunctionType() != pFT) + return nullptr; + F = existF; + UpdateCache(opClass, pOverloadType, F); + return F; + } - // Binary int - case OpCode::IMax: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - break; - case OpCode::IMin: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - break; + F = cast(m_pModule->getOrInsertFunction(FuncName, pFT)); - // Binary uint - case OpCode::UMax: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - break; - case OpCode::UMin: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - break; + UpdateCache(opClass, pOverloadType, F); + F->setCallingConv(CallingConv::C); + F->addFnAttr(Attribute::NoUnwind); + if (OpProps.FuncAttr != Attribute::None) + F->addFnAttr(OpProps.FuncAttr); - // Binary int with two outputs - case OpCode::IMul: - A(p2I32); - A(pI32); - A(pETy); - A(pETy); - break; + return F; +} - // Binary uint with two outputs - case OpCode::UMul: - A(p2I32); - A(pI32); - A(pETy); - A(pETy); - break; - case OpCode::UDiv: - A(p2I32); - A(pI32); - A(pETy); - A(pETy); - break; +const SmallMapVector & +OP::GetOpFuncList(OpCode opCode) const { + return m_OpCodeClassCache[(unsigned)m_OpCodeProps[(unsigned)opCode] + .opCodeClass] + .pOverloads; +} - // Binary uint with carry or borrow - case OpCode::UAddc: - A(pI32C); - A(pI32); - A(pETy); - A(pETy); - break; - case OpCode::USubb: - A(pI32C); - A(pI32); - A(pETy); - A(pETy); - break; +bool OP::IsDxilOpUsed(OpCode opcode) const { + auto &FnList = GetOpFuncList(opcode); + for (auto &it : FnList) { + llvm::Function *F = it.second; + if (!F) { + continue; + } + if (!F->user_empty()) { + return true; + } + } + return false; +} - // Tertiary float - case OpCode::FMad: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - break; - case OpCode::Fma: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - break; +void OP::RemoveFunction(Function *F) { + if (OP::IsDxilOpFunc(F)) { + OpCodeClass opClass = m_FunctionToOpClass[F]; + for (auto it : m_OpCodeClassCache[(unsigned)opClass].pOverloads) { + if (it.second == F) { + m_OpCodeClassCache[(unsigned)opClass].pOverloads.erase(it.first); + m_FunctionToOpClass.erase(F); + break; + } + } + } +} - // Tertiary int - case OpCode::IMad: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - break; +bool OP::GetOpCodeClass(const Function *F, OP::OpCodeClass &opClass) { + auto iter = m_FunctionToOpClass.find(F); + if (iter == m_FunctionToOpClass.end()) { + // When no user, cannot get opcode. + DXASSERT(F->user_empty() || !IsDxilOpFunc(F), + "dxil function without an opcode class mapping?"); + opClass = OP::OpCodeClass::NumOpClasses; + return false; + } + opClass = iter->second; + return true; +} - // Tertiary uint - case OpCode::UMad: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - break; +bool OP::UseMinPrecision() { + return m_LowPrecisionMode == DXIL::LowPrecisionMode::UseMinPrecision; +} - // Tertiary int - case OpCode::Msad: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - break; - case OpCode::Ibfe: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - break; +void OP::InitWithMinPrecision(bool bMinPrecision) { + DXIL::LowPrecisionMode mode = + bMinPrecision ? DXIL::LowPrecisionMode::UseMinPrecision + : DXIL::LowPrecisionMode::UseNativeLowPrecision; + DXASSERT((mode == m_LowPrecisionMode || + m_LowPrecisionMode == DXIL::LowPrecisionMode::Undefined), + "LowPrecisionMode should only be set once."); - // Tertiary uint - case OpCode::Ubfe: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - break; + if (mode != m_LowPrecisionMode) { + m_LowPrecisionMode = mode; - // Quaternary - case OpCode::Bfi: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - break; + // The following FixOverloadNames() and RefreshCache() calls interact with + // the type cache, which can only be correctly constructed once we know + // the min precision mode. That's why they are called here, rather than + // in the constructor. - // Dot - case OpCode::Dot2: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - break; - case OpCode::Dot3: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - break; - case OpCode::Dot4: - A(pETy); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - break; + // When loading a module into an existing context where types are merged, + // type names may change. When this happens, any intrinsics overloaded on + // UDT types will no longer have matching overload names. + // This causes RefreshCache() to assert. + // This fixes the function names to they match the expected types, + // preventing RefreshCache() from failing due to this issue. + FixOverloadNames(); - // Resources - case OpCode::CreateHandle: - A(pRes); - A(pI32); - A(pI8); - A(pI32); - A(pI32); - A(pI1); - break; - case OpCode::CBufferLoad: - A(pETy); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - break; - case OpCode::CBufferLoadLegacy: - CBRT(pETy); - A(pI32); - A(pRes); - A(pI32); - break; + // Try to find existing intrinsic function. + RefreshCache(); + } +} - // Resources - sample - case OpCode::Sample: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - break; - case OpCode::SampleBias: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - A(pF32); - break; - case OpCode::SampleLevel: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - break; - case OpCode::SampleGrad: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - break; - case OpCode::SampleCmp: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - A(pF32); - break; - case OpCode::SampleCmpLevelZero: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - break; +uint64_t OP::GetAllocSizeForType(llvm::Type *Ty) { + return m_pModule->getDataLayout().getTypeAllocSize(Ty); +} - // Resources - case OpCode::TextureLoad: - RRT(pETy); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::TextureStore: - A(pV); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pI8); - break; - case OpCode::BufferLoad: - RRT(pETy); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - break; - case OpCode::BufferStore: - A(pV); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pI8); - break; - case OpCode::BufferUpdateCounter: - A(pI32); - A(pI32); - A(pRes); - A(pI8); - break; - case OpCode::CheckAccessFullyMapped: - A(pI1); - A(pI32); - A(pI32); - break; - case OpCode::GetDimensions: - A(pDim); - A(pI32); - A(pRes); - A(pI32); - break; - - // Resources - gather - case OpCode::TextureGather: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::TextureGatherCmp: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - break; - - // Resources - sample - case OpCode::Texture2DMSGetSamplePosition: - A(pPos); - A(pI32); - A(pRes); - A(pI32); - break; - case OpCode::RenderTargetGetSamplePosition: - A(pPos); - A(pI32); - A(pI32); - break; - case OpCode::RenderTargetGetSampleCount: - A(pI32); - A(pI32); - break; - - // Synchronization - case OpCode::AtomicBinOp: - A(pETy); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pETy); - break; - case OpCode::AtomicCompareExchange: - A(pETy); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pI32); - A(pETy); - A(pETy); - break; - case OpCode::Barrier: - A(pV); - A(pI32); - A(pI32); - break; - - // Derivatives - case OpCode::CalculateLOD: - A(pF32); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pI1); - break; - - // Pixel shader - case OpCode::Discard: - A(pV); - A(pI32); - A(pI1); - break; - - // Derivatives - case OpCode::DerivCoarseX: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::DerivCoarseY: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::DerivFineX: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::DerivFineY: - A(pETy); - A(pI32); - A(pETy); - break; - - // Pixel shader - case OpCode::EvalSnapped: - A(pETy); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pI32); - A(pI32); - break; - case OpCode::EvalSampleIndex: - A(pETy); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pI32); - break; - case OpCode::EvalCentroid: - A(pETy); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::SampleIndex: - A(pI32); - A(pI32); - break; - case OpCode::Coverage: - A(pI32); - A(pI32); - break; - case OpCode::InnerCoverage: - A(pI32); - A(pI32); - break; - - // Compute/Mesh/Amplification/Node shader - case OpCode::ThreadId: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::GroupId: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::ThreadIdInGroup: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::FlattenedThreadIdInGroup: - A(pI32); - A(pI32); - break; - - // Geometry shader - case OpCode::EmitStream: - A(pV); - A(pI32); - A(pI8); - break; - case OpCode::CutStream: - A(pV); - A(pI32); - A(pI8); - break; - case OpCode::EmitThenCutStream: - A(pV); - A(pI32); - A(pI8); - break; - case OpCode::GSInstanceID: - A(pI32); - A(pI32); - break; - - // Double precision - case OpCode::MakeDouble: - A(pF64); - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::SplitDouble: - A(pSDT); - A(pI32); - A(pF64); - break; - - // Domain and hull shader - case OpCode::LoadOutputControlPoint: - A(pETy); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pI32); - break; - case OpCode::LoadPatchConstant: - A(pETy); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - break; - - // Domain shader - case OpCode::DomainLocation: - A(pF32); - A(pI32); - A(pI8); - break; - - // Hull shader - case OpCode::StorePatchConstant: - A(pV); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pETy); - break; - case OpCode::OutputControlPointID: - A(pI32); - A(pI32); - break; - - // Hull, Domain and Geometry shaders - case OpCode::PrimitiveID: - A(pI32); - A(pI32); - break; - - // Other - case OpCode::CycleCounterLegacy: - A(p2I32); - A(pI32); - break; - - // Wave - case OpCode::WaveIsFirstLane: - A(pI1); - A(pI32); - break; - case OpCode::WaveGetLaneIndex: - A(pI32); - A(pI32); - break; - case OpCode::WaveGetLaneCount: - A(pI32); - A(pI32); - break; - case OpCode::WaveAnyTrue: - A(pI1); - A(pI32); - A(pI1); - break; - case OpCode::WaveAllTrue: - A(pI1); - A(pI32); - A(pI1); - break; - case OpCode::WaveActiveAllEqual: - A(pI1); - A(pI32); - A(pETy); - break; - case OpCode::WaveActiveBallot: - A(p4I32); - A(pI32); - A(pI1); - break; - case OpCode::WaveReadLaneAt: - A(pETy); - A(pI32); - A(pETy); - A(pI32); - break; - case OpCode::WaveReadLaneFirst: - A(pETy); - A(pI32); - A(pETy); - break; - case OpCode::WaveActiveOp: - A(pETy); - A(pI32); - A(pETy); - A(pI8); - A(pI8); - break; - case OpCode::WaveActiveBit: - A(pETy); - A(pI32); - A(pETy); - A(pI8); - break; - case OpCode::WavePrefixOp: - A(pETy); - A(pI32); - A(pETy); - A(pI8); - A(pI8); - break; - - // Quad Wave Ops - case OpCode::QuadReadLaneAt: - A(pETy); - A(pI32); - A(pETy); - A(pI32); - break; - case OpCode::QuadOp: - A(pETy); - A(pI32); - A(pETy); - A(pI8); - break; - - // Bitcasts with different sizes - case OpCode::BitcastI16toF16: - A(pF16); - A(pI32); - A(pI16); - break; - case OpCode::BitcastF16toI16: - A(pI16); - A(pI32); - A(pF16); - break; - case OpCode::BitcastI32toF32: - A(pF32); - A(pI32); - A(pI32); - break; - case OpCode::BitcastF32toI32: - A(pI32); - A(pI32); - A(pF32); - break; - case OpCode::BitcastI64toF64: - A(pF64); - A(pI32); - A(pI64); - break; - case OpCode::BitcastF64toI64: - A(pI64); - A(pI32); - A(pF64); - break; - - // Legacy floating-point - case OpCode::LegacyF32ToF16: - A(pI32); - A(pI32); - A(pF32); - break; - case OpCode::LegacyF16ToF32: - A(pF32); - A(pI32); - A(pI32); - break; - - // Double precision - case OpCode::LegacyDoubleToFloat: - A(pF32); - A(pI32); - A(pF64); - break; - case OpCode::LegacyDoubleToSInt32: - A(pI32); - A(pI32); - A(pF64); - break; - case OpCode::LegacyDoubleToUInt32: - A(pI32); - A(pI32); - A(pF64); - break; - - // Wave - case OpCode::WaveAllBitCount: - A(pI32); - A(pI32); - A(pI1); - break; - case OpCode::WavePrefixBitCount: - A(pI32); - A(pI32); - A(pI1); - break; - - // Pixel shader - case OpCode::AttributeAtVertex: - A(pETy); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pI8); - break; - - // Graphics shader - case OpCode::ViewID: - A(pI32); - A(pI32); - break; - - // Resources - case OpCode::RawBufferLoad: - RRT(pETy); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pI8); - A(pI32); - break; - case OpCode::RawBufferStore: - A(pV); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pI8); - A(pI32); - break; - - // Raytracing object space uint System Values - case OpCode::InstanceID: - A(pI32); - A(pI32); - break; - case OpCode::InstanceIndex: - A(pI32); - A(pI32); - break; - - // Raytracing hit uint System Values - case OpCode::HitKind: - A(pI32); - A(pI32); - break; - - // Raytracing uint System Values - case OpCode::RayFlags: - A(pI32); - A(pI32); - break; - - // Ray Dispatch Arguments - case OpCode::DispatchRaysIndex: - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::DispatchRaysDimensions: - A(pI32); - A(pI32); - A(pI8); - break; - - // Ray Vectors - case OpCode::WorldRayOrigin: - A(pF32); - A(pI32); - A(pI8); - break; - case OpCode::WorldRayDirection: - A(pF32); - A(pI32); - A(pI8); - break; - - // Ray object space Vectors - case OpCode::ObjectRayOrigin: - A(pF32); - A(pI32); - A(pI8); - break; - case OpCode::ObjectRayDirection: - A(pF32); - A(pI32); - A(pI8); - break; - - // Ray Transforms - case OpCode::ObjectToWorld: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::WorldToObject: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - - // RayT - case OpCode::RayTMin: - A(pF32); - A(pI32); - break; - case OpCode::RayTCurrent: - A(pF32); - A(pI32); - break; - - // AnyHit Terminals - case OpCode::IgnoreHit: - A(pV); - A(pI32); - break; - case OpCode::AcceptHitAndEndSearch: - A(pV); - A(pI32); - break; - - // Indirect Shader Invocation - case OpCode::TraceRay: - A(pV); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(udt); - break; - case OpCode::ReportHit: - A(pI1); - A(pI32); - A(pF32); - A(pI32); - A(udt); - break; - case OpCode::CallShader: - A(pV); - A(pI32); - A(pI32); - A(udt); - break; - - // Library create handle from resource struct (like HL intrinsic) - case OpCode::CreateHandleForLib: - A(pRes); - A(pI32); - A(obj); - break; - - // Raytracing object space uint System Values - case OpCode::PrimitiveIndex: - A(pI32); - A(pI32); - break; - - // Dot product with accumulate - case OpCode::Dot2AddHalf: - A(pETy); - A(pI32); - A(pETy); - A(pF16); - A(pF16); - A(pF16); - A(pF16); - break; - case OpCode::Dot4AddI8Packed: - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::Dot4AddU8Packed: - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - break; - - // Wave - case OpCode::WaveMatch: - A(p4I32); - A(pI32); - A(pETy); - break; - case OpCode::WaveMultiPrefixOp: - A(pETy); - A(pI32); - A(pETy); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pI8); - break; - case OpCode::WaveMultiPrefixBitCount: - A(pI32); - A(pI32); - A(pI1); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - break; - - // Mesh shader instructions - case OpCode::SetMeshOutputCounts: - A(pV); - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::EmitIndices: - A(pV); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::GetMeshPayload: - A(pETy); - A(pI32); - break; - case OpCode::StoreVertexOutput: - A(pV); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pETy); - A(pI32); - break; - case OpCode::StorePrimitiveOutput: - A(pV); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - A(pETy); - A(pI32); - break; - - // Amplification shader instructions - case OpCode::DispatchMesh: - A(pV); - A(pI32); - A(pI32); - A(pI32); - A(pI32); - A(pETy); - break; - - // Sampler Feedback - case OpCode::WriteSamplerFeedback: - A(pV); - A(pI32); - A(pRes); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - break; - case OpCode::WriteSamplerFeedbackBias: - A(pV); - A(pI32); - A(pRes); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - break; - case OpCode::WriteSamplerFeedbackLevel: - A(pV); - A(pI32); - A(pRes); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - break; - case OpCode::WriteSamplerFeedbackGrad: - A(pV); - A(pI32); - A(pRes); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - break; - - // Inline Ray Query - case OpCode::AllocateRayQuery: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_TraceRayInline: - A(pV); - A(pI32); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - break; - case OpCode::RayQuery_Proceed: - A(pI1); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_Abort: - A(pV); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CommitNonOpaqueTriangleHit: - A(pV); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CommitProceduralPrimitiveHit: - A(pV); - A(pI32); - A(pI32); - A(pF32); - break; - case OpCode::RayQuery_CommittedStatus: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidateType: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidateObjectToWorld3x4: - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_CandidateWorldToObject3x4: - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_CommittedObjectToWorld3x4: - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_CommittedWorldToObject3x4: - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_CandidateProceduralPrimitiveNonOpaque: - A(pI1); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidateTriangleFrontFace: - A(pI1); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CommittedTriangleFrontFace: - A(pI1); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidateTriangleBarycentrics: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_CommittedTriangleBarycentrics: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_RayFlags: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_WorldRayOrigin: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_WorldRayDirection: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_RayTMin: - A(pF32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidateTriangleRayT: - A(pF32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CommittedRayT: - A(pF32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidateInstanceIndex: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidateInstanceID: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidateGeometryIndex: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidatePrimitiveIndex: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CandidateObjectRayOrigin: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_CandidateObjectRayDirection: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_CommittedInstanceIndex: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CommittedInstanceID: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CommittedGeometryIndex: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CommittedPrimitiveIndex: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CommittedObjectRayOrigin: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - case OpCode::RayQuery_CommittedObjectRayDirection: - A(pF32); - A(pI32); - A(pI32); - A(pI8); - break; - - // Raytracing object space uint System Values, raytracing tier 1.1 - case OpCode::GeometryIndex: - A(pI32); - A(pI32); - break; - - // Inline Ray Query - case OpCode::RayQuery_CandidateInstanceContributionToHitGroupIndex: - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RayQuery_CommittedInstanceContributionToHitGroupIndex: - A(pI32); - A(pI32); - A(pI32); - break; - - // Get handle from heap - case OpCode::AnnotateHandle: - A(pRes); - A(pI32); - A(pRes); - A(resProperty); - break; - case OpCode::CreateHandleFromBinding: - A(pRes); - A(pI32); - A(resBind); - A(pI32); - A(pI1); - break; - case OpCode::CreateHandleFromHeap: - A(pRes); - A(pI32); - A(pI32); - A(pI1); - A(pI1); - break; - - // Unpacking intrinsics - case OpCode::Unpack4x8: - VEC4(pETy); - A(pI32); - A(pI8); - A(pI32); - break; - - // Packing intrinsics - case OpCode::Pack4x8: - A(pI32); - A(pI32); - A(pI8); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - break; - - // Helper Lanes - case OpCode::IsHelperLane: - A(pI1); - A(pI32); - break; - - // Quad Wave Ops - case OpCode::QuadVote: - A(pI1); - A(pI32); - A(pI1); - A(pI8); - break; - - // Resources - gather - case OpCode::TextureGatherRaw: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - break; - - // Resources - sample - case OpCode::SampleCmpLevel: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - A(pF32); - break; - - // Resources - case OpCode::TextureStoreSample: - A(pV); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pI32); - A(pETy); - A(pETy); - A(pETy); - A(pETy); - A(pI8); - A(pI32); - break; - - // - case OpCode::Reserved0: - A(pV); - A(pI32); - break; - case OpCode::Reserved1: - A(pV); - A(pI32); - break; - case OpCode::Reserved2: - A(pV); - A(pI32); - break; - case OpCode::Reserved3: - A(pV); - A(pI32); - break; - case OpCode::Reserved4: - A(pV); - A(pI32); - break; - case OpCode::Reserved5: - A(pV); - A(pI32); - break; - case OpCode::Reserved6: - A(pV); - A(pI32); - break; - case OpCode::Reserved7: - A(pV); - A(pI32); - break; - case OpCode::Reserved8: - A(pV); - A(pI32); - break; - case OpCode::Reserved9: - A(pV); - A(pI32); - break; - case OpCode::Reserved10: - A(pV); - A(pI32); - break; - case OpCode::Reserved11: - A(pV); - A(pI32); - break; - - // Create/Annotate Node Handles - case OpCode::AllocateNodeOutputRecords: - A(pNodeRecordHandle); - A(pI32); - A(pNodeHandle); - A(pI32); - A(pI1); - break; - - // Get Pointer to Node Record in Address Space 6 - case OpCode::GetNodeRecordPtr: - A(pETy); - A(pI32); - A(pNodeRecordHandle); - A(pI32); - break; - - // Work Graph intrinsics - case OpCode::IncrementOutputCount: - A(pV); - A(pI32); - A(pNodeHandle); - A(pI32); - A(pI1); - break; - case OpCode::OutputComplete: - A(pV); - A(pI32); - A(pNodeRecordHandle); - break; - case OpCode::GetInputRecordCount: - A(pI32); - A(pI32); - A(pNodeRecordHandle); - break; - case OpCode::FinishedCrossGroupSharing: - A(pI1); - A(pI32); - A(pNodeRecordHandle); - break; - - // Synchronization - case OpCode::BarrierByMemoryType: - A(pV); - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::BarrierByMemoryHandle: - A(pV); - A(pI32); - A(pRes); - A(pI32); - break; - case OpCode::BarrierByNodeRecordHandle: - A(pV); - A(pI32); - A(pNodeRecordHandle); - A(pI32); - break; - - // Create/Annotate Node Handles - case OpCode::CreateNodeOutputHandle: - A(pNodeHandle); - A(pI32); - A(pI32); - break; - case OpCode::IndexNodeHandle: - A(pNodeHandle); - A(pI32); - A(pNodeHandle); - A(pI32); - break; - case OpCode::AnnotateNodeHandle: - A(pNodeHandle); - A(pI32); - A(pNodeHandle); - A(nodeProperty); - break; - case OpCode::CreateNodeInputRecordHandle: - A(pNodeRecordHandle); - A(pI32); - A(pI32); - break; - case OpCode::AnnotateNodeRecordHandle: - A(pNodeRecordHandle); - A(pI32); - A(pNodeRecordHandle); - A(nodeRecordProperty); - break; - - // Work Graph intrinsics - case OpCode::NodeOutputIsValid: - A(pI1); - A(pI32); - A(pNodeHandle); - break; - case OpCode::GetRemainingRecursionLevels: - A(pI32); - A(pI32); - break; - - // Comparison Samples - case OpCode::SampleCmpGrad: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - break; - case OpCode::SampleCmpBias: - RRT(pETy); - A(pI32); - A(pRes); - A(pRes); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - A(pF32); - A(pF32); - break; - - // Extended Command Information - case OpCode::StartVertexLocation: - A(pI32); - A(pI32); - break; - case OpCode::StartInstanceLocation: - A(pI32); - A(pI32); - break; - - // Inline Ray Query - case OpCode::AllocateRayQuery2: - A(pI32); - A(pI32); - A(pI32); - A(pI32); - break; - - // - case OpCode::ReservedA0: - A(pV); - A(pI32); - break; - case OpCode::ReservedA1: - A(pV); - A(pI32); - break; - case OpCode::ReservedA2: - A(pV); - A(pI32); - break; - case OpCode::ReservedB0: - A(pV); - A(pI32); - break; - case OpCode::ReservedB1: - A(pV); - A(pI32); - break; - case OpCode::ReservedB2: - A(pV); - A(pI32); - break; - - // Shader Execution Reordering - case OpCode::HitObject_MakeMiss: - A(pHit); - A(pI32); - A(pI32); - A(pI32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - A(pF32); - break; - case OpCode::HitObject_MakeNop: - A(pHit); - A(pI32); - break; - - // - case OpCode::ReservedB5: - A(pV); - A(pI32); - break; - case OpCode::ReservedB6: - A(pV); - A(pI32); - break; - case OpCode::ReservedB7: - A(pV); - A(pI32); - break; - case OpCode::ReservedB8: - A(pV); - A(pI32); - break; - case OpCode::ReservedB9: - A(pV); - A(pI32); - break; - case OpCode::ReservedB10: - A(pV); - A(pI32); - break; - case OpCode::ReservedB11: - A(pV); - A(pI32); - break; - case OpCode::ReservedB12: - A(pV); - A(pI32); - break; - case OpCode::ReservedB13: - A(pV); - A(pI32); - break; - case OpCode::ReservedB14: - A(pV); - A(pI32); - break; - case OpCode::ReservedB15: - A(pV); - A(pI32); - break; - case OpCode::ReservedB16: - A(pV); - A(pI32); - break; - case OpCode::ReservedB17: - A(pV); - A(pI32); - break; - case OpCode::ReservedB18: - A(pV); - A(pI32); - break; - case OpCode::ReservedB19: - A(pV); - A(pI32); - break; - case OpCode::ReservedB20: - A(pV); - A(pI32); - break; - case OpCode::ReservedB21: - A(pV); - A(pI32); - break; - case OpCode::ReservedB22: - A(pV); - A(pI32); - break; - case OpCode::ReservedB23: - A(pV); - A(pI32); - break; - case OpCode::ReservedB24: - A(pV); - A(pI32); - break; - case OpCode::ReservedB25: - A(pV); - A(pI32); - break; - case OpCode::ReservedB26: - A(pV); - A(pI32); - break; - case OpCode::ReservedB27: - A(pV); - A(pI32); - break; - case OpCode::ReservedB28: - A(pV); - A(pI32); - break; - case OpCode::ReservedB29: - A(pV); - A(pI32); - break; - case OpCode::ReservedB30: - A(pV); - A(pI32); - break; - case OpCode::ReservedC0: - A(pV); - A(pI32); - break; - case OpCode::ReservedC1: - A(pV); - A(pI32); - break; - case OpCode::ReservedC2: - A(pV); - A(pI32); - break; - case OpCode::ReservedC3: - A(pV); - A(pI32); - break; - case OpCode::ReservedC4: - A(pV); - A(pI32); - break; - case OpCode::ReservedC5: - A(pV); - A(pI32); - break; - case OpCode::ReservedC6: - A(pV); - A(pI32); - break; - case OpCode::ReservedC7: - A(pV); - A(pI32); - break; - case OpCode::ReservedC8: - A(pV); - A(pI32); - break; - case OpCode::ReservedC9: - A(pV); - A(pI32); - break; - case OpCode::RawBufferVectorLoad: - RRT(pETy); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pI32); - break; - case OpCode::RawBufferVectorStore: - A(pV); - A(pI32); - A(pRes); - A(pI32); - A(pI32); - A(pETy); - A(pI32); - break; - // OPCODE-OLOAD-FUNCS:END - default: - DXASSERT(false, "otherwise unhandled case"); - break; - } -#undef RRT -#undef A - - FunctionType *pFT; - DXASSERT(ArgTypes.size() > 1, "otherwise forgot to initialize arguments"); - pFT = FunctionType::get( - ArgTypes[0], ArrayRef(&ArgTypes[1], ArgTypes.size() - 1), false); - - SmallVector FuncStorage; - StringRef FuncName = - ConstructOverloadName(pOverloadType, opCode, FuncStorage); - - // Try to find existing function with the same name in the module. - // This needs to happen after the switch statement that constructs arguments - // and return values to ensure that ResRetType is constructed in the - // RefreshCache case. - if (Function *existF = m_pModule->getFunction(FuncName)) { - if (existF->getFunctionType() != pFT) - return nullptr; - F = existF; - UpdateCache(opClass, pOverloadType, F); - return F; - } - - F = cast(m_pModule->getOrInsertFunction(FuncName, pFT)); - - UpdateCache(opClass, pOverloadType, F); - F->setCallingConv(CallingConv::C); - F->addFnAttr(Attribute::NoUnwind); - if (OpProps.FuncAttr != Attribute::None) - F->addFnAttr(OpProps.FuncAttr); - - return F; -} - -const SmallMapVector & -OP::GetOpFuncList(OpCode opCode) const { - return m_OpCodeClassCache[(unsigned)m_OpCodeProps[(unsigned)opCode] - .opCodeClass] - .pOverloads; -} - -bool OP::IsDxilOpUsed(OpCode opcode) const { - auto &FnList = GetOpFuncList(opcode); - for (auto &it : FnList) { - llvm::Function *F = it.second; - if (!F) { - continue; - } - if (!F->user_empty()) { - return true; - } - } - return false; -} - -void OP::RemoveFunction(Function *F) { - if (OP::IsDxilOpFunc(F)) { - OpCodeClass opClass = m_FunctionToOpClass[F]; - for (auto it : m_OpCodeClassCache[(unsigned)opClass].pOverloads) { - if (it.second == F) { - m_OpCodeClassCache[(unsigned)opClass].pOverloads.erase(it.first); - m_FunctionToOpClass.erase(F); - break; - } - } - } -} - -bool OP::GetOpCodeClass(const Function *F, OP::OpCodeClass &opClass) { - auto iter = m_FunctionToOpClass.find(F); - if (iter == m_FunctionToOpClass.end()) { - // When no user, cannot get opcode. - DXASSERT(F->user_empty() || !IsDxilOpFunc(F), - "dxil function without an opcode class mapping?"); - opClass = OP::OpCodeClass::NumOpClasses; - return false; - } - opClass = iter->second; - return true; -} - -bool OP::UseMinPrecision() { - return m_LowPrecisionMode == DXIL::LowPrecisionMode::UseMinPrecision; -} - -void OP::InitWithMinPrecision(bool bMinPrecision) { - DXIL::LowPrecisionMode mode = - bMinPrecision ? DXIL::LowPrecisionMode::UseMinPrecision - : DXIL::LowPrecisionMode::UseNativeLowPrecision; - DXASSERT((mode == m_LowPrecisionMode || - m_LowPrecisionMode == DXIL::LowPrecisionMode::Undefined), - "LowPrecisionMode should only be set once."); - - if (mode != m_LowPrecisionMode) { - m_LowPrecisionMode = mode; - - // The following FixOverloadNames() and RefreshCache() calls interact with - // the type cache, which can only be correctly constructed once we know - // the min precision mode. That's why they are called here, rather than - // in the constructor. - - // When loading a module into an existing context where types are merged, - // type names may change. When this happens, any intrinsics overloaded on - // UDT types will no longer have matching overload names. - // This causes RefreshCache() to assert. - // This fixes the function names to they match the expected types, - // preventing RefreshCache() from failing due to this issue. - FixOverloadNames(); - - // Try to find existing intrinsic function. - RefreshCache(); - } -} - -uint64_t OP::GetAllocSizeForType(llvm::Type *Ty) { - return m_pModule->getDataLayout().getTypeAllocSize(Ty); -} - -llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { - DXASSERT(F, "not work on nullptr"); - Type *Ty = F->getReturnType(); - FunctionType *FT = F->getFunctionType(); - LLVMContext &Ctx = F->getContext(); - // clang-format off - // Python lines need to be not formatted. - /* hctdb_instrhelp.get_funcs_oload_type()*/ - // clang-format on - switch (opCode) { // return OpCode - // OPCODE-OLOAD-TYPES:BEGIN - case OpCode::TempRegStore: - case OpCode::CallShader: - case OpCode::Pack4x8: - if (FT->getNumParams() <= 2) - return nullptr; - return FT->getParamType(2); - case OpCode::MinPrecXRegStore: - case OpCode::StoreOutput: +llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { + DXASSERT(F, "not work on nullptr"); + Type *Ty = F->getReturnType(); + FunctionType *FT = F->getFunctionType(); + LLVMContext &Ctx = F->getContext(); + // clang-format off + // Python lines need to be not formatted. + /* hctdb_instrhelp.get_funcs_oload_type()*/ + // clang-format on + switch (opCode) { // return OpCode + // OPCODE-OLOAD-TYPES:BEGIN + case OpCode::TempRegStore: + case OpCode::CallShader: + case OpCode::Pack4x8: + if (FT->getNumParams() <= 2) return nullptr; + return FT->getParamType(2); + case OpCode::MinPrecXRegStore: + case OpCode::StoreOutput: case OpCode::BufferStore: case OpCode::StorePatchConstant: case OpCode::RawBufferStore: @@ -5924,8 +2171,7 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::StorePrimitiveOutput: case OpCode::DispatchMesh: case OpCode::RawBufferVectorStore: - if (FT->getNumParams() <= 4) - return nullptr; + if (FT->getNumParams() <= 4) return nullptr; return FT->getParamType(4); case OpCode::IsNaN: case OpCode::IsInf: @@ -5943,21 +2189,18 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::WaveActiveAllEqual: case OpCode::CreateHandleForLib: case OpCode::WaveMatch: - if (FT->getNumParams() <= 1) - return nullptr; + case OpCode::VectorAccumulate: + if (FT->getNumParams() <= 1) return nullptr; return FT->getParamType(1); case OpCode::TextureStore: case OpCode::TextureStoreSample: - if (FT->getNumParams() <= 5) - return nullptr; + if (FT->getNumParams() <= 5) return nullptr; return FT->getParamType(5); case OpCode::TraceRay: - if (FT->getNumParams() <= 15) - return nullptr; + if (FT->getNumParams() <= 15) return nullptr; return FT->getParamType(15); case OpCode::ReportHit: - if (FT->getNumParams() <= 3) - return nullptr; + if (FT->getNumParams() <= 3) return nullptr; return FT->getParamType(3); case OpCode::CreateHandle: case OpCode::BufferUpdateCounter: @@ -6171,10 +2414,22 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::SampleCmpLevel: case OpCode::SampleCmpGrad: case OpCode::SampleCmpBias: - case OpCode::RawBufferVectorLoad: { + case OpCode::RawBufferVectorLoad: + { StructType *ST = cast(Ty); return ST->getElementType(0); } + case OpCode::MatVecMul: + case OpCode::MatVecMulAdd: + if (FT->getNumParams() < 2) + return nullptr; + return llvm::StructType::get(Ctx, {FT->getReturnType(), FT->getParamType(1)}); + + case OpCode::OuterProductAccumulate: + if (FT->getNumParams() < 3) + return nullptr; + return llvm::StructType::get(Ctx, {FT->getParamType(1), FT->getParamType(2)}); + // OPCODE-OLOAD-TYPES:END default: return Ty; diff --git a/lib/DXIL/DxilShaderModel.cpp b/lib/DXIL/DxilShaderModel.cpp index 861e8586e0..c8e08a9231 100644 --- a/lib/DXIL/DxilShaderModel.cpp +++ b/lib/DXIL/DxilShaderModel.cpp @@ -79,114 +79,111 @@ const ShaderModel *ShaderModel::Get(Kind Kind, unsigned Major, unsigned Minor) { /* hctdb_instrhelp.get_shader_model_get()*/ // VALRULE-TEXT:BEGIN const static std::pair hashToIdxMap[] = { - {1024, 0}, // ps_4_0 - {1025, 1}, // ps_4_1 - {1280, 2}, // ps_5_0 - {1281, 3}, // ps_5_1 - {1536, 4}, // ps_6_0 - {1537, 5}, // ps_6_1 - {1538, 6}, // ps_6_2 - {1539, 7}, // ps_6_3 - {1540, 8}, // ps_6_4 - {1541, 9}, // ps_6_5 - {1542, 10}, // ps_6_6 - {1543, 11}, // ps_6_7 - {1544, 12}, // ps_6_8 - {1545, 13}, // ps_6_9 - {66560, 14}, // vs_4_0 - {66561, 15}, // vs_4_1 - {66816, 16}, // vs_5_0 - {66817, 17}, // vs_5_1 - {67072, 18}, // vs_6_0 - {67073, 19}, // vs_6_1 - {67074, 20}, // vs_6_2 - {67075, 21}, // vs_6_3 - {67076, 22}, // vs_6_4 - {67077, 23}, // vs_6_5 - {67078, 24}, // vs_6_6 - {67079, 25}, // vs_6_7 - {67080, 26}, // vs_6_8 - {67081, 27}, // vs_6_9 - {132096, 28}, // gs_4_0 - {132097, 29}, // gs_4_1 - {132352, 30}, // gs_5_0 - {132353, 31}, // gs_5_1 - {132608, 32}, // gs_6_0 - {132609, 33}, // gs_6_1 - {132610, 34}, // gs_6_2 - {132611, 35}, // gs_6_3 - {132612, 36}, // gs_6_4 - {132613, 37}, // gs_6_5 - {132614, 38}, // gs_6_6 - {132615, 39}, // gs_6_7 - {132616, 40}, // gs_6_8 - {132617, 41}, // gs_6_9 - {197888, 42}, // hs_5_0 - {197889, 43}, // hs_5_1 - {198144, 44}, // hs_6_0 - {198145, 45}, // hs_6_1 - {198146, 46}, // hs_6_2 - {198147, 47}, // hs_6_3 - {198148, 48}, // hs_6_4 - {198149, 49}, // hs_6_5 - {198150, 50}, // hs_6_6 - {198151, 51}, // hs_6_7 - {198152, 52}, // hs_6_8 - {198153, 53}, // hs_6_9 - {263424, 54}, // ds_5_0 - {263425, 55}, // ds_5_1 - {263680, 56}, // ds_6_0 - {263681, 57}, // ds_6_1 - {263682, 58}, // ds_6_2 - {263683, 59}, // ds_6_3 - {263684, 60}, // ds_6_4 - {263685, 61}, // ds_6_5 - {263686, 62}, // ds_6_6 - {263687, 63}, // ds_6_7 - {263688, 64}, // ds_6_8 - {263689, 65}, // ds_6_9 - {328704, 66}, // cs_4_0 - {328705, 67}, // cs_4_1 - {328960, 68}, // cs_5_0 - {328961, 69}, // cs_5_1 - {329216, 70}, // cs_6_0 - {329217, 71}, // cs_6_1 - {329218, 72}, // cs_6_2 - {329219, 73}, // cs_6_3 - {329220, 74}, // cs_6_4 - {329221, 75}, // cs_6_5 - {329222, 76}, // cs_6_6 - {329223, 77}, // cs_6_7 - {329224, 78}, // cs_6_8 - {329225, 79}, // cs_6_9 - {394753, 80}, // lib_6_1 - {394754, 81}, // lib_6_2 - {394755, 82}, // lib_6_3 - {394756, 83}, // lib_6_4 - {394757, 84}, // lib_6_5 - {394758, 85}, // lib_6_6 - {394759, 86}, // lib_6_7 - {394760, 87}, // lib_6_8 - {394761, 88}, // lib_6_9 - // lib_6_x is for offline linking only, and relaxes restrictions - {394767, 89}, // lib_6_x - {853509, 90}, // ms_6_5 - {853510, 91}, // ms_6_6 - {853511, 92}, // ms_6_7 - {853512, 93}, // ms_6_8 - {853513, 94}, // ms_6_9 - {919045, 95}, // as_6_5 - {919046, 96}, // as_6_6 - {919047, 97}, // as_6_7 - {919048, 98}, // as_6_8 - {919049, 99}, // as_6_9 + {1024,0}, //ps_4_0 + {1025,1}, //ps_4_1 + {1280,2}, //ps_5_0 + {1281,3}, //ps_5_1 + {1536,4}, //ps_6_0 + {1537,5}, //ps_6_1 + {1538,6}, //ps_6_2 + {1539,7}, //ps_6_3 + {1540,8}, //ps_6_4 + {1541,9}, //ps_6_5 + {1542,10}, //ps_6_6 + {1543,11}, //ps_6_7 + {1544,12}, //ps_6_8 + {1545,13}, //ps_6_9 + {66560,14}, //vs_4_0 + {66561,15}, //vs_4_1 + {66816,16}, //vs_5_0 + {66817,17}, //vs_5_1 + {67072,18}, //vs_6_0 + {67073,19}, //vs_6_1 + {67074,20}, //vs_6_2 + {67075,21}, //vs_6_3 + {67076,22}, //vs_6_4 + {67077,23}, //vs_6_5 + {67078,24}, //vs_6_6 + {67079,25}, //vs_6_7 + {67080,26}, //vs_6_8 + {67081,27}, //vs_6_9 + {132096,28}, //gs_4_0 + {132097,29}, //gs_4_1 + {132352,30}, //gs_5_0 + {132353,31}, //gs_5_1 + {132608,32}, //gs_6_0 + {132609,33}, //gs_6_1 + {132610,34}, //gs_6_2 + {132611,35}, //gs_6_3 + {132612,36}, //gs_6_4 + {132613,37}, //gs_6_5 + {132614,38}, //gs_6_6 + {132615,39}, //gs_6_7 + {132616,40}, //gs_6_8 + {132617,41}, //gs_6_9 + {197888,42}, //hs_5_0 + {197889,43}, //hs_5_1 + {198144,44}, //hs_6_0 + {198145,45}, //hs_6_1 + {198146,46}, //hs_6_2 + {198147,47}, //hs_6_3 + {198148,48}, //hs_6_4 + {198149,49}, //hs_6_5 + {198150,50}, //hs_6_6 + {198151,51}, //hs_6_7 + {198152,52}, //hs_6_8 + {198153,53}, //hs_6_9 + {263424,54}, //ds_5_0 + {263425,55}, //ds_5_1 + {263680,56}, //ds_6_0 + {263681,57}, //ds_6_1 + {263682,58}, //ds_6_2 + {263683,59}, //ds_6_3 + {263684,60}, //ds_6_4 + {263685,61}, //ds_6_5 + {263686,62}, //ds_6_6 + {263687,63}, //ds_6_7 + {263688,64}, //ds_6_8 + {263689,65}, //ds_6_9 + {328704,66}, //cs_4_0 + {328705,67}, //cs_4_1 + {328960,68}, //cs_5_0 + {328961,69}, //cs_5_1 + {329216,70}, //cs_6_0 + {329217,71}, //cs_6_1 + {329218,72}, //cs_6_2 + {329219,73}, //cs_6_3 + {329220,74}, //cs_6_4 + {329221,75}, //cs_6_5 + {329222,76}, //cs_6_6 + {329223,77}, //cs_6_7 + {329224,78}, //cs_6_8 + {329225,79}, //cs_6_9 + {394753,80}, //lib_6_1 + {394754,81}, //lib_6_2 + {394755,82}, //lib_6_3 + {394756,83}, //lib_6_4 + {394757,84}, //lib_6_5 + {394758,85}, //lib_6_6 + {394759,86}, //lib_6_7 + {394760,87}, //lib_6_8 + {394761,88}, //lib_6_9 + // lib_6_x is for offline linking only, and relaxes restrictions + {394767,89},//lib_6_x + {853509,90}, //ms_6_5 + {853510,91}, //ms_6_6 + {853511,92}, //ms_6_7 + {853512,93}, //ms_6_8 + {853513,94}, //ms_6_9 + {919045,95}, //as_6_5 + {919046,96}, //as_6_6 + {919047,97}, //as_6_7 + {919048,98}, //as_6_8 + {919049,99}, //as_6_9 }; unsigned hash = (unsigned)Kind << 16 | Major << 8 | Minor; - auto pred = [](const std::pair &elem, unsigned val) { - return elem.first < val; - }; - auto it = std::lower_bound(std::begin(hashToIdxMap), std::end(hashToIdxMap), - hash, pred); + auto pred = [](const std::pair& elem, unsigned val){ return elem.first < val;}; + auto it = std::lower_bound(std::begin(hashToIdxMap), std::end(hashToIdxMap), hash, pred); if (it == std::end(hashToIdxMap) || it->first != hash) return GetInvalid(); return &ms_ShaderModels[it->second]; @@ -294,50 +291,50 @@ const ShaderModel *ShaderModel::GetByName(llvm::StringRef Name) { if (Major == 6) { Minor = 2; break; - } else - return GetInvalid(); + } + else return GetInvalid(); case '3': if (Major == 6) { Minor = 3; break; - } else - return GetInvalid(); + } + else return GetInvalid(); case '4': if (Major == 6) { Minor = 4; break; - } else - return GetInvalid(); + } + else return GetInvalid(); case '5': if (Major == 6) { Minor = 5; break; - } else - return GetInvalid(); + } + else return GetInvalid(); case '6': if (Major == 6) { Minor = 6; break; - } else - return GetInvalid(); + } + else return GetInvalid(); case '7': if (Major == 6) { Minor = 7; break; - } else - return GetInvalid(); + } + else return GetInvalid(); case '8': if (Major == 6) { Minor = 8; break; - } else - return GetInvalid(); + } + else return GetInvalid(); case '9': if (Major == 6) { Minor = 9; break; - } else - return GetInvalid(); + } + else return GetInvalid(); // VALRULE-TEXT:END case 'x': if (kind == Kind::Library && Major == 6) { @@ -659,8 +656,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Library, 6, 8, "lib_6_8", 32, 32, true, true, UINT_MAX), SM(Kind::Library, 6, 9, "lib_6_9", 32, 32, true, true, UINT_MAX), // lib_6_x is for offline linking only, and relaxes restrictions - SM(Kind::Library, 6, kOfflineMinor, "lib_6_x", 32, 32, true, true, - UINT_MAX), + SM(Kind::Library, 6, kOfflineMinor, "lib_6_x", 32, 32, true, true, UINT_MAX), SM(Kind::Mesh, 6, 5, "ms_6_5", 0, 0, true, true, UINT_MAX), SM(Kind::Mesh, 6, 6, "ms_6_6", 0, 0, true, true, UINT_MAX), SM(Kind::Mesh, 6, 7, "ms_6_7", 0, 0, true, true, UINT_MAX), @@ -672,7 +668,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Amplification, 6, 8, "as_6_8", 0, 0, true, true, UINT_MAX), SM(Kind::Amplification, 6, 9, "as_6_9", 0, 0, true, true, UINT_MAX), // Values before Invalid must remain sorted by Kind, then Major, then Minor. - SM(Kind::Invalid, 0, 0, "invalid", 0, 0, false, false, 0), + SM(Kind::Invalid, 0, 0, "invalid", 0, 0, false, false, 0), // VALRULE-TEXT:END }; diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index 362a647e4f..bf83ffd916 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -6300,6 +6300,150 @@ Value *TranslateSelect(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, } return Builder.CreateSelect(cond, t, f); } + +Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, + HLOperationLowerHelper &helper, + HLObjectOperationLowerHelper *pObjHelper, + bool &Translated) { + + hlsl::OP *hlslOP = &helper.hlslOP; + IRBuilder<> Builder(CI); + + Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); + // input + Value *inputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulInputVectorIdx); + Value *isInputSigned = Builder.getInt1(0); + Value *inputInterpretation = + CI->getArgOperand(HLOperandIndex::kMatVecMulInputInterpretationIdx); + // matrix + Value *matrixBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixBufferIdx); + Value *matrixOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixOffsetIdx); + Value *matrixInterpretation = + CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixInterpretationIdx); + Value *matrixM = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixMIdx); + Value *matrixK = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixKIdx); + Value *matrixLayout = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixLayoutIdx); + Value *matrixTranspose = + CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixTransposeIdx); + Value *matrixStride = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixStrideIdx); + // output + Value *isOutputSigned = Builder.getInt1(0); + + Function *dxilFunc = + hlslOP->GetOpFunc(opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx) + ->getType() + ->getPointerElementType(), inputVector->getType()}); + + Value *NewCI = Builder.CreateCall( + dxilFunc, + {opArg, inputVector, isInputSigned, inputInterpretation, matrixBuffer, + matrixOffset, matrixInterpretation, matrixM, matrixK, matrixLayout, + matrixTranspose, matrixStride, isOutputSigned}); + + Value *OutParam = CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx); + Builder.CreateStore(NewCI, OutParam); + + return nullptr; +} + +Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, + HLOperationLowerHelper &helper, + HLObjectOperationLowerHelper *pObjHelper, + bool &Translated) { + + hlsl::OP *hlslOP = &helper.hlslOP; + IRBuilder<> Builder(CI); + + Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); + // input vector + Value *inputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputVectorIdx); + Value *isInputSigned = Builder.getInt1(0); + Value *inputInterpretation = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputInterpretationIdx); + // matrix + Value *matrixBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixBufferIdx); + Value *matrixOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixOffsetIdx); + Value *matrixInterpretation = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixInterpretationIdx); + Value *matrixM = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixMIdx); + Value *matrixK = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixKIdx); + Value *matrixLayout = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixLayoutIdx); + Value *matrixTranspose = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixTransposeIdx); + Value *matrixStride = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixStrideIdx); + // bias + Value *biasBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasBufferIdx); + Value *biasOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasOffsetIdx); + Value *biasInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasInterpretationIdx); + // output + Value *isOutputSigned = Builder.getInt1(0); + + Function *dxilFunc = + hlslOP->GetOpFunc(opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx) + ->getType() + ->getPointerElementType(), inputVector->getType()}); + + Value *NewCI = Builder.CreateCall( + dxilFunc, {opArg, inputVector, isInputSigned, inputInterpretation, + matrixBuffer, matrixOffset, matrixInterpretation, matrixM, + matrixK, matrixLayout, matrixTranspose, matrixStride, + biasBuffer, biasOffset, biasInterpretation, isOutputSigned}); + + Value *OutParam = CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx); + Builder.CreateStore(NewCI, OutParam); + + return nullptr; +} + +Value *TranslateOuterProductAccumulate(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, + HLOperationLowerHelper &helper, + HLObjectOperationLowerHelper *pObjHelper, + bool &Translated) { + + hlsl::OP *hlslOP = &helper.hlslOP; + IRBuilder<> Builder(CI); + + Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); + // input + Value *inputVector1 = CI->getArgOperand(HLOperandIndex::kOuterProdAccInputVec1Idx); + Value *inputVector2 = CI->getArgOperand(HLOperandIndex::kOuterProdAccInputVec2Idx); + // matrix + Value *matrixBuffer = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixIdx); + Value *matrixOffset = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixOffsetIdx); + Value *matrixInterpretation = + CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixInterpretationIdx); + Value *matrixLayout = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixLayoutIdx); + Value *matrixStride = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixStrideIdx); + + Function *dxilFunc = + hlslOP->GetOpFunc(opcode, {inputVector1->getType(), inputVector2->getType()}); + + return Builder.CreateCall( + dxilFunc, {opArg, inputVector1, inputVector2, matrixBuffer, matrixOffset, + matrixInterpretation, matrixLayout, matrixStride}); +} + +Value *TranslateVectorAccumulate(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, + HLOperationLowerHelper &helper, + HLObjectOperationLowerHelper *pObjHelper, + bool &Translated) { + + hlsl::OP *hlslOP = &helper.hlslOP; + IRBuilder<> Builder(CI); + + Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); + // input + Value *inputVector = CI->getArgOperand(HLOperandIndex::kVectorAccInputVecIdx); + // matrix + Value *matrixBuffer = CI->getArgOperand(HLOperandIndex::kVectorAccMatrixIdx); + Value *matrixOffset = CI->getArgOperand(HLOperandIndex::kVectorAccMatrixOffsetIdx); + + Function *dxilFunc = + hlslOP->GetOpFunc(opcode, {inputVector->getType()}); + + return Builder.CreateCall(dxilFunc, + {opArg, inputVector, matrixBuffer, matrixOffset}); +} } // namespace // Lower table. @@ -6950,6 +7094,15 @@ IntrinsicLower gLowerTable[] = { {IntrinsicOp::IOP_DxMaybeReorderThread, TranslateMaybeReorderThread, DXIL::OpCode::NumOpCodes_Dxil_1_8}, // FIXME: Just a placeholder Dxil // opcode + {IntrinsicOp::IOP___builtin_MatVecMul, TranslateMatVecMul, + DXIL::OpCode::MatVecMul}, + {IntrinsicOp::IOP___builtin_MatVecMulAdd, TranslateMatVecMulAdd, + DXIL::OpCode::MatVecMulAdd}, + {IntrinsicOp::IOP___builtin_OuterProductAccumulate, + TranslateOuterProductAccumulate, DXIL::OpCode::OuterProductAccumulate}, + {IntrinsicOp::IOP___builtin_VectorAccumulate, TranslateVectorAccumulate, + DXIL::OpCode::VectorAccumulate}, + }; } // namespace static_assert( diff --git a/utils/hct/gen_intrin_main.txt b/utils/hct/gen_intrin_main.txt index 0ca5b0716b..3399db2d47 100644 --- a/utils/hct/gen_intrin_main.txt +++ b/utils/hct/gen_intrin_main.txt @@ -380,6 +380,14 @@ void [[]] Barrier(in NodeRecordOrUAV o, in uint SemanticFlags); uint [[]] GetRemainingRecursionLevels(); +void [[]] __builtin_MatVecMul(out numeric output_vector, in numeric input_vector, in uint input_interpretation, in ByteAddressBuffer input_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride); + +void [[]] __builtin_MatVecMulAdd(out numeric output_vector, in numeric input_vector, in uint input_interpretation, in ByteAddressBuffer input_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride, in ByteAddressBuffer bias_vector, in uint bias_offset, in uint bias_interpretation); + +void [[]] __builtin_OuterProductAccumulate(in numeric input_vector1, in numeric input_vector2, in RWByteAddressBuffer acc_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint matrix_layout, in uint matrix_stride); + +void [[]] __builtin_VectorAccumulate(in numeric input_vector, in RWByteAddressBuffer acc_matrix, in uint matrix_offset); + } namespace diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 8f6887b5d4..8fa8f9baff 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -5848,9 +5848,97 @@ def UFI(name, **mappings): ) next_op_idx += 1 - # End of DXIL 1.9 opcodes. + self.add_dxil_op( + "MatVecMul", + next_op_idx, + "MatVecMul", + "Matrix-Vector Multiply", + " Date: Wed, 26 Mar 2025 16:23:28 -0700 Subject: [PATCH 02/93] Add is signed parameters to the builtins --- include/dxc/HLSL/HLOperations.h | 50 ++++++++++++++++++--------------- lib/HLSL/HLOperationLower.cpp | 8 +++--- utils/hct/gen_intrin_main.txt | 4 +-- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/include/dxc/HLSL/HLOperations.h b/include/dxc/HLSL/HLOperations.h index b4838b6046..38a62f1a92 100644 --- a/include/dxc/HLSL/HLOperations.h +++ b/include/dxc/HLSL/HLOperations.h @@ -437,33 +437,37 @@ const unsigned kAnnotateNodeRecordHandleNodeRecordPropIdx = 2; // MatVecMul const unsigned kMatVecMulOutputVectorIdx = 1; -const unsigned kMatVecMulInputVectorIdx = 2; -const unsigned kMatVecMulInputInterpretationIdx = 3; -const unsigned kMatVecMulMatrixBufferIdx = 4; -const unsigned kMatVecMulMatrixOffsetIdx = 5; -const unsigned kMatVecMulMatrixInterpretationIdx = 6; -const unsigned kMatVecMulMatrixMIdx = 7; -const unsigned kMatVecMulMatrixKIdx = 8; -const unsigned kMatVecMulMatrixLayoutIdx = 9; -const unsigned kMatVecMulMatrixTransposeIdx = 10; -const unsigned kMatVecMulMatrixStrideIdx = 11; +const unsigned kMatVecMulIsOutputUnsignedIdx = 2; +const unsigned kMatVecMulInputVectorIdx = 3; +const unsigned kMatVecMulIsInputUnsignedIdx = 4; +const unsigned kMatVecMulInputInterpretationIdx = 5; +const unsigned kMatVecMulMatrixBufferIdx = 6; +const unsigned kMatVecMulMatrixOffsetIdx = 7; +const unsigned kMatVecMulMatrixInterpretationIdx = 8; +const unsigned kMatVecMulMatrixMIdx = 9; +const unsigned kMatVecMulMatrixKIdx = 10; +const unsigned kMatVecMulMatrixLayoutIdx = 11; +const unsigned kMatVecMulMatrixTransposeIdx = 12; +const unsigned kMatVecMulMatrixStrideIdx = 13; // MatVecMulAdd const unsigned kMatVecMulAddOutputVectorIdx = 1; -const unsigned kMatVecMulAddInputVectorIdx = 2; -const unsigned kMatVecMulAddInputInterpretationIdx = 3; -const unsigned kMatVecMulAddMatrixBufferIdx = 4; -const unsigned kMatVecMulAddMatrixOffsetIdx = 5; -const unsigned kMatVecMulAddMatrixInterpretationIdx = 6; -const unsigned kMatVecMulAddMatrixMIdx = 7; -const unsigned kMatVecMulAddMatrixKIdx = 8; -const unsigned kMatVecMulAddMatrixLayoutIdx = 9; -const unsigned kMatVecMulAddMatrixTransposeIdx = 10; -const unsigned kMatVecMulAddMatrixStrideIdx = 11; -const unsigned kMatVecMulAddBiasBufferIdx = 12; -const unsigned kMatVecMulAddBiasOffsetIdx = 13; -const unsigned kMatVecMulAddBiasInterpretationIdx = 14; +const unsigned kMatVecMulAddIsOutputUnsignedIdx = 2; +const unsigned kMatVecMulAddInputVectorIdx = 3; +const unsigned kMatVecMulAddIsInputUnsignedIdx = 4; +const unsigned kMatVecMulAddInputInterpretationIdx = 5; +const unsigned kMatVecMulAddMatrixBufferIdx = 6; +const unsigned kMatVecMulAddMatrixOffsetIdx = 7; +const unsigned kMatVecMulAddMatrixInterpretationIdx = 8; +const unsigned kMatVecMulAddMatrixMIdx = 9; +const unsigned kMatVecMulAddMatrixKIdx = 10; +const unsigned kMatVecMulAddMatrixLayoutIdx = 11; +const unsigned kMatVecMulAddMatrixTransposeIdx = 12; +const unsigned kMatVecMulAddMatrixStrideIdx = 13; +const unsigned kMatVecMulAddBiasBufferIdx = 14; +const unsigned kMatVecMulAddBiasOffsetIdx = 15; +const unsigned kMatVecMulAddBiasInterpretationIdx = 16; // OuterProductAccumulate diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index bf83ffd916..8add2ea4d2 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -6312,7 +6312,7 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); // input Value *inputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulInputVectorIdx); - Value *isInputSigned = Builder.getInt1(0); + Value *isInputSigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsInputUnsignedIdx); Value *inputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulInputInterpretationIdx); // matrix @@ -6327,7 +6327,7 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixTransposeIdx); Value *matrixStride = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixStrideIdx); // output - Value *isOutputSigned = Builder.getInt1(0); + Value *isOutputSigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsOutputUnsignedIdx); Function *dxilFunc = hlslOP->GetOpFunc(opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx) @@ -6357,7 +6357,7 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); // input vector Value *inputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputVectorIdx); - Value *isInputSigned = Builder.getInt1(0); + Value *isInputSigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsInputUnsignedIdx); Value *inputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputInterpretationIdx); // matrix @@ -6376,7 +6376,7 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, Value *biasOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasOffsetIdx); Value *biasInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasInterpretationIdx); // output - Value *isOutputSigned = Builder.getInt1(0); + Value *isOutputSigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsOutputUnsignedIdx); Function *dxilFunc = hlslOP->GetOpFunc(opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx) diff --git a/utils/hct/gen_intrin_main.txt b/utils/hct/gen_intrin_main.txt index 3399db2d47..4fd3b1b916 100644 --- a/utils/hct/gen_intrin_main.txt +++ b/utils/hct/gen_intrin_main.txt @@ -380,9 +380,9 @@ void [[]] Barrier(in NodeRecordOrUAV o, in uint SemanticFlags); uint [[]] GetRemainingRecursionLevels(); -void [[]] __builtin_MatVecMul(out numeric output_vector, in numeric input_vector, in uint input_interpretation, in ByteAddressBuffer input_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride); +void [[]] __builtin_MatVecMul(out numeric output_vector, in bool isOutputSigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer input_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride); -void [[]] __builtin_MatVecMulAdd(out numeric output_vector, in numeric input_vector, in uint input_interpretation, in ByteAddressBuffer input_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride, in ByteAddressBuffer bias_vector, in uint bias_offset, in uint bias_interpretation); +void [[]] __builtin_MatVecMulAdd(out numeric output_vector, in bool isOutputUnsigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer input_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride, in ByteAddressBuffer bias_vector, in uint bias_offset, in uint bias_interpretation); void [[]] __builtin_OuterProductAccumulate(in numeric input_vector1, in numeric input_vector2, in RWByteAddressBuffer acc_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint matrix_layout, in uint matrix_stride); From a6863d4f886d0bd68dcf08799a09888e35801543 Mon Sep 17 00:00:00 2001 From: anupamac Date: Tue, 1 Apr 2025 12:01:39 -0700 Subject: [PATCH 03/93] Change parameter names for better readability --- utils/hct/gen_intrin_main.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/hct/gen_intrin_main.txt b/utils/hct/gen_intrin_main.txt index 4fd3b1b916..aee831189b 100644 --- a/utils/hct/gen_intrin_main.txt +++ b/utils/hct/gen_intrin_main.txt @@ -380,13 +380,13 @@ void [[]] Barrier(in NodeRecordOrUAV o, in uint SemanticFlags); uint [[]] GetRemainingRecursionLevels(); -void [[]] __builtin_MatVecMul(out numeric output_vector, in bool isOutputSigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer input_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride); +void [[]] __builtin_MatVecMul(out numeric output_vector, in bool isOutputSigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer matrix_buffer, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride); -void [[]] __builtin_MatVecMulAdd(out numeric output_vector, in bool isOutputUnsigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer input_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride, in ByteAddressBuffer bias_vector, in uint bias_offset, in uint bias_interpretation); +void [[]] __builtin_MatVecMulAdd(out numeric output_vector, in bool isOutputUnsigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer matrix_buffer, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride, in ByteAddressBuffer bias_vector, in uint bias_offset, in uint bias_interpretation); -void [[]] __builtin_OuterProductAccumulate(in numeric input_vector1, in numeric input_vector2, in RWByteAddressBuffer acc_matrix, in uint matrix_offset, in uint matrix_interpretation, in uint matrix_layout, in uint matrix_stride); +void [[]] __builtin_OuterProductAccumulate(in numeric input_vector1, in numeric input_vector2, in RWByteAddressBuffer matrix_buffer, in uint matrix_offset, in uint matrix_interpretation, in uint matrix_layout, in uint matrix_stride); -void [[]] __builtin_VectorAccumulate(in numeric input_vector, in RWByteAddressBuffer acc_matrix, in uint matrix_offset); +void [[]] __builtin_VectorAccumulate(in numeric input_vector, in RWByteAddressBuffer matrix_buffer, in uint matrix_offset); } namespace From 49bc4f09c2d63c3d75c11ab827f9f562d087069c Mon Sep 17 00:00:00 2001 From: anupamac Date: Tue, 1 Apr 2025 12:19:21 -0700 Subject: [PATCH 04/93] Keeping parameter names accurate --- lib/HLSL/HLOperationLower.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index 8add2ea4d2..82a06cd047 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -6312,7 +6312,7 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); // input Value *inputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulInputVectorIdx); - Value *isInputSigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsInputUnsignedIdx); + Value *isInputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsInputUnsignedIdx); Value *inputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulInputInterpretationIdx); // matrix @@ -6327,7 +6327,7 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixTransposeIdx); Value *matrixStride = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixStrideIdx); // output - Value *isOutputSigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsOutputUnsignedIdx); + Value *isOutputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsOutputUnsignedIdx); Function *dxilFunc = hlslOP->GetOpFunc(opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx) @@ -6336,9 +6336,9 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, Value *NewCI = Builder.CreateCall( dxilFunc, - {opArg, inputVector, isInputSigned, inputInterpretation, matrixBuffer, + {opArg, inputVector, isInputUnsigned, inputInterpretation, matrixBuffer, matrixOffset, matrixInterpretation, matrixM, matrixK, matrixLayout, - matrixTranspose, matrixStride, isOutputSigned}); + matrixTranspose, matrixStride, isOutputUnsigned}); Value *OutParam = CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx); Builder.CreateStore(NewCI, OutParam); @@ -6357,7 +6357,7 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); // input vector Value *inputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputVectorIdx); - Value *isInputSigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsInputUnsignedIdx); + Value *isInputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsInputUnsignedIdx); Value *inputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputInterpretationIdx); // matrix @@ -6376,7 +6376,7 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, Value *biasOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasOffsetIdx); Value *biasInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasInterpretationIdx); // output - Value *isOutputSigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsOutputUnsignedIdx); + Value *isOutputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsOutputUnsignedIdx); Function *dxilFunc = hlslOP->GetOpFunc(opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx) @@ -6384,10 +6384,10 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, ->getPointerElementType(), inputVector->getType()}); Value *NewCI = Builder.CreateCall( - dxilFunc, {opArg, inputVector, isInputSigned, inputInterpretation, + dxilFunc, {opArg, inputVector, isInputUnsigned, inputInterpretation, matrixBuffer, matrixOffset, matrixInterpretation, matrixM, matrixK, matrixLayout, matrixTranspose, matrixStride, - biasBuffer, biasOffset, biasInterpretation, isOutputSigned}); + biasBuffer, biasOffset, biasInterpretation, isOutputUnsigned}); Value *OutParam = CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx); Builder.CreateStore(NewCI, OutParam); From 564689a26724b50e032c9ecd61ca658b718104d4 Mon Sep 17 00:00:00 2001 From: anupamac Date: Tue, 1 Apr 2025 18:28:23 -0700 Subject: [PATCH 05/93] After clang-format --- include/dxc/DXIL/DxilConstants.h | 620 +-- include/dxc/DXIL/DxilInstructions.h | 2166 +++++++--- include/dxc/HLSL/HLOperations.h | 2 - lib/DXIL/DxilOperations.cpp | 6138 ++++++++++++++++++++++----- lib/DXIL/DxilShaderModel.cpp | 246 +- lib/HLSL/HLOperationLower.cpp | 137 +- 6 files changed, 7080 insertions(+), 2229 deletions(-) diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index 4524cf7c80..182ecbaaf3 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -291,28 +291,30 @@ enum class SemanticKind : unsigned { /* hctdb_instrhelp.get_enum_decl("SigPointKind", hide_val=True, sort_val=False)*/ // clang-format on // SigPointKind-ENUM:BEGIN -// Signature Point is more specific than shader stage or signature as it is unique in both stage and item dimensionality or frequency. +// Signature Point is more specific than shader stage or signature as it is +// unique in both stage and item dimensionality or frequency. enum class SigPointKind : unsigned { - VSIn, // Ordinary Vertex Shader input from Input Assembler - VSOut, // Ordinary Vertex Shader output that may feed Rasterizer - PCIn, // Patch Constant function non-patch inputs - HSIn, // Hull Shader function non-patch inputs - HSCPIn, // Hull Shader patch inputs - Control Points + VSIn, // Ordinary Vertex Shader input from Input Assembler + VSOut, // Ordinary Vertex Shader output that may feed Rasterizer + PCIn, // Patch Constant function non-patch inputs + HSIn, // Hull Shader function non-patch inputs + HSCPIn, // Hull Shader patch inputs - Control Points HSCPOut, // Hull Shader function output - Control Point - PCOut, // Patch Constant function output - Patch Constant data passed to Domain Shader + PCOut, // Patch Constant function output - Patch Constant data passed to + // Domain Shader DSIn, // Domain Shader regular input - Patch Constant data plus system values DSCPIn, // Domain Shader patch input - Control Points - DSOut, // Domain Shader output - vertex data that may feed Rasterizer - GSVIn, // Geometry Shader vertex input - qualified with primitive type - GSIn, // Geometry Shader non-vertex inputs (system values) - GSOut, // Geometry Shader output - vertex data that may feed Rasterizer - PSIn, // Pixel Shader input - PSOut, // Pixel Shader output - CSIn, // Compute Shader input - MSIn, // Mesh Shader input - MSOut, // Mesh Shader vertices output + DSOut, // Domain Shader output - vertex data that may feed Rasterizer + GSVIn, // Geometry Shader vertex input - qualified with primitive type + GSIn, // Geometry Shader non-vertex inputs (system values) + GSOut, // Geometry Shader output - vertex data that may feed Rasterizer + PSIn, // Pixel Shader input + PSOut, // Pixel Shader output + CSIn, // Compute Shader input + MSIn, // Mesh Shader input + MSOut, // Mesh Shader vertices output MSPOut, // Mesh Shader primitives output - ASIn, // Amplification Shader input + ASIn, // Amplification Shader input Invalid, }; // SigPointKind-ENUM:END @@ -324,16 +326,16 @@ enum class SigPointKind : unsigned { // SemanticInterpretationKind-ENUM:BEGIN // Defines how a semantic is interpreted at a particular SignaturePoint enum class SemanticInterpretationKind : unsigned { - NA, // Not Available - SV, // Normal System Value - SGV, // System Generated Value (sorted last) - Arb, // Treated as Arbitrary - NotInSig, // Not included in signature (intrinsic access) - NotPacked, // Included in signature, but does not contribute to packing - Target, // Special handling for SV_Target + NA, // Not Available + SV, // Normal System Value + SGV, // System Generated Value (sorted last) + Arb, // Treated as Arbitrary + NotInSig, // Not included in signature (intrinsic access) + NotPacked, // Included in signature, but does not contribute to packing + Target, // Special handling for SV_Target TessFactor, // Special handling for tessellation factors - Shadow, // Shadow element must be added to a signature for compatibility - ClipCull, // Special packing rules for SV_ClipDistance or SV_CullDistance + Shadow, // Shadow element must be added to a signature for compatibility + ClipCull, // Special packing rules for SV_ClipDistance or SV_CullDistance Invalid, }; // SemanticInterpretationKind-ENUM:END @@ -345,11 +347,11 @@ enum class SemanticInterpretationKind : unsigned { // PackingKind-ENUM:BEGIN // Kind of signature point enum class PackingKind : unsigned { - None, // No packing should be performed + None, // No packing should be performed InputAssembler, // Vertex Shader input from Input Assembler - Vertex, // Vertex that may feed the Rasterizer - PatchConstant, // Patch constant signature - Target, // Render Target (Pixel Shader Output) + Vertex, // Vertex that may feed the Rasterizer + PatchConstant, // Patch constant signature + Target, // Render Target (Pixel Shader Output) Invalid, }; // PackingKind-ENUM:END @@ -361,9 +363,9 @@ enum class PackingKind : unsigned { // FPDenormMode-ENUM:BEGIN // float32 denorm behavior enum class Float32DenormMode : unsigned { - Any = 0, // Undefined behavior for denormal numbers + Any = 0, // Undefined behavior for denormal numbers Preserve = 1, // Preserve both input and output - FTZ = 2, // Preserve denormal inputs. Flush denorm outputs + FTZ = 2, // Preserve denormal inputs. Flush denorm outputs Reserve3 = 3, // Reserved Value. Not used for now Reserve4 = 4, // Reserved Value. Not used for now Reserve5 = 5, // Reserved Value. Not used for now @@ -484,29 +486,30 @@ inline bool IsFeedbackTexture(DXIL::ResourceKind ResourceKind) { // OPCODE-ENUM:BEGIN // Enumeration for operations specified by DXIL enum class OpCode : unsigned { - // - MatVecMul = 305, // Matrix-Vector Multiply - MatVecMulAdd = 306, // Matrix-Vector Multiply Add + // + MatVecMul = 305, // Matrix-Vector Multiply + MatVecMulAdd = 306, // Matrix-Vector Multiply Add OuterProductAccumulate = 307, // Outer Product Accumulate - RawBufferVectorLoad = 303, // reads from a raw buffer and structured buffer - RawBufferVectorStore = 304, // writes to a RWByteAddressBuffer or RWStructuredBuffer - Reserved0 = 226, // Reserved - Reserved1 = 227, // Reserved - Reserved10 = 236, // Reserved - Reserved11 = 237, // Reserved - Reserved2 = 228, // Reserved - Reserved3 = 229, // Reserved - Reserved4 = 230, // Reserved - Reserved5 = 231, // Reserved - Reserved6 = 232, // Reserved - Reserved7 = 233, // Reserved - Reserved8 = 234, // Reserved - Reserved9 = 235, // Reserved - ReservedA0 = 259, // reserved - ReservedA1 = 260, // reserved - ReservedA2 = 261, // reserved - ReservedB0 = 262, // reserved - ReservedB1 = 263, // reserved + RawBufferVectorLoad = 303, // reads from a raw buffer and structured buffer + RawBufferVectorStore = + 304, // writes to a RWByteAddressBuffer or RWStructuredBuffer + Reserved0 = 226, // Reserved + Reserved1 = 227, // Reserved + Reserved10 = 236, // Reserved + Reserved11 = 237, // Reserved + Reserved2 = 228, // Reserved + Reserved3 = 229, // Reserved + Reserved4 = 230, // Reserved + Reserved5 = 231, // Reserved + Reserved6 = 232, // Reserved + Reserved7 = 233, // Reserved + Reserved8 = 234, // Reserved + Reserved9 = 235, // Reserved + ReservedA0 = 259, // reserved + ReservedA1 = 260, // reserved + ReservedA2 = 261, // reserved + ReservedB0 = 262, // reserved + ReservedB1 = 263, // reserved ReservedB10 = 272, // reserved ReservedB11 = 273, // reserved ReservedB12 = 274, // reserved @@ -517,7 +520,7 @@ enum class OpCode : unsigned { ReservedB17 = 279, // reserved ReservedB18 = 280, // reserved ReservedB19 = 281, // reserved - ReservedB2 = 264, // reserved + ReservedB2 = 264, // reserved ReservedB20 = 282, // reserved ReservedB21 = 283, // reserved ReservedB22 = 284, // reserved @@ -529,36 +532,42 @@ enum class OpCode : unsigned { ReservedB28 = 290, // reserved ReservedB29 = 291, // reserved ReservedB30 = 292, // reserved - ReservedB5 = 267, // reserved - ReservedB6 = 268, // reserved - ReservedB7 = 269, // reserved - ReservedB8 = 270, // reserved - ReservedB9 = 271, // reserved - ReservedC0 = 293, // reserved - ReservedC1 = 294, // reserved - ReservedC2 = 295, // reserved - ReservedC3 = 296, // reserved - ReservedC4 = 297, // reserved - ReservedC5 = 298, // reserved - ReservedC6 = 299, // reserved - ReservedC7 = 300, // reserved - ReservedC8 = 301, // reserved - ReservedC9 = 302, // reserved + ReservedB5 = 267, // reserved + ReservedB6 = 268, // reserved + ReservedB7 = 269, // reserved + ReservedB8 = 270, // reserved + ReservedB9 = 271, // reserved + ReservedC0 = 293, // reserved + ReservedC1 = 294, // reserved + ReservedC2 = 295, // reserved + ReservedC3 = 296, // reserved + ReservedC4 = 297, // reserved + ReservedC5 = 298, // reserved + ReservedC6 = 299, // reserved + ReservedC7 = 300, // reserved + ReservedC8 = 301, // reserved + ReservedC9 = 302, // reserved VectorAccumulate = 308, // Vector Accumulate // Amplification shader instructions DispatchMesh = 173, // Amplification shader intrinsic DispatchMesh // AnyHit Terminals - AcceptHitAndEndSearch = 156, // Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far - IgnoreHit = 155, // Used in an any hit shader to reject an intersection and terminate the shader + AcceptHitAndEndSearch = + 156, // Used in an any hit shader to abort the ray query and the + // intersection shader (if any). The current hit is committed and + // execution passes to the closest hit shader with the closest hit + // recorded so far + IgnoreHit = 155, // Used in an any hit shader to reject an intersection and + // terminate the shader // Binary float FMax = 35, // returns a if a >= b, else b FMin = 36, // returns a if a < b, else b // Binary int with two outputs - IMul = 41, // multiply of 32-bit operands to produce the correct full 64-bit result. + IMul = 41, // multiply of 32-bit operands to produce the correct full 64-bit + // result. // Binary int IMax = 37, // IMax(a,b) returns a if a > b, else b @@ -569,8 +578,10 @@ enum class OpCode : unsigned { USubb = 45, // unsigned subtract of 32-bit operands with the borrow // Binary uint with two outputs - UDiv = 43, // unsigned divide of the 32-bit operand src0 by the 32-bit operand src1. - UMul = 42, // multiply of 32-bit operands to produce the correct full 64-bit result. + UDiv = 43, // unsigned divide of the 32-bit operand src0 by the 32-bit operand + // src1. + UMul = 42, // multiply of 32-bit operands to produce the correct full 64-bit + // result. // Binary uint UMax = 39, // unsigned integer maximum. UMax(a,b) = a > b ? a : b @@ -585,41 +596,50 @@ enum class OpCode : unsigned { BitcastI64toF64 = 128, // bitcast between different sizes // Comparison Samples - SampleCmpBias = 255, // samples a texture after applying the input bias to the mipmap level and compares a single component against the specified comparison value - SampleCmpGrad = 254, // samples a texture using a gradient and compares a single component against the specified comparison value + SampleCmpBias = 255, // samples a texture after applying the input bias to the + // mipmap level and compares a single component against + // the specified comparison value + SampleCmpGrad = + 254, // samples a texture using a gradient and compares a single component + // against the specified comparison value // Compute/Mesh/Amplification/Node shader - FlattenedThreadIdInGroup = 96, // provides a flattened index for a given thread within a given group (SV_GroupIndex) - GroupId = 94, // reads the group ID (SV_GroupID) - ThreadId = 93, // reads the thread ID - ThreadIdInGroup = 95, // reads the thread ID within the group (SV_GroupThreadID) + FlattenedThreadIdInGroup = 96, // provides a flattened index for a given + // thread within a given group (SV_GroupIndex) + GroupId = 94, // reads the group ID (SV_GroupID) + ThreadId = 93, // reads the thread ID + ThreadIdInGroup = + 95, // reads the thread ID within the group (SV_GroupThreadID) // Create/Annotate Node Handles AllocateNodeOutputRecords = 238, // returns a handle for the output records - AnnotateNodeHandle = 249, // annotate handle with node properties + AnnotateNodeHandle = 249, // annotate handle with node properties AnnotateNodeRecordHandle = 251, // annotate handle with node record properties CreateNodeInputRecordHandle = 250, // create a handle for an InputRecord - CreateNodeOutputHandle = 247, // Creates a handle to a NodeOutput - IndexNodeHandle = 248, // returns the handle for the location in the output node array at the indicated index + CreateNodeOutputHandle = 247, // Creates a handle to a NodeOutput + IndexNodeHandle = 248, // returns the handle for the location in the output + // node array at the indicated index // Derivatives CalculateLOD = 81, // calculates the level of detail DerivCoarseX = 83, // computes the rate of change per stamp in x direction. DerivCoarseY = 84, // computes the rate of change per stamp in y direction. - DerivFineX = 85, // computes the rate of change per pixel in x direction. - DerivFineY = 86, // computes the rate of change per pixel in y direction. + DerivFineX = 85, // computes the rate of change per pixel in x direction. + DerivFineY = 86, // computes the rate of change per pixel in y direction. // Domain and hull shader LoadOutputControlPoint = 103, // LoadOutputControlPoint - LoadPatchConstant = 104, // LoadPatchConstant + LoadPatchConstant = 104, // LoadPatchConstant // Domain shader DomainLocation = 105, // DomainLocation // Dot product with accumulate - Dot2AddHalf = 162, // 2D half dot product with accumulate to float - Dot4AddI8Packed = 163, // signed dot product of 4 x i8 vectors packed into i32, with accumulate to i32 - Dot4AddU8Packed = 164, // unsigned dot product of 4 x u8 vectors packed into i32, with accumulate to i32 + Dot2AddHalf = 162, // 2D half dot product with accumulate to float + Dot4AddI8Packed = 163, // signed dot product of 4 x i8 vectors packed into + // i32, with accumulate to i32 + Dot4AddU8Packed = 164, // unsigned dot product of 4 x u8 vectors packed into + // i32, with accumulate to i32 // Dot Dot2 = 54, // Two-dimensional vector dot-product @@ -627,29 +647,34 @@ enum class OpCode : unsigned { Dot4 = 56, // Four-dimensional vector dot-product // Double precision - LegacyDoubleToFloat = 132, // legacy fuction to convert double to float + LegacyDoubleToFloat = 132, // legacy fuction to convert double to float LegacyDoubleToSInt32 = 133, // legacy fuction to convert double to int32 LegacyDoubleToUInt32 = 134, // legacy fuction to convert double to uint32 - MakeDouble = 101, // creates a double value - SplitDouble = 102, // splits a double into low and high parts + MakeDouble = 101, // creates a double value + SplitDouble = 102, // splits a double into low and high parts // Extended Command Information - StartInstanceLocation = 257, // returns the StartInstanceLocation from Draw*Instanced - StartVertexLocation = 256, // returns the BaseVertexLocation from DrawIndexedInstanced or StartVertexLocation from DrawInstanced + StartInstanceLocation = + 257, // returns the StartInstanceLocation from Draw*Instanced + StartVertexLocation = + 256, // returns the BaseVertexLocation from DrawIndexedInstanced or + // StartVertexLocation from DrawInstanced // Geometry shader - CutStream = 98, // completes the current primitive topology at the specified stream - EmitStream = 97, // emits a vertex to a given stream + CutStream = + 98, // completes the current primitive topology at the specified stream + EmitStream = 97, // emits a vertex to a given stream EmitThenCutStream = 99, // equivalent to an EmitStream followed by a CutStream - GSInstanceID = 100, // GSInstanceID + GSInstanceID = 100, // GSInstanceID // Get Pointer to Node Record in Address Space 6 - GetNodeRecordPtr = 239, // retrieve node input/output record pointer in address space 6 + GetNodeRecordPtr = + 239, // retrieve node input/output record pointer in address space 6 // Get handle from heap - AnnotateHandle = 216, // annotate handle with resource properties + AnnotateHandle = 216, // annotate handle with resource properties CreateHandleFromBinding = 217, // create resource handle from binding - CreateHandleFromHeap = 218, // create resource handle from heap + CreateHandleFromHeap = 218, // create resource handle from heap // Graphics shader ViewID = 138, // returns the view index @@ -659,189 +684,267 @@ enum class OpCode : unsigned { // Hull shader OutputControlPointID = 107, // OutputControlPointID - StorePatchConstant = 106, // StorePatchConstant + StorePatchConstant = 106, // StorePatchConstant // Hull, Domain and Geometry shaders PrimitiveID = 108, // PrimitiveID // Indirect Shader Invocation - CallShader = 159, // Call a shader in the callable shader table supplied through the DispatchRays() API - ReportHit = 158, // returns true if hit was accepted - TraceRay = 157, // initiates raytrace + CallShader = 159, // Call a shader in the callable shader table supplied + // through the DispatchRays() API + ReportHit = 158, // returns true if hit was accepted + TraceRay = 157, // initiates raytrace // Inline Ray Query - AllocateRayQuery = 178, // allocates space for RayQuery and return handle + AllocateRayQuery = 178, // allocates space for RayQuery and return handle AllocateRayQuery2 = 258, // allocates space for RayQuery and return handle - RayQuery_Abort = 181, // aborts a ray query + RayQuery_Abort = 181, // aborts a ray query RayQuery_CandidateGeometryIndex = 203, // returns candidate hit geometry index - RayQuery_CandidateInstanceContributionToHitGroupIndex = 214, // returns candidate hit InstanceContributionToHitGroupIndex - RayQuery_CandidateInstanceID = 202, // returns candidate hit instance ID + RayQuery_CandidateInstanceContributionToHitGroupIndex = + 214, // returns candidate hit InstanceContributionToHitGroupIndex + RayQuery_CandidateInstanceID = 202, // returns candidate hit instance ID RayQuery_CandidateInstanceIndex = 201, // returns candidate hit instance index - RayQuery_CandidateObjectRayDirection = 206, // returns candidate object ray direction - RayQuery_CandidateObjectRayOrigin = 205, // returns candidate hit object ray origin - RayQuery_CandidateObjectToWorld3x4 = 186, // returns matrix for transforming from object-space to world-space for a candidate hit. - RayQuery_CandidatePrimitiveIndex = 204, // returns candidate hit geometry index - RayQuery_CandidateProceduralPrimitiveNonOpaque = 190, // returns if current candidate procedural primitive is non opaque - RayQuery_CandidateTriangleBarycentrics = 193, // returns candidate triangle hit barycentrics - RayQuery_CandidateTriangleFrontFace = 191, // returns if current candidate triangle is front facing - RayQuery_CandidateTriangleRayT = 199, // returns float representing the parametric point on the ray for the current candidate triangle hit. - RayQuery_CandidateType = 185, // returns uint candidate type (CANDIDATE_TYPE) of the current hit candidate in a ray query, after Proceed() has returned true - RayQuery_CandidateWorldToObject3x4 = 187, // returns matrix for transforming from world-space to object-space for a candidate hit. - RayQuery_CommitNonOpaqueTriangleHit = 182, // commits a non opaque triangle hit - RayQuery_CommitProceduralPrimitiveHit = 183, // commits a procedural primitive hit + RayQuery_CandidateObjectRayDirection = + 206, // returns candidate object ray direction + RayQuery_CandidateObjectRayOrigin = + 205, // returns candidate hit object ray origin + RayQuery_CandidateObjectToWorld3x4 = + 186, // returns matrix for transforming from object-space to world-space + // for a candidate hit. + RayQuery_CandidatePrimitiveIndex = + 204, // returns candidate hit geometry index + RayQuery_CandidateProceduralPrimitiveNonOpaque = + 190, // returns if current candidate procedural primitive is non opaque + RayQuery_CandidateTriangleBarycentrics = + 193, // returns candidate triangle hit barycentrics + RayQuery_CandidateTriangleFrontFace = + 191, // returns if current candidate triangle is front facing + RayQuery_CandidateTriangleRayT = + 199, // returns float representing the parametric point on the ray for the + // current candidate triangle hit. + RayQuery_CandidateType = + 185, // returns uint candidate type (CANDIDATE_TYPE) of the current hit + // candidate in a ray query, after Proceed() has returned true + RayQuery_CandidateWorldToObject3x4 = + 187, // returns matrix for transforming from world-space to object-space + // for a candidate hit. + RayQuery_CommitNonOpaqueTriangleHit = + 182, // commits a non opaque triangle hit + RayQuery_CommitProceduralPrimitiveHit = + 183, // commits a procedural primitive hit RayQuery_CommittedGeometryIndex = 209, // returns committed hit geometry index - RayQuery_CommittedInstanceContributionToHitGroupIndex = 215, // returns committed hit InstanceContributionToHitGroupIndex - RayQuery_CommittedInstanceID = 208, // returns committed hit instance ID + RayQuery_CommittedInstanceContributionToHitGroupIndex = + 215, // returns committed hit InstanceContributionToHitGroupIndex + RayQuery_CommittedInstanceID = 208, // returns committed hit instance ID RayQuery_CommittedInstanceIndex = 207, // returns committed hit instance index - RayQuery_CommittedObjectRayDirection = 212, // returns committed object ray direction - RayQuery_CommittedObjectRayOrigin = 211, // returns committed hit object ray origin - RayQuery_CommittedObjectToWorld3x4 = 188, // returns matrix for transforming from object-space to world-space for a Committed hit. - RayQuery_CommittedPrimitiveIndex = 210, // returns committed hit geometry index - RayQuery_CommittedRayT = 200, // returns float representing the parametric point on the ray for the current committed hit. - RayQuery_CommittedStatus = 184, // returns uint status (COMMITTED_STATUS) of the committed hit in a ray query - RayQuery_CommittedTriangleBarycentrics = 194, // returns committed triangle hit barycentrics - RayQuery_CommittedTriangleFrontFace = 192, // returns if current committed triangle is front facing - RayQuery_CommittedWorldToObject3x4 = 189, // returns matrix for transforming from world-space to object-space for a Committed hit. - RayQuery_Proceed = 180, // advances a ray query + RayQuery_CommittedObjectRayDirection = + 212, // returns committed object ray direction + RayQuery_CommittedObjectRayOrigin = + 211, // returns committed hit object ray origin + RayQuery_CommittedObjectToWorld3x4 = + 188, // returns matrix for transforming from object-space to world-space + // for a Committed hit. + RayQuery_CommittedPrimitiveIndex = + 210, // returns committed hit geometry index + RayQuery_CommittedRayT = + 200, // returns float representing the parametric point on the ray for the + // current committed hit. + RayQuery_CommittedStatus = 184, // returns uint status (COMMITTED_STATUS) of + // the committed hit in a ray query + RayQuery_CommittedTriangleBarycentrics = + 194, // returns committed triangle hit barycentrics + RayQuery_CommittedTriangleFrontFace = + 192, // returns if current committed triangle is front facing + RayQuery_CommittedWorldToObject3x4 = + 189, // returns matrix for transforming from world-space to object-space + // for a Committed hit. + RayQuery_Proceed = 180, // advances a ray query RayQuery_RayFlags = 195, // returns ray flags - RayQuery_RayTMin = 198, // returns float representing the parametric starting point for the ray. - RayQuery_TraceRayInline = 179, // initializes RayQuery for raytrace + RayQuery_RayTMin = 198, // returns float representing the parametric starting + // point for the ray. + RayQuery_TraceRayInline = 179, // initializes RayQuery for raytrace RayQuery_WorldRayDirection = 197, // returns world ray direction - RayQuery_WorldRayOrigin = 196, // returns world ray origin + RayQuery_WorldRayOrigin = 196, // returns world ray origin // Legacy floating-point - LegacyF16ToF32 = 131, // legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision) - LegacyF32ToF16 = 130, // legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision) + LegacyF16ToF32 = 131, // legacy fuction to convert half (f16) to float (f32) + // (this is not related to min-precision) + LegacyF32ToF16 = 130, // legacy fuction to convert float (f32) to half (f16) + // (this is not related to min-precision) // Library create handle from resource struct (like HL intrinsic) - CreateHandleForLib = 160, // create resource handle from resource struct for library + CreateHandleForLib = + 160, // create resource handle from resource struct for library // Mesh shader instructions EmitIndices = 169, // emit a primitive's vertex indices in a mesh shader - GetMeshPayload = 170, // get the mesh payload which is from amplification shader + GetMeshPayload = + 170, // get the mesh payload which is from amplification shader SetMeshOutputCounts = 168, // Mesh shader intrinsic SetMeshOutputCounts - StorePrimitiveOutput = 172, // stores the value to mesh shader primitive output + StorePrimitiveOutput = + 172, // stores the value to mesh shader primitive output StoreVertexOutput = 171, // stores the value to mesh shader vertex output // Other CycleCounterLegacy = 109, // CycleCounterLegacy // Packing intrinsics - Pack4x8 = 220, // packs vector of 4 signed or unsigned values into a packed datatype, drops or clamps unused bits + Pack4x8 = 220, // packs vector of 4 signed or unsigned values into a packed + // datatype, drops or clamps unused bits // Pixel shader - AttributeAtVertex = 137, // returns the values of the attributes at the vertex. - Coverage = 91, // returns the coverage mask input in a pixel shader - Discard = 82, // discard the current pixel - EvalCentroid = 89, // evaluates an input attribute at pixel center + AttributeAtVertex = + 137, // returns the values of the attributes at the vertex. + Coverage = 91, // returns the coverage mask input in a pixel shader + Discard = 82, // discard the current pixel + EvalCentroid = 89, // evaluates an input attribute at pixel center EvalSampleIndex = 88, // evaluates an input attribute at a sample location - EvalSnapped = 87, // evaluates an input attribute at pixel center with an offset - InnerCoverage = 92, // returns underestimated coverage input from conservative rasterization in a pixel shader - SampleIndex = 90, // returns the sample index in a sample-frequency pixel shader + EvalSnapped = + 87, // evaluates an input attribute at pixel center with an offset + InnerCoverage = 92, // returns underestimated coverage input from conservative + // rasterization in a pixel shader + SampleIndex = + 90, // returns the sample index in a sample-frequency pixel shader // Quad Wave Ops - QuadOp = 123, // returns the result of a quad-level operation + QuadOp = 123, // returns the result of a quad-level operation QuadReadLaneAt = 122, // reads from a lane in the quad - QuadVote = 222, // compares boolean accross a quad + QuadVote = 222, // compares boolean accross a quad // Quaternary - Bfi = 53, // Given a bit range from the LSB of a number, places that number of bits in another number at any offset + Bfi = 53, // Given a bit range from the LSB of a number, places that number of + // bits in another number at any offset // Ray Dispatch Arguments - DispatchRaysDimensions = 146, // The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call. - DispatchRaysIndex = 145, // The current x and y location within the Width and Height + DispatchRaysDimensions = + 146, // The Width and Height values from the D3D12_DISPATCH_RAYS_DESC + // structure provided to the originating DispatchRays() call. + DispatchRaysIndex = + 145, // The current x and y location within the Width and Height // Ray Transforms - ObjectToWorld = 151, // Matrix for transforming from object-space to world-space. - WorldToObject = 152, // Matrix for transforming from world-space to object-space. + ObjectToWorld = + 151, // Matrix for transforming from object-space to world-space. + WorldToObject = + 152, // Matrix for transforming from world-space to object-space. // Ray Vectors WorldRayDirection = 148, // The world-space direction for the current ray. - WorldRayOrigin = 147, // The world-space origin for the current ray. + WorldRayOrigin = 147, // The world-space origin for the current ray. // Ray object space Vectors ObjectRayDirection = 150, // Object-space direction for the current ray. - ObjectRayOrigin = 149, // Object-space origin for the current ray. + ObjectRayOrigin = 149, // Object-space origin for the current ray. // RayT - RayTCurrent = 154, // float representing the current parametric ending point for the ray - RayTMin = 153, // float representing the parametric starting point for the ray. + RayTCurrent = + 154, // float representing the current parametric ending point for the ray + RayTMin = + 153, // float representing the parametric starting point for the ray. // Raytracing hit uint System Values - HitKind = 143, // Returns the value passed as HitKind in ReportIntersection(). If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE. + HitKind = 143, // Returns the value passed as HitKind in ReportIntersection(). + // If intersection was reported by fixed-function triangle + // intersection, HitKind will be one of + // HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE. // Raytracing object space uint System Values, raytracing tier 1.1 - GeometryIndex = 213, // The autogenerated index of the current geometry in the bottom-level structure + GeometryIndex = 213, // The autogenerated index of the current geometry in the + // bottom-level structure // Raytracing object space uint System Values - InstanceID = 141, // The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure - InstanceIndex = 142, // The autogenerated index of the current instance in the top-level structure + InstanceID = + 141, // The user-provided InstanceID on the bottom-level acceleration + // structure instance within the top-level structure + InstanceIndex = 142, // The autogenerated index of the current instance in the + // top-level structure PrimitiveIndex = 161, // PrimitiveIndex for raytracing shaders // Raytracing uint System Values RayFlags = 144, // uint containing the current ray flags. // Resources - gather - TextureGather = 73, // gathers the four texels that would be used in a bi-linear filtering operation - TextureGatherCmp = 74, // same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp - TextureGatherRaw = 223, // Gather raw elements from 4 texels with no type conversions (SRV type is constrained) + TextureGather = 73, // gathers the four texels that would be used in a + // bi-linear filtering operation + TextureGatherCmp = 74, // same as TextureGather, except this instrution + // performs comparison on texels, similar to SampleCmp + TextureGatherRaw = 223, // Gather raw elements from 4 texels with no type + // conversions (SRV type is constrained) // Resources - sample - RenderTargetGetSampleCount = 77, // gets the number of samples for a render target - RenderTargetGetSamplePosition = 76, // gets the position of the specified sample + RenderTargetGetSampleCount = + 77, // gets the number of samples for a render target + RenderTargetGetSamplePosition = + 76, // gets the position of the specified sample Sample = 60, // samples a texture - SampleBias = 61, // samples a texture after applying the input bias to the mipmap level - SampleCmp = 64, // samples a texture and compares a single component against the specified comparison value - SampleCmpLevel = 224, // samples a texture and compares a single component against the specified comparison value - SampleCmpLevelZero = 65, // samples a texture and compares a single component against the specified comparison value - SampleGrad = 63, // samples a texture using a gradient to influence the way the sample location is calculated + SampleBias = + 61, // samples a texture after applying the input bias to the mipmap level + SampleCmp = 64, // samples a texture and compares a single component against + // the specified comparison value + SampleCmpLevel = 224, // samples a texture and compares a single component + // against the specified comparison value + SampleCmpLevelZero = 65, // samples a texture and compares a single component + // against the specified comparison value + SampleGrad = 63, // samples a texture using a gradient to influence the way + // the sample location is calculated SampleLevel = 62, // samples a texture using a mipmap-level offset - Texture2DMSGetSamplePosition = 75, // gets the position of the specified sample + Texture2DMSGetSamplePosition = + 75, // gets the position of the specified sample // Resources - BufferLoad = 68, // reads from a TypedBuffer - BufferStore = 69, // writes to a RWTypedBuffer - BufferUpdateCounter = 70, // atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV - CBufferLoad = 58, // loads a value from a constant buffer resource - CBufferLoadLegacy = 59, // loads a value from a constant buffer resource - CheckAccessFullyMapped = 71, // determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource - CreateHandle = 57, // creates the handle to a resource - GetDimensions = 72, // gets texture size information - RawBufferLoad = 139, // reads from a raw buffer and structured buffer + BufferLoad = 68, // reads from a TypedBuffer + BufferStore = 69, // writes to a RWTypedBuffer + BufferUpdateCounter = 70, // atomically increments/decrements the hidden + // 32-bit counter stored with a Count or Append UAV + CBufferLoad = 58, // loads a value from a constant buffer resource + CBufferLoadLegacy = 59, // loads a value from a constant buffer resource + CheckAccessFullyMapped = + 71, // determines whether all values from a Sample, Gather, or Load + // operation accessed mapped tiles in a tiled resource + CreateHandle = 57, // creates the handle to a resource + GetDimensions = 72, // gets texture size information + RawBufferLoad = 139, // reads from a raw buffer and structured buffer RawBufferStore = 140, // writes to a RWByteAddressBuffer or RWStructuredBuffer - TextureLoad = 66, // reads texel data without any filtering or sampling - TextureStore = 67, // reads texel data without any filtering or sampling + TextureLoad = 66, // reads texel data without any filtering or sampling + TextureStore = 67, // reads texel data without any filtering or sampling TextureStoreSample = 225, // stores texel data at specified sample index // Sampler Feedback - WriteSamplerFeedback = 174, // updates a feedback texture for a sampling operation - WriteSamplerFeedbackBias = 175, // updates a feedback texture for a sampling operation with a bias on the mipmap level - WriteSamplerFeedbackGrad = 177, // updates a feedback texture for a sampling operation with explicit gradients - WriteSamplerFeedbackLevel = 176, // updates a feedback texture for a sampling operation with a mipmap-level offset + WriteSamplerFeedback = + 174, // updates a feedback texture for a sampling operation + WriteSamplerFeedbackBias = 175, // updates a feedback texture for a sampling + // operation with a bias on the mipmap level + WriteSamplerFeedbackGrad = 177, // updates a feedback texture for a sampling + // operation with explicit gradients + WriteSamplerFeedbackLevel = 176, // updates a feedback texture for a sampling + // operation with a mipmap-level offset // Shader Execution Reordering HitObject_MakeMiss = 265, // Creates a new HitObject representing a miss - HitObject_MakeNop = 266, // Creates an empty nop HitObject + HitObject_MakeNop = 266, // Creates an empty nop HitObject // Synchronization - AtomicBinOp = 78, // performs an atomic operation on two operands + AtomicBinOp = 78, // performs an atomic operation on two operands AtomicCompareExchange = 79, // atomic compare and exchange to memory - Barrier = 80, // inserts a memory barrier in the shader - BarrierByMemoryHandle = 245, // Request a barrier for just the memory used by the specified object - BarrierByMemoryType = 244, // Request a barrier for a set of memory types and/or thread group execution sync - BarrierByNodeRecordHandle = 246, // Request a barrier for just the memory used by the node record + Barrier = 80, // inserts a memory barrier in the shader + BarrierByMemoryHandle = + 245, // Request a barrier for just the memory used by the specified object + BarrierByMemoryType = 244, // Request a barrier for a set of memory types + // and/or thread group execution sync + BarrierByNodeRecordHandle = + 246, // Request a barrier for just the memory used by the node record // Temporary, indexable, input, output registers - LoadInput = 4, // Loads the value from shader input - MinPrecXRegLoad = 2, // Helper load operation for minprecision + LoadInput = 4, // Loads the value from shader input + MinPrecXRegLoad = 2, // Helper load operation for minprecision MinPrecXRegStore = 3, // Helper store operation for minprecision - StoreOutput = 5, // Stores the value to shader output - TempRegLoad = 0, // Helper load operation - TempRegStore = 1, // Helper store operation + StoreOutput = 5, // Stores the value to shader output + TempRegLoad = 0, // Helper load operation + TempRegStore = 1, // Helper store operation // Tertiary float FMad = 46, // floating point multiply & add - Fma = 47, // fused multiply-add + Fma = 47, // fused multiply-add // Tertiary int IMad = 48, // Signed integer multiply & add @@ -856,68 +959,87 @@ enum class OpCode : unsigned { Round_ne = 26, // floating-point round to integral float. Round_ni = 27, // floating-point round to integral float. Round_pi = 28, // floating-point round to integral float. - Round_z = 29, // floating-point round to integral float. + Round_z = 29, // floating-point round to integral float. // Unary float - Acos = 15, // Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1. - Asin = 16, // Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1 - Atan = 17, // Returns the arctangent of the specified value. The return value is within the range of -PI/2 to PI/2. - Cos = 12, // returns cosine(theta) for theta in radians. - Exp = 21, // returns 2^exponent - FAbs = 6, // returns the absolute value of the input value. - Frc = 22, // extract fracitonal component. + Acos = 15, // Returns the arccosine of the specified value. Input should be a + // floating-point value within the range of -1 to 1. + Asin = 16, // Returns the arccosine of the specified value. Input should be a + // floating-point value within the range of -1 to 1 + Atan = 17, // Returns the arctangent of the specified value. The return value + // is within the range of -PI/2 to PI/2. + Cos = 12, // returns cosine(theta) for theta in radians. + Exp = 21, // returns 2^exponent + FAbs = 6, // returns the absolute value of the input value. + Frc = 22, // extract fracitonal component. Hcos = 18, // returns the hyperbolic cosine of the specified value. Hsin = 19, // returns the hyperbolic sine of the specified value. Htan = 20, // returns the hyperbolic tangent of the specified value. IsFinite = 10, // Returns true if x is finite, false otherwise. - IsInf = 9, // Returns true if x is +INF or -INF, false otherwise. - IsNaN = 8, // Returns true if x is NAN or QNAN, false otherwise. + IsInf = 9, // Returns true if x is +INF or -INF, false otherwise. + IsNaN = 8, // Returns true if x is NAN or QNAN, false otherwise. IsNormal = 11, // returns IsNormal - Log = 23, // returns log base 2. - Rsqrt = 25, // returns reciprocal square root (1 / sqrt(src) - Saturate = 7, // clamps the result of a single or double precision floating point value to [0.0f...1.0f] - Sin = 13, // returns sine(theta) for theta in radians. - Sqrt = 24, // returns square root - Tan = 14, // returns tan(theta) for theta in radians. + Log = 23, // returns log base 2. + Rsqrt = 25, // returns reciprocal square root (1 / sqrt(src) + Saturate = 7, // clamps the result of a single or double precision floating + // point value to [0.0f...1.0f] + Sin = 13, // returns sine(theta) for theta in radians. + Sqrt = 24, // returns square root + Tan = 14, // returns tan(theta) for theta in radians. // Unary int - Bfrev = 30, // Reverses the order of the bits. - Countbits = 31, // Counts the number of bits in the input integer. - FirstbitLo = 32, // Returns the location of the first set bit starting from the lowest order bit and working upward. - FirstbitSHi = 34, // Returns the location of the first set bit from the highest order bit based on the sign. + Bfrev = 30, // Reverses the order of the bits. + Countbits = 31, // Counts the number of bits in the input integer. + FirstbitLo = 32, // Returns the location of the first set bit starting from + // the lowest order bit and working upward. + FirstbitSHi = 34, // Returns the location of the first set bit from the + // highest order bit based on the sign. // Unary uint - FirstbitHi = 33, // Returns the location of the first set bit starting from the highest order bit and working downward. + FirstbitHi = 33, // Returns the location of the first set bit starting from + // the highest order bit and working downward. // Unpacking intrinsics - Unpack4x8 = 219, // unpacks 4 8-bit signed or unsigned values into int32 or int16 vector + Unpack4x8 = 219, // unpacks 4 8-bit signed or unsigned values into int32 or + // int16 vector // Wave WaveActiveAllEqual = 115, // returns 1 if all the lanes have the same value - WaveActiveBallot = 116, // returns a struct with a bit set for each lane where the condition is true - WaveActiveBit = 120, // returns the result of the operation across all lanes - WaveActiveOp = 119, // returns the result the operation across waves + WaveActiveBallot = 116, // returns a struct with a bit set for each lane where + // the condition is true + WaveActiveBit = 120, // returns the result of the operation across all lanes + WaveActiveOp = 119, // returns the result the operation across waves WaveAllBitCount = 135, // returns the count of bits set to 1 across the wave WaveAllTrue = 114, // returns 1 if all the lanes evaluate the value to true WaveAnyTrue = 113, // returns 1 if any of the lane evaluates the value to true WaveGetLaneCount = 112, // returns the number of lanes in the wave WaveGetLaneIndex = 111, // returns the index of the current lane in the wave - WaveIsFirstLane = 110, // returns 1 for the first lane in the wave - WaveMatch = 165, // returns the bitmask of active lanes that have the same value - WaveMultiPrefixBitCount = 167, // returns the count of bits set to 1 on groups of lanes identified by a bitmask - WaveMultiPrefixOp = 166, // returns the result of the operation on groups of lanes identified by a bitmask + WaveIsFirstLane = 110, // returns 1 for the first lane in the wave + WaveMatch = + 165, // returns the bitmask of active lanes that have the same value + WaveMultiPrefixBitCount = 167, // returns the count of bits set to 1 on groups + // of lanes identified by a bitmask + WaveMultiPrefixOp = 166, // returns the result of the operation on groups of + // lanes identified by a bitmask WavePrefixBitCount = 136, // returns the count of bits set to 1 on prior lanes - WavePrefixOp = 121, // returns the result of the operation on prior lanes - WaveReadLaneAt = 117, // returns the value from the specified lane + WavePrefixOp = 121, // returns the result of the operation on prior lanes + WaveReadLaneAt = 117, // returns the value from the specified lane WaveReadLaneFirst = 118, // returns the value from the first lane // Work Graph intrinsics - FinishedCrossGroupSharing = 243, // returns true if the current thread group is the last to access the input - GetInputRecordCount = 242, // returns the number of records that have been coalesced into the current thread group - GetRemainingRecursionLevels = 253, // returns how many levels of recursion remain - IncrementOutputCount = 240, // Select the next logical output count for an EmptyNodeOutput for the whole group or per thread. - NodeOutputIsValid = 252, // returns true if the specified output node is present in the work graph - OutputComplete = 241, // indicates all outputs for a given records are complete + FinishedCrossGroupSharing = 243, // returns true if the current thread group + // is the last to access the input + GetInputRecordCount = 242, // returns the number of records that have been + // coalesced into the current thread group + GetRemainingRecursionLevels = + 253, // returns how many levels of recursion remain + IncrementOutputCount = + 240, // Select the next logical output count for an EmptyNodeOutput for + // the whole group or per thread. + NodeOutputIsValid = 252, // returns true if the specified output node is + // present in the work graph + OutputComplete = + 241, // indicates all outputs for a given records are complete NumOpCodes_Dxil_1_0 = 137, NumOpCodes_Dxil_1_1 = 139, @@ -941,7 +1063,7 @@ enum class OpCode : unsigned { // OPCODECLASS-ENUM:BEGIN // Groups for DXIL operations with equivalent function templates enum class OpCodeClass : unsigned { - // + // MatVecMul, MatVecMulAdd, OuterProductAccumulate, @@ -1633,7 +1755,7 @@ enum class QuadOpKind { // Kind of bitwise cross-lane operation enum class WaveBitOpKind : unsigned { And = 0, // bitwise and of values - Or = 1, // bitwise or of values + Or = 1, // bitwise or of values Xor = 2, // bitwise xor of values }; // WAVEBITOPKIND-ENUM:END @@ -1645,10 +1767,10 @@ enum class WaveBitOpKind : unsigned { // WAVEOPKIND-ENUM:BEGIN // Kind of cross-lane operation enum class WaveOpKind : unsigned { - Max = 3, // maximum value - Min = 2, // minimum value + Max = 3, // maximum value + Min = 2, // minimum value Product = 1, // product of values - Sum = 0, // sum of values + Sum = 0, // sum of values }; // WAVEOPKIND-ENUM:END @@ -1659,11 +1781,11 @@ enum class WaveOpKind : unsigned { // WAVEMULTIPREFIXOPKIND-ENUM:BEGIN // Kind of cross-lane for multi-prefix operation enum class WaveMultiPrefixOpKind : unsigned { - And = 1, // bitwise and of values - Or = 2, // bitwise or of values + And = 1, // bitwise and of values + Or = 2, // bitwise or of values Product = 4, // product of values - Sum = 0, // sum of values - Xor = 3, // bitwise xor of values + Sum = 0, // sum of values + Xor = 3, // bitwise xor of values }; // WAVEMULTIPREFIXOPKIND-ENUM:END @@ -1674,7 +1796,7 @@ enum class WaveMultiPrefixOpKind : unsigned { // SIGNEDOPKIND-ENUM:BEGIN // Sign vs. unsigned operands for operation enum class SignedOpKind : unsigned { - Signed = 0, // signed integer or floating-point operands + Signed = 0, // signed integer or floating-point operands Unsigned = 1, // unsigned integer operands }; // SIGNEDOPKIND-ENUM:END diff --git a/include/dxc/DXIL/DxilInstructions.h b/include/dxc/DXIL/DxilInstructions.h index 8bd4244169..367aeec708 100644 --- a/include/dxc/DXIL/DxilInstructions.h +++ b/include/dxc/DXIL/DxilInstructions.h @@ -31,9 +31,7 @@ struct LlvmInst_Ret { llvm::Instruction *Instr; // Construction and identification LlvmInst_Ret(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::Ret; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::Ret; } // Validation support bool isAllowed() const { return true; } }; @@ -43,9 +41,7 @@ struct LlvmInst_Br { llvm::Instruction *Instr; // Construction and identification LlvmInst_Br(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::Br; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::Br; } // Validation support bool isAllowed() const { return true; } }; @@ -115,9 +111,7 @@ struct LlvmInst_Add { llvm::Instruction *Instr; // Construction and identification LlvmInst_Add(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::Add; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::Add; } // Validation support bool isAllowed() const { return true; } }; @@ -139,9 +133,7 @@ struct LlvmInst_Sub { llvm::Instruction *Instr; // Construction and identification LlvmInst_Sub(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::Sub; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::Sub; } // Validation support bool isAllowed() const { return true; } }; @@ -163,9 +155,7 @@ struct LlvmInst_Mul { llvm::Instruction *Instr; // Construction and identification LlvmInst_Mul(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::Mul; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::Mul; } // Validation support bool isAllowed() const { return true; } }; @@ -218,7 +208,8 @@ struct LlvmInst_FDiv { bool isAllowed() const { return true; } }; -/// This instruction returns the remainder from the unsigned division of its two operands +/// This instruction returns the remainder from the unsigned division of its two +/// operands struct LlvmInst_URem { llvm::Instruction *Instr; // Construction and identification @@ -230,7 +221,8 @@ struct LlvmInst_URem { bool isAllowed() const { return true; } }; -/// This instruction returns the remainder from the signed division of its two operands +/// This instruction returns the remainder from the signed division of its two +/// operands struct LlvmInst_SRem { llvm::Instruction *Instr; // Construction and identification @@ -259,9 +251,7 @@ struct LlvmInst_Shl { llvm::Instruction *Instr; // Construction and identification LlvmInst_Shl(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::Shl; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::Shl; } // Validation support bool isAllowed() const { return true; } }; @@ -295,9 +285,7 @@ struct LlvmInst_And { llvm::Instruction *Instr; // Construction and identification LlvmInst_And(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::And; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::And; } // Validation support bool isAllowed() const { return true; } }; @@ -307,9 +295,7 @@ struct LlvmInst_Or { llvm::Instruction *Instr; // Construction and identification LlvmInst_Or(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::Or; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::Or; } // Validation support bool isAllowed() const { return true; } }; @@ -319,14 +305,13 @@ struct LlvmInst_Xor { llvm::Instruction *Instr; // Construction and identification LlvmInst_Xor(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::Xor; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::Xor; } // Validation support bool isAllowed() const { return true; } }; -/// This instruction allocates memory on the stack frame of the currently executing function +/// This instruction allocates memory on the stack frame of the currently +/// executing function struct LlvmInst_Alloca { llvm::Instruction *Instr; // Construction and identification @@ -595,9 +580,7 @@ struct LlvmInst_PHI { llvm::Instruction *Instr; // Construction and identification LlvmInst_PHI(llvm::Instruction *pInstr) : Instr(pInstr) {} - operator bool() const { - return Instr->getOpcode() == llvm::Instruction::PHI; - } + operator bool() const { return Instr->getOpcode() == llvm::Instruction::PHI; } // Validation support bool isAllowed() const { return true; } }; @@ -733,7 +716,8 @@ struct DxilInst_TempRegLoad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -753,12 +737,14 @@ struct DxilInst_TempRegStore { // Construction and identification DxilInst_TempRegStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TempRegStore); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::TempRegStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -781,12 +767,14 @@ struct DxilInst_MinPrecXRegLoad { // Construction and identification DxilInst_MinPrecXRegLoad(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MinPrecXRegLoad); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::MinPrecXRegLoad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -812,12 +800,14 @@ struct DxilInst_MinPrecXRegStore { // Construction and identification DxilInst_MinPrecXRegStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MinPrecXRegStore); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::MinPrecXRegStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -851,7 +841,8 @@ struct DxilInst_LoadInput { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -885,7 +876,8 @@ struct DxilInst_StoreOutput { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -919,7 +911,8 @@ struct DxilInst_FAbs { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -933,7 +926,8 @@ struct DxilInst_FAbs { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction clamps the result of a single or double precision floating point value to [0.0f...1.0f] +/// This instruction clamps the result of a single or double precision floating +/// point value to [0.0f...1.0f] struct DxilInst_Saturate { llvm::Instruction *Instr; // Construction and identification @@ -944,7 +938,8 @@ struct DxilInst_Saturate { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -969,7 +964,8 @@ struct DxilInst_IsNaN { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -994,7 +990,8 @@ struct DxilInst_IsInf { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1019,7 +1016,8 @@ struct DxilInst_IsFinite { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1044,7 +1042,8 @@ struct DxilInst_IsNormal { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1069,7 +1068,8 @@ struct DxilInst_Cos { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1094,7 +1094,8 @@ struct DxilInst_Sin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1119,7 +1120,8 @@ struct DxilInst_Tan { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1133,7 +1135,8 @@ struct DxilInst_Tan { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1. +/// This instruction Returns the arccosine of the specified value. Input should +/// be a floating-point value within the range of -1 to 1. struct DxilInst_Acos { llvm::Instruction *Instr; // Construction and identification @@ -1144,7 +1147,8 @@ struct DxilInst_Acos { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1158,7 +1162,8 @@ struct DxilInst_Acos { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1 +/// This instruction Returns the arccosine of the specified value. Input should +/// be a floating-point value within the range of -1 to 1 struct DxilInst_Asin { llvm::Instruction *Instr; // Construction and identification @@ -1169,7 +1174,8 @@ struct DxilInst_Asin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1183,7 +1189,8 @@ struct DxilInst_Asin { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the arctangent of the specified value. The return value is within the range of -PI/2 to PI/2. +/// This instruction Returns the arctangent of the specified value. The return +/// value is within the range of -PI/2 to PI/2. struct DxilInst_Atan { llvm::Instruction *Instr; // Construction and identification @@ -1194,7 +1201,8 @@ struct DxilInst_Atan { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1219,7 +1227,8 @@ struct DxilInst_Hcos { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1244,7 +1253,8 @@ struct DxilInst_Hsin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1269,7 +1279,8 @@ struct DxilInst_Htan { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1294,7 +1305,8 @@ struct DxilInst_Exp { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1319,7 +1331,8 @@ struct DxilInst_Frc { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1344,7 +1357,8 @@ struct DxilInst_Log { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1369,7 +1383,8 @@ struct DxilInst_Sqrt { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1394,7 +1409,8 @@ struct DxilInst_Rsqrt { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1419,7 +1435,8 @@ struct DxilInst_Round_ne { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1444,7 +1461,8 @@ struct DxilInst_Round_ni { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1469,7 +1487,8 @@ struct DxilInst_Round_pi { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1494,7 +1513,8 @@ struct DxilInst_Round_z { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1519,7 +1539,8 @@ struct DxilInst_Bfrev { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1544,7 +1565,8 @@ struct DxilInst_Countbits { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1558,7 +1580,8 @@ struct DxilInst_Countbits { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the location of the first set bit starting from the lowest order bit and working upward. +/// This instruction Returns the location of the first set bit starting from the +/// lowest order bit and working upward. struct DxilInst_FirstbitLo { llvm::Instruction *Instr; // Construction and identification @@ -1569,7 +1592,8 @@ struct DxilInst_FirstbitLo { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1583,7 +1607,8 @@ struct DxilInst_FirstbitLo { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the location of the first set bit starting from the highest order bit and working downward. +/// This instruction Returns the location of the first set bit starting from the +/// highest order bit and working downward. struct DxilInst_FirstbitHi { llvm::Instruction *Instr; // Construction and identification @@ -1594,7 +1619,8 @@ struct DxilInst_FirstbitHi { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1608,7 +1634,8 @@ struct DxilInst_FirstbitHi { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Returns the location of the first set bit from the highest order bit based on the sign. +/// This instruction Returns the location of the first set bit from the highest +/// order bit based on the sign. struct DxilInst_FirstbitSHi { llvm::Instruction *Instr; // Construction and identification @@ -1619,7 +1646,8 @@ struct DxilInst_FirstbitSHi { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1644,7 +1672,8 @@ struct DxilInst_FMax { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1672,7 +1701,8 @@ struct DxilInst_FMin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1700,7 +1730,8 @@ struct DxilInst_IMax { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1728,7 +1759,8 @@ struct DxilInst_IMin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1756,7 +1788,8 @@ struct DxilInst_UMax { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1784,7 +1817,8 @@ struct DxilInst_UMin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1801,7 +1835,8 @@ struct DxilInst_UMin { void set_b(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction multiply of 32-bit operands to produce the correct full 64-bit result. +/// This instruction multiply of 32-bit operands to produce the correct full +/// 64-bit result. struct DxilInst_IMul { llvm::Instruction *Instr; // Construction and identification @@ -1812,7 +1847,8 @@ struct DxilInst_IMul { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1829,7 +1865,8 @@ struct DxilInst_IMul { void set_b(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction multiply of 32-bit operands to produce the correct full 64-bit result. +/// This instruction multiply of 32-bit operands to produce the correct full +/// 64-bit result. struct DxilInst_UMul { llvm::Instruction *Instr; // Construction and identification @@ -1840,7 +1877,8 @@ struct DxilInst_UMul { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1857,7 +1895,8 @@ struct DxilInst_UMul { void set_b(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction unsigned divide of the 32-bit operand src0 by the 32-bit operand src1. +/// This instruction unsigned divide of the 32-bit operand src0 by the 32-bit +/// operand src1. struct DxilInst_UDiv { llvm::Instruction *Instr; // Construction and identification @@ -1868,7 +1907,8 @@ struct DxilInst_UDiv { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1896,7 +1936,8 @@ struct DxilInst_UAddc { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1924,7 +1965,8 @@ struct DxilInst_USubb { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1952,7 +1994,8 @@ struct DxilInst_FMad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -1983,7 +2026,8 @@ struct DxilInst_Fma { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2014,7 +2058,8 @@ struct DxilInst_IMad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2045,7 +2090,8 @@ struct DxilInst_UMad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2076,7 +2122,8 @@ struct DxilInst_Msad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2107,7 +2154,8 @@ struct DxilInst_Ibfe { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2138,7 +2186,8 @@ struct DxilInst_Ubfe { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2158,7 +2207,8 @@ struct DxilInst_Ubfe { void set_c(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction Given a bit range from the LSB of a number, places that number of bits in another number at any offset +/// This instruction Given a bit range from the LSB of a number, places that +/// number of bits in another number at any offset struct DxilInst_Bfi { llvm::Instruction *Instr; // Construction and identification @@ -2169,7 +2219,8 @@ struct DxilInst_Bfi { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2203,7 +2254,8 @@ struct DxilInst_Dot2 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2237,7 +2289,8 @@ struct DxilInst_Dot3 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2277,7 +2330,8 @@ struct DxilInst_Dot4 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2318,12 +2372,14 @@ struct DxilInst_CreateHandle { // Construction and identification DxilInst_CreateHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::CreateHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2338,18 +2394,39 @@ struct DxilInst_CreateHandle { // Accessors llvm::Value *get_resourceClass() const { return Instr->getOperand(1); } void set_resourceClass(llvm::Value *val) { Instr->setOperand(1, val); } - int8_t get_resourceClass_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } - void set_resourceClass_val(int8_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_resourceClass_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(1)) + ->getZExtValue()); + } + void set_resourceClass_val(int8_t val) { + Instr->setOperand(1, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } llvm::Value *get_rangeId() const { return Instr->getOperand(2); } void set_rangeId(llvm::Value *val) { Instr->setOperand(2, val); } - int32_t get_rangeId_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_rangeId_val(int32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_rangeId_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_rangeId_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } llvm::Value *get_index() const { return Instr->getOperand(3); } void set_index(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_nonUniformIndex() const { return Instr->getOperand(4); } void set_nonUniformIndex(llvm::Value *val) { Instr->setOperand(4, val); } - bool get_nonUniformIndex_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(4))->getZExtValue()); } - void set_nonUniformIndex_val(bool val) { Instr->setOperand(4, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } + bool get_nonUniformIndex_val() const { + return (bool)(llvm::dyn_cast(Instr->getOperand(4)) + ->getZExtValue()); + } + void set_nonUniformIndex_val(bool val) { + Instr->setOperand(4, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 1), + llvm::APInt(1, (uint64_t)val))); + } }; /// This instruction loads a value from a constant buffer resource @@ -2363,7 +2440,8 @@ struct DxilInst_CBufferLoad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2381,8 +2459,15 @@ struct DxilInst_CBufferLoad { void set_byteOffset(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_alignment() const { return Instr->getOperand(3); } void set_alignment(llvm::Value *val) { Instr->setOperand(3, val); } - uint32_t get_alignment_val() const { return (uint32_t)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } - void set_alignment_val(uint32_t val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + uint32_t get_alignment_val() const { + return (uint32_t)(llvm::dyn_cast(Instr->getOperand(3)) + ->getZExtValue()); + } + void set_alignment_val(uint32_t val) { + Instr->setOperand(3, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; /// This instruction loads a value from a constant buffer resource @@ -2391,12 +2476,14 @@ struct DxilInst_CBufferLoadLegacy { // Construction and identification DxilInst_CBufferLoadLegacy(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CBufferLoadLegacy); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::CBufferLoadLegacy); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2424,7 +2511,8 @@ struct DxilInst_Sample { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2465,7 +2553,8 @@ struct DxilInst_Sample { void set_clamp(llvm::Value *val) { Instr->setOperand(10, val); } }; -/// This instruction samples a texture after applying the input bias to the mipmap level +/// This instruction samples a texture after applying the input bias to the +/// mipmap level struct DxilInst_SampleBias { llvm::Instruction *Instr; // Construction and identification @@ -2476,7 +2565,8 @@ struct DxilInst_SampleBias { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2531,7 +2621,8 @@ struct DxilInst_SampleLevel { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2572,7 +2663,8 @@ struct DxilInst_SampleLevel { void set_LOD(llvm::Value *val) { Instr->setOperand(10, val); } }; -/// This instruction samples a texture using a gradient to influence the way the sample location is calculated +/// This instruction samples a texture using a gradient to influence the way the +/// sample location is calculated struct DxilInst_SampleGrad { llvm::Instruction *Instr; // Construction and identification @@ -2583,7 +2675,8 @@ struct DxilInst_SampleGrad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (17 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (17 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2642,7 +2735,8 @@ struct DxilInst_SampleGrad { void set_clamp(llvm::Value *val) { Instr->setOperand(16, val); } }; -/// This instruction samples a texture and compares a single component against the specified comparison value +/// This instruction samples a texture and compares a single component against +/// the specified comparison value struct DxilInst_SampleCmp { llvm::Instruction *Instr; // Construction and identification @@ -2653,7 +2747,8 @@ struct DxilInst_SampleCmp { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2697,18 +2792,21 @@ struct DxilInst_SampleCmp { void set_clamp(llvm::Value *val) { Instr->setOperand(11, val); } }; -/// This instruction samples a texture and compares a single component against the specified comparison value +/// This instruction samples a texture and compares a single component against +/// the specified comparison value struct DxilInst_SampleCmpLevelZero { llvm::Instruction *Instr; // Construction and identification DxilInst_SampleCmpLevelZero(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpLevelZero); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::SampleCmpLevelZero); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2760,7 +2858,8 @@ struct DxilInst_TextureLoad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2779,8 +2878,12 @@ struct DxilInst_TextureLoad { // Accessors llvm::Value *get_srv() const { return Instr->getOperand(1); } void set_srv(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_mipLevelOrSampleCount() const { return Instr->getOperand(2); } - void set_mipLevelOrSampleCount(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_mipLevelOrSampleCount() const { + return Instr->getOperand(2); + } + void set_mipLevelOrSampleCount(llvm::Value *val) { + Instr->setOperand(2, val); + } llvm::Value *get_coord0() const { return Instr->getOperand(3); } void set_coord0(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_coord1() const { return Instr->getOperand(4); } @@ -2801,12 +2904,14 @@ struct DxilInst_TextureStore { // Construction and identification DxilInst_TextureStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureStore); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::TextureStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2855,7 +2960,8 @@ struct DxilInst_BufferLoad { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2886,7 +2992,8 @@ struct DxilInst_BufferStore { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2921,18 +3028,21 @@ struct DxilInst_BufferStore { void set_mask(llvm::Value *val) { Instr->setOperand(8, val); } }; -/// This instruction atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV +/// This instruction atomically increments/decrements the hidden 32-bit counter +/// stored with a Count or Append UAV struct DxilInst_BufferUpdateCounter { llvm::Instruction *Instr; // Construction and identification DxilInst_BufferUpdateCounter(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BufferUpdateCounter); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::BufferUpdateCounter); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2949,18 +3059,21 @@ struct DxilInst_BufferUpdateCounter { void set_inc(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource +/// This instruction determines whether all values from a Sample, Gather, or +/// Load operation accessed mapped tiles in a tiled resource struct DxilInst_CheckAccessFullyMapped { llvm::Instruction *Instr; // Construction and identification DxilInst_CheckAccessFullyMapped(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CheckAccessFullyMapped); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::CheckAccessFullyMapped); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -2980,12 +3093,14 @@ struct DxilInst_GetDimensions { // Construction and identification DxilInst_GetDimensions(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetDimensions); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::GetDimensions); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3002,18 +3117,21 @@ struct DxilInst_GetDimensions { void set_mipLevel(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction gathers the four texels that would be used in a bi-linear filtering operation +/// This instruction gathers the four texels that would be used in a bi-linear +/// filtering operation struct DxilInst_TextureGather { llvm::Instruction *Instr; // Construction and identification DxilInst_TextureGather(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGather); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::TextureGather); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3051,18 +3169,21 @@ struct DxilInst_TextureGather { void set_channel(llvm::Value *val) { Instr->setOperand(9, val); } }; -/// This instruction same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp +/// This instruction same as TextureGather, except this instrution performs +/// comparison on texels, similar to SampleCmp struct DxilInst_TextureGatherCmp { llvm::Instruction *Instr; // Construction and identification DxilInst_TextureGatherCmp(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGatherCmp); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::TextureGatherCmp); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3107,14 +3228,17 @@ struct DxilInst_TextureGatherCmp { struct DxilInst_Texture2DMSGetSamplePosition { llvm::Instruction *Instr; // Construction and identification - DxilInst_Texture2DMSGetSamplePosition(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_Texture2DMSGetSamplePosition(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Texture2DMSGetSamplePosition); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::Texture2DMSGetSamplePosition); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3135,14 +3259,17 @@ struct DxilInst_Texture2DMSGetSamplePosition { struct DxilInst_RenderTargetGetSamplePosition { llvm::Instruction *Instr; // Construction and identification - DxilInst_RenderTargetGetSamplePosition(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RenderTargetGetSamplePosition(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RenderTargetGetSamplePosition); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RenderTargetGetSamplePosition); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3160,14 +3287,17 @@ struct DxilInst_RenderTargetGetSamplePosition { struct DxilInst_RenderTargetGetSampleCount { llvm::Instruction *Instr; // Construction and identification - DxilInst_RenderTargetGetSampleCount(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RenderTargetGetSampleCount(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RenderTargetGetSampleCount); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RenderTargetGetSampleCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3185,7 +3315,8 @@ struct DxilInst_AtomicBinOp { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3220,12 +3351,14 @@ struct DxilInst_AtomicCompareExchange { // Construction and identification DxilInst_AtomicCompareExchange(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AtomicCompareExchange); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::AtomicCompareExchange); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3265,7 +3398,8 @@ struct DxilInst_Barrier { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3277,8 +3411,15 @@ struct DxilInst_Barrier { // Accessors llvm::Value *get_barrierMode() const { return Instr->getOperand(1); } void set_barrierMode(llvm::Value *val) { Instr->setOperand(1, val); } - int32_t get_barrierMode_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } - void set_barrierMode_val(int32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_barrierMode_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(1)) + ->getZExtValue()); + } + void set_barrierMode_val(int32_t val) { + Instr->setOperand(1, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; /// This instruction calculates the level of detail @@ -3287,12 +3428,14 @@ struct DxilInst_CalculateLOD { // Construction and identification DxilInst_CalculateLOD(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CalculateLOD); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::CalculateLOD); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (7 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3332,7 +3475,8 @@ struct DxilInst_Discard { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3352,12 +3496,14 @@ struct DxilInst_DerivCoarseX { // Construction and identification DxilInst_DerivCoarseX(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivCoarseX); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::DerivCoarseX); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3377,12 +3523,14 @@ struct DxilInst_DerivCoarseY { // Construction and identification DxilInst_DerivCoarseY(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivCoarseY); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::DerivCoarseY); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3407,7 +3555,8 @@ struct DxilInst_DerivFineX { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3432,7 +3581,8 @@ struct DxilInst_DerivFineY { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3457,7 +3607,8 @@ struct DxilInst_EvalSnapped { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3489,12 +3640,14 @@ struct DxilInst_EvalSampleIndex { // Construction and identification DxilInst_EvalSampleIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalSampleIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::EvalSampleIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3523,12 +3676,14 @@ struct DxilInst_EvalCentroid { // Construction and identification DxilInst_EvalCentroid(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalCentroid); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::EvalCentroid); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3559,7 +3714,8 @@ struct DxilInst_SampleIndex { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3577,25 +3733,29 @@ struct DxilInst_Coverage { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction returns underestimated coverage input from conservative rasterization in a pixel shader +/// This instruction returns underestimated coverage input from conservative +/// rasterization in a pixel shader struct DxilInst_InnerCoverage { llvm::Instruction *Instr; // Construction and identification DxilInst_InnerCoverage(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::InnerCoverage); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::InnerCoverage); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3613,7 +3773,8 @@ struct DxilInst_ThreadId { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3638,7 +3799,8 @@ struct DxilInst_GroupId { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3658,12 +3820,14 @@ struct DxilInst_ThreadIdInGroup { // Construction and identification DxilInst_ThreadIdInGroup(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ThreadIdInGroup); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::ThreadIdInGroup); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3677,18 +3841,22 @@ struct DxilInst_ThreadIdInGroup { void set_component(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction provides a flattened index for a given thread within a given group (SV_GroupIndex) +/// This instruction provides a flattened index for a given thread within a +/// given group (SV_GroupIndex) struct DxilInst_FlattenedThreadIdInGroup { llvm::Instruction *Instr; // Construction and identification - DxilInst_FlattenedThreadIdInGroup(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_FlattenedThreadIdInGroup(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FlattenedThreadIdInGroup); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::FlattenedThreadIdInGroup); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3706,7 +3874,8 @@ struct DxilInst_EmitStream { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3720,7 +3889,8 @@ struct DxilInst_EmitStream { void set_streamId(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction completes the current primitive topology at the specified stream +/// This instruction completes the current primitive topology at the specified +/// stream struct DxilInst_CutStream { llvm::Instruction *Instr; // Construction and identification @@ -3731,7 +3901,8 @@ struct DxilInst_CutStream { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3751,12 +3922,14 @@ struct DxilInst_EmitThenCutStream { // Construction and identification DxilInst_EmitThenCutStream(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EmitThenCutStream); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::EmitThenCutStream); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3776,12 +3949,14 @@ struct DxilInst_GSInstanceID { // Construction and identification DxilInst_GSInstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GSInstanceID); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::GSInstanceID); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3799,7 +3974,8 @@ struct DxilInst_MakeDouble { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3827,7 +4003,8 @@ struct DxilInst_SplitDouble { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3847,12 +4024,14 @@ struct DxilInst_LoadOutputControlPoint { // Construction and identification DxilInst_LoadOutputControlPoint(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadOutputControlPoint); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::LoadOutputControlPoint); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3881,12 +4060,14 @@ struct DxilInst_LoadPatchConstant { // Construction and identification DxilInst_LoadPatchConstant(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadPatchConstant); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::LoadPatchConstant); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3912,12 +4093,14 @@ struct DxilInst_DomainLocation { // Construction and identification DxilInst_DomainLocation(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DomainLocation); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::DomainLocation); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3929,8 +4112,15 @@ struct DxilInst_DomainLocation { // Accessors llvm::Value *get_component() const { return Instr->getOperand(1); } void set_component(llvm::Value *val) { Instr->setOperand(1, val); } - int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } - void set_component_val(int8_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_component_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(1)) + ->getZExtValue()); + } + void set_component_val(int8_t val) { + Instr->setOperand(1, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction StorePatchConstant @@ -3939,12 +4129,14 @@ struct DxilInst_StorePatchConstant { // Construction and identification DxilInst_StorePatchConstant(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StorePatchConstant); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::StorePatchConstant); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3973,12 +4165,14 @@ struct DxilInst_OutputControlPointID { // Construction and identification DxilInst_OutputControlPointID(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::OutputControlPointID); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::OutputControlPointID); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -3996,7 +4190,8 @@ struct DxilInst_PrimitiveID { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4009,12 +4204,14 @@ struct DxilInst_CycleCounterLegacy { // Construction and identification DxilInst_CycleCounterLegacy(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CycleCounterLegacy); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::CycleCounterLegacy); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4027,12 +4224,14 @@ struct DxilInst_WaveIsFirstLane { // Construction and identification DxilInst_WaveIsFirstLane(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveIsFirstLane); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveIsFirstLane); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4045,12 +4244,14 @@ struct DxilInst_WaveGetLaneIndex { // Construction and identification DxilInst_WaveGetLaneIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveGetLaneIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveGetLaneIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4063,12 +4264,14 @@ struct DxilInst_WaveGetLaneCount { // Construction and identification DxilInst_WaveGetLaneCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveGetLaneCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveGetLaneCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4086,7 +4289,8 @@ struct DxilInst_WaveAnyTrue { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4111,7 +4315,8 @@ struct DxilInst_WaveAllTrue { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4131,12 +4336,14 @@ struct DxilInst_WaveActiveAllEqual { // Construction and identification DxilInst_WaveActiveAllEqual(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveAllEqual); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveActiveAllEqual); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4150,18 +4357,21 @@ struct DxilInst_WaveActiveAllEqual { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns a struct with a bit set for each lane where the condition is true +/// This instruction returns a struct with a bit set for each lane where the +/// condition is true struct DxilInst_WaveActiveBallot { llvm::Instruction *Instr; // Construction and identification DxilInst_WaveActiveBallot(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveBallot); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveActiveBallot); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4181,12 +4391,14 @@ struct DxilInst_WaveReadLaneAt { // Construction and identification DxilInst_WaveReadLaneAt(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveReadLaneAt); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveReadLaneAt); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4209,12 +4421,14 @@ struct DxilInst_WaveReadLaneFirst { // Construction and identification DxilInst_WaveReadLaneFirst(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveReadLaneFirst); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveReadLaneFirst); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4234,12 +4448,14 @@ struct DxilInst_WaveActiveOp { // Construction and identification DxilInst_WaveActiveOp(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveOp); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveActiveOp); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4255,12 +4471,26 @@ struct DxilInst_WaveActiveOp { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_op_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_op_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } llvm::Value *get_sop() const { return Instr->getOperand(3); } void set_sop(llvm::Value *val) { Instr->setOperand(3, val); } - int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } - void set_sop_val(int8_t val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_sop_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(3)) + ->getZExtValue()); + } + void set_sop_val(int8_t val) { + Instr->setOperand(3, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction returns the result of the operation across all lanes @@ -4269,12 +4499,14 @@ struct DxilInst_WaveActiveBit { // Construction and identification DxilInst_WaveActiveBit(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveBit); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveActiveBit); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4289,8 +4521,15 @@ struct DxilInst_WaveActiveBit { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_op_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_op_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction returns the result of the operation on prior lanes @@ -4299,12 +4538,14 @@ struct DxilInst_WavePrefixOp { // Construction and identification DxilInst_WavePrefixOp(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WavePrefixOp); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WavePrefixOp); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4320,12 +4561,26 @@ struct DxilInst_WavePrefixOp { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_op_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_op_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } llvm::Value *get_sop() const { return Instr->getOperand(3); } void set_sop(llvm::Value *val) { Instr->setOperand(3, val); } - int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } - void set_sop_val(int8_t val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_sop_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(3)) + ->getZExtValue()); + } + void set_sop_val(int8_t val) { + Instr->setOperand(3, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction reads from a lane in the quad @@ -4334,12 +4589,14 @@ struct DxilInst_QuadReadLaneAt { // Construction and identification DxilInst_QuadReadLaneAt(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::QuadReadLaneAt); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::QuadReadLaneAt); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4367,7 +4624,8 @@ struct DxilInst_QuadOp { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4382,8 +4640,15 @@ struct DxilInst_QuadOp { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_op_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_op_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction bitcast between different sizes @@ -4392,12 +4657,14 @@ struct DxilInst_BitcastI16toF16 { // Construction and identification DxilInst_BitcastI16toF16(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI16toF16); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::BitcastI16toF16); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4417,12 +4684,14 @@ struct DxilInst_BitcastF16toI16 { // Construction and identification DxilInst_BitcastF16toI16(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF16toI16); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::BitcastF16toI16); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4442,12 +4711,14 @@ struct DxilInst_BitcastI32toF32 { // Construction and identification DxilInst_BitcastI32toF32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI32toF32); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::BitcastI32toF32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4467,12 +4738,14 @@ struct DxilInst_BitcastF32toI32 { // Construction and identification DxilInst_BitcastF32toI32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF32toI32); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::BitcastF32toI32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4492,12 +4765,14 @@ struct DxilInst_BitcastI64toF64 { // Construction and identification DxilInst_BitcastI64toF64(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI64toF64); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::BitcastI64toF64); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4517,12 +4792,14 @@ struct DxilInst_BitcastF64toI64 { // Construction and identification DxilInst_BitcastF64toI64(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF64toI64); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::BitcastF64toI64); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4536,18 +4813,21 @@ struct DxilInst_BitcastF64toI64 { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision) +/// This instruction legacy fuction to convert float (f32) to half (f16) (this +/// is not related to min-precision) struct DxilInst_LegacyF32ToF16 { llvm::Instruction *Instr; // Construction and identification DxilInst_LegacyF32ToF16(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyF32ToF16); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::LegacyF32ToF16); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4561,18 +4841,21 @@ struct DxilInst_LegacyF32ToF16 { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision) +/// This instruction legacy fuction to convert half (f16) to float (f32) (this +/// is not related to min-precision) struct DxilInst_LegacyF16ToF32 { llvm::Instruction *Instr; // Construction and identification DxilInst_LegacyF16ToF32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyF16ToF32); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::LegacyF16ToF32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4592,12 +4875,14 @@ struct DxilInst_LegacyDoubleToFloat { // Construction and identification DxilInst_LegacyDoubleToFloat(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToFloat); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::LegacyDoubleToFloat); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4617,12 +4902,14 @@ struct DxilInst_LegacyDoubleToSInt32 { // Construction and identification DxilInst_LegacyDoubleToSInt32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToSInt32); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::LegacyDoubleToSInt32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4642,12 +4929,14 @@ struct DxilInst_LegacyDoubleToUInt32 { // Construction and identification DxilInst_LegacyDoubleToUInt32(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToUInt32); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::LegacyDoubleToUInt32); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4667,12 +4956,14 @@ struct DxilInst_WaveAllBitCount { // Construction and identification DxilInst_WaveAllBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveAllBitCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveAllBitCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4692,12 +4983,14 @@ struct DxilInst_WavePrefixBitCount { // Construction and identification DxilInst_WavePrefixBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WavePrefixBitCount); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WavePrefixBitCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4717,12 +5010,14 @@ struct DxilInst_AttributeAtVertex { // Construction and identification DxilInst_AttributeAtVertex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AttributeAtVertex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::AttributeAtVertex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4756,7 +5051,8 @@ struct DxilInst_ViewID { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4769,12 +5065,14 @@ struct DxilInst_RawBufferLoad { // Construction and identification DxilInst_RawBufferLoad(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferLoad); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::RawBufferLoad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4796,12 +5094,26 @@ struct DxilInst_RawBufferLoad { void set_elementOffset(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_mask() const { return Instr->getOperand(4); } void set_mask(llvm::Value *val) { Instr->setOperand(4, val); } - int8_t get_mask_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(4))->getZExtValue()); } - void set_mask_val(int8_t val) { Instr->setOperand(4, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_mask_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(4)) + ->getZExtValue()); + } + void set_mask_val(int8_t val) { + Instr->setOperand(4, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } llvm::Value *get_alignment() const { return Instr->getOperand(5); } void set_alignment(llvm::Value *val) { Instr->setOperand(5, val); } - int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(5))->getZExtValue()); } - void set_alignment_val(int32_t val) { Instr->setOperand(5, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_alignment_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(5)) + ->getZExtValue()); + } + void set_alignment_val(int32_t val) { + Instr->setOperand(5, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; /// This instruction writes to a RWByteAddressBuffer or RWStructuredBuffer @@ -4810,12 +5122,14 @@ struct DxilInst_RawBufferStore { // Construction and identification DxilInst_RawBufferStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferStore); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::RawBufferStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4849,15 +5163,30 @@ struct DxilInst_RawBufferStore { void set_value3(llvm::Value *val) { Instr->setOperand(7, val); } llvm::Value *get_mask() const { return Instr->getOperand(8); } void set_mask(llvm::Value *val) { Instr->setOperand(8, val); } - int8_t get_mask_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(8))->getZExtValue()); } - void set_mask_val(int8_t val) { Instr->setOperand(8, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_mask_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(8)) + ->getZExtValue()); + } + void set_mask_val(int8_t val) { + Instr->setOperand(8, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } llvm::Value *get_alignment() const { return Instr->getOperand(9); } void set_alignment(llvm::Value *val) { Instr->setOperand(9, val); } - int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(9))->getZExtValue()); } - void set_alignment_val(int32_t val) { Instr->setOperand(9, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_alignment_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(9)) + ->getZExtValue()); + } + void set_alignment_val(int32_t val) { + Instr->setOperand(9, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; -/// This instruction The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure +/// This instruction The user-provided InstanceID on the bottom-level +/// acceleration structure instance within the top-level structure struct DxilInst_InstanceID { llvm::Instruction *Instr; // Construction and identification @@ -4868,32 +5197,39 @@ struct DxilInst_InstanceID { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction The autogenerated index of the current instance in the top-level structure +/// This instruction The autogenerated index of the current instance in the +/// top-level structure struct DxilInst_InstanceIndex { llvm::Instruction *Instr; // Construction and identification DxilInst_InstanceIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::InstanceIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::InstanceIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction Returns the value passed as HitKind in ReportIntersection(). If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE. +/// This instruction Returns the value passed as HitKind in +/// ReportIntersection(). If intersection was reported by fixed-function +/// triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE +/// or HIT_KIND_TRIANGLE_BACK_FACE. struct DxilInst_HitKind { llvm::Instruction *Instr; // Construction and identification @@ -4904,7 +5240,8 @@ struct DxilInst_HitKind { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4922,7 +5259,8 @@ struct DxilInst_RayFlags { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4935,12 +5273,14 @@ struct DxilInst_DispatchRaysIndex { // Construction and identification DxilInst_DispatchRaysIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DispatchRaysIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::DispatchRaysIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4954,18 +5294,22 @@ struct DxilInst_DispatchRaysIndex { void set_col(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call. +/// This instruction The Width and Height values from the +/// D3D12_DISPATCH_RAYS_DESC structure provided to the originating +/// DispatchRays() call. struct DxilInst_DispatchRaysDimensions { llvm::Instruction *Instr; // Construction and identification DxilInst_DispatchRaysDimensions(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DispatchRaysDimensions); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::DispatchRaysDimensions); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -4985,12 +5329,14 @@ struct DxilInst_WorldRayOrigin { // Construction and identification DxilInst_WorldRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WorldRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WorldRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5010,12 +5356,14 @@ struct DxilInst_WorldRayDirection { // Construction and identification DxilInst_WorldRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WorldRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WorldRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5035,12 +5383,14 @@ struct DxilInst_ObjectRayOrigin { // Construction and identification DxilInst_ObjectRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ObjectRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::ObjectRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5060,12 +5410,14 @@ struct DxilInst_ObjectRayDirection { // Construction and identification DxilInst_ObjectRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ObjectRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::ObjectRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5085,12 +5437,14 @@ struct DxilInst_ObjectToWorld { // Construction and identification DxilInst_ObjectToWorld(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ObjectToWorld); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::ObjectToWorld); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5113,12 +5467,14 @@ struct DxilInst_WorldToObject { // Construction and identification DxilInst_WorldToObject(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WorldToObject); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WorldToObject); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5135,7 +5491,8 @@ struct DxilInst_WorldToObject { void set_col(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction float representing the parametric starting point for the ray. +/// This instruction float representing the parametric starting point for the +/// ray. struct DxilInst_RayTMin { llvm::Instruction *Instr; // Construction and identification @@ -5146,14 +5503,16 @@ struct DxilInst_RayTMin { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction float representing the current parametric ending point for the ray +/// This instruction float representing the current parametric ending point for +/// the ray struct DxilInst_RayTCurrent { llvm::Instruction *Instr; // Construction and identification @@ -5164,14 +5523,16 @@ struct DxilInst_RayTCurrent { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction Used in an any hit shader to reject an intersection and terminate the shader +/// This instruction Used in an any hit shader to reject an intersection and +/// terminate the shader struct DxilInst_IgnoreHit { llvm::Instruction *Instr; // Construction and identification @@ -5182,25 +5543,30 @@ struct DxilInst_IgnoreHit { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far +/// This instruction Used in an any hit shader to abort the ray query and the +/// intersection shader (if any). The current hit is committed and execution +/// passes to the closest hit shader with the closest hit recorded so far struct DxilInst_AcceptHitAndEndSearch { llvm::Instruction *Instr; // Construction and identification DxilInst_AcceptHitAndEndSearch(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AcceptHitAndEndSearch); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::AcceptHitAndEndSearch); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5218,7 +5584,8 @@ struct DxilInst_TraceRay { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (16 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (16 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5242,16 +5609,32 @@ struct DxilInst_TraceRay { arg_payload = 15, }; // Accessors - llvm::Value *get_AccelerationStructure() const { return Instr->getOperand(1); } - void set_AccelerationStructure(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_AccelerationStructure() const { + return Instr->getOperand(1); + } + void set_AccelerationStructure(llvm::Value *val) { + Instr->setOperand(1, val); + } llvm::Value *get_RayFlags() const { return Instr->getOperand(2); } void set_RayFlags(llvm::Value *val) { Instr->setOperand(2, val); } - llvm::Value *get_InstanceInclusionMask() const { return Instr->getOperand(3); } - void set_InstanceInclusionMask(llvm::Value *val) { Instr->setOperand(3, val); } - llvm::Value *get_RayContributionToHitGroupIndex() const { return Instr->getOperand(4); } - void set_RayContributionToHitGroupIndex(llvm::Value *val) { Instr->setOperand(4, val); } - llvm::Value *get_MultiplierForGeometryContributionToShaderIndex() const { return Instr->getOperand(5); } - void set_MultiplierForGeometryContributionToShaderIndex(llvm::Value *val) { Instr->setOperand(5, val); } + llvm::Value *get_InstanceInclusionMask() const { + return Instr->getOperand(3); + } + void set_InstanceInclusionMask(llvm::Value *val) { + Instr->setOperand(3, val); + } + llvm::Value *get_RayContributionToHitGroupIndex() const { + return Instr->getOperand(4); + } + void set_RayContributionToHitGroupIndex(llvm::Value *val) { + Instr->setOperand(4, val); + } + llvm::Value *get_MultiplierForGeometryContributionToShaderIndex() const { + return Instr->getOperand(5); + } + void set_MultiplierForGeometryContributionToShaderIndex(llvm::Value *val) { + Instr->setOperand(5, val); + } llvm::Value *get_MissShaderIndex() const { return Instr->getOperand(6); } void set_MissShaderIndex(llvm::Value *val) { Instr->setOperand(6, val); } llvm::Value *get_Origin_X() const { return Instr->getOperand(7); } @@ -5285,7 +5668,8 @@ struct DxilInst_ReportHit { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5305,7 +5689,8 @@ struct DxilInst_ReportHit { void set_Attributes(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction Call a shader in the callable shader table supplied through the DispatchRays() API +/// This instruction Call a shader in the callable shader table supplied through +/// the DispatchRays() API struct DxilInst_CallShader { llvm::Instruction *Instr; // Construction and identification @@ -5316,7 +5701,8 @@ struct DxilInst_CallShader { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5339,12 +5725,14 @@ struct DxilInst_CreateHandleForLib { // Construction and identification DxilInst_CreateHandleForLib(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandleForLib); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::CreateHandleForLib); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5364,12 +5752,14 @@ struct DxilInst_PrimitiveIndex { // Construction and identification DxilInst_PrimitiveIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::PrimitiveIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::PrimitiveIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5387,7 +5777,8 @@ struct DxilInst_Dot2AddHalf { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5413,18 +5804,21 @@ struct DxilInst_Dot2AddHalf { void set_by(llvm::Value *val) { Instr->setOperand(5, val); } }; -/// This instruction signed dot product of 4 x i8 vectors packed into i32, with accumulate to i32 +/// This instruction signed dot product of 4 x i8 vectors packed into i32, with +/// accumulate to i32 struct DxilInst_Dot4AddI8Packed { llvm::Instruction *Instr; // Construction and identification DxilInst_Dot4AddI8Packed(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot4AddI8Packed); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::Dot4AddI8Packed); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5444,18 +5838,21 @@ struct DxilInst_Dot4AddI8Packed { void set_b(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction unsigned dot product of 4 x u8 vectors packed into i32, with accumulate to i32 +/// This instruction unsigned dot product of 4 x u8 vectors packed into i32, +/// with accumulate to i32 struct DxilInst_Dot4AddU8Packed { llvm::Instruction *Instr; // Construction and identification DxilInst_Dot4AddU8Packed(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot4AddU8Packed); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::Dot4AddU8Packed); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5475,7 +5872,8 @@ struct DxilInst_Dot4AddU8Packed { void set_b(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns the bitmask of active lanes that have the same value +/// This instruction returns the bitmask of active lanes that have the same +/// value struct DxilInst_WaveMatch { llvm::Instruction *Instr; // Construction and identification @@ -5486,7 +5884,8 @@ struct DxilInst_WaveMatch { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5500,18 +5899,21 @@ struct DxilInst_WaveMatch { void set_value(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns the result of the operation on groups of lanes identified by a bitmask +/// This instruction returns the result of the operation on groups of lanes +/// identified by a bitmask struct DxilInst_WaveMultiPrefixOp { llvm::Instruction *Instr; // Construction and identification DxilInst_WaveMultiPrefixOp(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveMultiPrefixOp); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::WaveMultiPrefixOp); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (8 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (8 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5539,26 +5941,43 @@ struct DxilInst_WaveMultiPrefixOp { void set_mask3(llvm::Value *val) { Instr->setOperand(5, val); } llvm::Value *get_op() const { return Instr->getOperand(6); } void set_op(llvm::Value *val) { Instr->setOperand(6, val); } - int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(6))->getZExtValue()); } - void set_op_val(int8_t val) { Instr->setOperand(6, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_op_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(6)) + ->getZExtValue()); + } + void set_op_val(int8_t val) { + Instr->setOperand(6, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } llvm::Value *get_sop() const { return Instr->getOperand(7); } void set_sop(llvm::Value *val) { Instr->setOperand(7, val); } - int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(7))->getZExtValue()); } - void set_sop_val(int8_t val) { Instr->setOperand(7, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_sop_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(7)) + ->getZExtValue()); + } + void set_sop_val(int8_t val) { + Instr->setOperand(7, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; -/// This instruction returns the count of bits set to 1 on groups of lanes identified by a bitmask +/// This instruction returns the count of bits set to 1 on groups of lanes +/// identified by a bitmask struct DxilInst_WaveMultiPrefixBitCount { llvm::Instruction *Instr; // Construction and identification DxilInst_WaveMultiPrefixBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveMultiPrefixBitCount); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::WaveMultiPrefixBitCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5590,12 +6009,14 @@ struct DxilInst_SetMeshOutputCounts { // Construction and identification DxilInst_SetMeshOutputCounts(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SetMeshOutputCounts); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::SetMeshOutputCounts); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5623,7 +6044,8 @@ struct DxilInst_EmitIndices { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5652,12 +6074,14 @@ struct DxilInst_GetMeshPayload { // Construction and identification DxilInst_GetMeshPayload(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetMeshPayload); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::GetMeshPayload); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5670,12 +6094,14 @@ struct DxilInst_StoreVertexOutput { // Construction and identification DxilInst_StoreVertexOutput(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StoreVertexOutput); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::StoreVertexOutput); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5707,12 +6133,14 @@ struct DxilInst_StorePrimitiveOutput { // Construction and identification DxilInst_StorePrimitiveOutput(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StorePrimitiveOutput); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::StorePrimitiveOutput); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5744,12 +6172,14 @@ struct DxilInst_DispatchMesh { // Construction and identification DxilInst_DispatchMesh(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DispatchMesh); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::DispatchMesh); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5778,12 +6208,14 @@ struct DxilInst_WriteSamplerFeedback { // Construction and identification DxilInst_WriteSamplerFeedback(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WriteSamplerFeedback); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::WriteSamplerFeedback); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5818,18 +6250,22 @@ struct DxilInst_WriteSamplerFeedback { void set_clamp(llvm::Value *val) { Instr->setOperand(8, val); } }; -/// This instruction updates a feedback texture for a sampling operation with a bias on the mipmap level +/// This instruction updates a feedback texture for a sampling operation with a +/// bias on the mipmap level struct DxilInst_WriteSamplerFeedbackBias { llvm::Instruction *Instr; // Construction and identification - DxilInst_WriteSamplerFeedbackBias(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_WriteSamplerFeedbackBias(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WriteSamplerFeedbackBias); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::WriteSamplerFeedbackBias); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (10 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5867,18 +6303,22 @@ struct DxilInst_WriteSamplerFeedbackBias { void set_clamp(llvm::Value *val) { Instr->setOperand(9, val); } }; -/// This instruction updates a feedback texture for a sampling operation with a mipmap-level offset +/// This instruction updates a feedback texture for a sampling operation with a +/// mipmap-level offset struct DxilInst_WriteSamplerFeedbackLevel { llvm::Instruction *Instr; // Construction and identification - DxilInst_WriteSamplerFeedbackLevel(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_WriteSamplerFeedbackLevel(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WriteSamplerFeedbackLevel); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::WriteSamplerFeedbackLevel); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5913,18 +6353,22 @@ struct DxilInst_WriteSamplerFeedbackLevel { void set_lod(llvm::Value *val) { Instr->setOperand(8, val); } }; -/// This instruction updates a feedback texture for a sampling operation with explicit gradients +/// This instruction updates a feedback texture for a sampling operation with +/// explicit gradients struct DxilInst_WriteSamplerFeedbackGrad { llvm::Instruction *Instr; // Construction and identification - DxilInst_WriteSamplerFeedbackGrad(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_WriteSamplerFeedbackGrad(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WriteSamplerFeedbackGrad); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::WriteSamplerFeedbackGrad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (15 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (15 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -5983,12 +6427,14 @@ struct DxilInst_AllocateRayQuery { // Construction and identification DxilInst_AllocateRayQuery(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AllocateRayQuery); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::AllocateRayQuery); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6000,8 +6446,15 @@ struct DxilInst_AllocateRayQuery { // Accessors llvm::Value *get_constRayFlags() const { return Instr->getOperand(1); } void set_constRayFlags(llvm::Value *val) { Instr->setOperand(1, val); } - uint32_t get_constRayFlags_val() const { return (uint32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } - void set_constRayFlags_val(uint32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + uint32_t get_constRayFlags_val() const { + return (uint32_t)(llvm::dyn_cast(Instr->getOperand(1)) + ->getZExtValue()); + } + void set_constRayFlags_val(uint32_t val) { + Instr->setOperand(1, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; /// This instruction initializes RayQuery for raytrace @@ -6010,12 +6463,14 @@ struct DxilInst_RayQuery_TraceRayInline { // Construction and identification DxilInst_RayQuery_TraceRayInline(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_TraceRayInline); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_TraceRayInline); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6038,12 +6493,20 @@ struct DxilInst_RayQuery_TraceRayInline { // Accessors llvm::Value *get_rayQueryHandle() const { return Instr->getOperand(1); } void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_accelerationStructure() const { return Instr->getOperand(2); } - void set_accelerationStructure(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_accelerationStructure() const { + return Instr->getOperand(2); + } + void set_accelerationStructure(llvm::Value *val) { + Instr->setOperand(2, val); + } llvm::Value *get_rayFlags() const { return Instr->getOperand(3); } void set_rayFlags(llvm::Value *val) { Instr->setOperand(3, val); } - llvm::Value *get_instanceInclusionMask() const { return Instr->getOperand(4); } - void set_instanceInclusionMask(llvm::Value *val) { Instr->setOperand(4, val); } + llvm::Value *get_instanceInclusionMask() const { + return Instr->getOperand(4); + } + void set_instanceInclusionMask(llvm::Value *val) { + Instr->setOperand(4, val); + } llvm::Value *get_origin_X() const { return Instr->getOperand(5); } void set_origin_X(llvm::Value *val) { Instr->setOperand(5, val); } llvm::Value *get_origin_Y() const { return Instr->getOperand(6); } @@ -6068,12 +6531,14 @@ struct DxilInst_RayQuery_Proceed { // Construction and identification DxilInst_RayQuery_Proceed(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_Proceed); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::RayQuery_Proceed); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6093,12 +6558,14 @@ struct DxilInst_RayQuery_Abort { // Construction and identification DxilInst_RayQuery_Abort(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_Abort); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::RayQuery_Abort); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6116,14 +6583,17 @@ struct DxilInst_RayQuery_Abort { struct DxilInst_RayQuery_CommitNonOpaqueTriangleHit { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommitNonOpaqueTriangleHit(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommitNonOpaqueTriangleHit(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommitNonOpaqueTriangleHit); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommitNonOpaqueTriangleHit); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6141,14 +6611,17 @@ struct DxilInst_RayQuery_CommitNonOpaqueTriangleHit { struct DxilInst_RayQuery_CommitProceduralPrimitiveHit { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommitProceduralPrimitiveHit(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommitProceduralPrimitiveHit(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommitProceduralPrimitiveHit); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommitProceduralPrimitiveHit); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6165,18 +6638,22 @@ struct DxilInst_RayQuery_CommitProceduralPrimitiveHit { void set_t(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction returns uint status (COMMITTED_STATUS) of the committed hit in a ray query +/// This instruction returns uint status (COMMITTED_STATUS) of the committed hit +/// in a ray query struct DxilInst_RayQuery_CommittedStatus { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedStatus(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedStatus(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedStatus); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedStatus); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6190,18 +6667,21 @@ struct DxilInst_RayQuery_CommittedStatus { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns uint candidate type (CANDIDATE_TYPE) of the current hit candidate in a ray query, after Proceed() has returned true +/// This instruction returns uint candidate type (CANDIDATE_TYPE) of the current +/// hit candidate in a ray query, after Proceed() has returned true struct DxilInst_RayQuery_CandidateType { llvm::Instruction *Instr; // Construction and identification DxilInst_RayQuery_CandidateType(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateType); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateType); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6215,18 +6695,22 @@ struct DxilInst_RayQuery_CandidateType { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns matrix for transforming from object-space to world-space for a candidate hit. +/// This instruction returns matrix for transforming from object-space to +/// world-space for a candidate hit. struct DxilInst_RayQuery_CandidateObjectToWorld3x4 { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateObjectToWorld3x4(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateObjectToWorld3x4(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectToWorld3x4); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectToWorld3x4); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6246,18 +6730,22 @@ struct DxilInst_RayQuery_CandidateObjectToWorld3x4 { void set_col(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns matrix for transforming from world-space to object-space for a candidate hit. +/// This instruction returns matrix for transforming from world-space to +/// object-space for a candidate hit. struct DxilInst_RayQuery_CandidateWorldToObject3x4 { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateWorldToObject3x4(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateWorldToObject3x4(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateWorldToObject3x4); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateWorldToObject3x4); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6277,18 +6765,22 @@ struct DxilInst_RayQuery_CandidateWorldToObject3x4 { void set_col(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns matrix for transforming from object-space to world-space for a Committed hit. +/// This instruction returns matrix for transforming from object-space to +/// world-space for a Committed hit. struct DxilInst_RayQuery_CommittedObjectToWorld3x4 { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedObjectToWorld3x4(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedObjectToWorld3x4(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectToWorld3x4); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectToWorld3x4); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6308,18 +6800,22 @@ struct DxilInst_RayQuery_CommittedObjectToWorld3x4 { void set_col(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns matrix for transforming from world-space to object-space for a Committed hit. +/// This instruction returns matrix for transforming from world-space to +/// object-space for a Committed hit. struct DxilInst_RayQuery_CommittedWorldToObject3x4 { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedWorldToObject3x4(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedWorldToObject3x4(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedWorldToObject3x4); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedWorldToObject3x4); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6339,18 +6835,24 @@ struct DxilInst_RayQuery_CommittedWorldToObject3x4 { void set_col(llvm::Value *val) { Instr->setOperand(3, val); } }; -/// This instruction returns if current candidate procedural primitive is non opaque +/// This instruction returns if current candidate procedural primitive is non +/// opaque struct DxilInst_RayQuery_CandidateProceduralPrimitiveNonOpaque { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateProceduralPrimitiveNonOpaque(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateProceduralPrimitiveNonOpaque( + llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateProceduralPrimitiveNonOpaque); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, + hlsl::OP::OpCode::RayQuery_CandidateProceduralPrimitiveNonOpaque); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6368,14 +6870,17 @@ struct DxilInst_RayQuery_CandidateProceduralPrimitiveNonOpaque { struct DxilInst_RayQuery_CandidateTriangleFrontFace { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateTriangleFrontFace(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateTriangleFrontFace(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleFrontFace); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleFrontFace); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6393,14 +6898,17 @@ struct DxilInst_RayQuery_CandidateTriangleFrontFace { struct DxilInst_RayQuery_CommittedTriangleFrontFace { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedTriangleFrontFace(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedTriangleFrontFace(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedTriangleFrontFace); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedTriangleFrontFace); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6418,14 +6926,17 @@ struct DxilInst_RayQuery_CommittedTriangleFrontFace { struct DxilInst_RayQuery_CandidateTriangleBarycentrics { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateTriangleBarycentrics(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateTriangleBarycentrics(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleBarycentrics); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleBarycentrics); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6440,22 +6951,32 @@ struct DxilInst_RayQuery_CandidateTriangleBarycentrics { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_component_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction returns committed triangle hit barycentrics struct DxilInst_RayQuery_CommittedTriangleBarycentrics { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedTriangleBarycentrics(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedTriangleBarycentrics(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedTriangleBarycentrics); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedTriangleBarycentrics); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6470,8 +6991,15 @@ struct DxilInst_RayQuery_CommittedTriangleBarycentrics { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_component_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction returns ray flags @@ -6480,12 +7008,14 @@ struct DxilInst_RayQuery_RayFlags { // Construction and identification DxilInst_RayQuery_RayFlags(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_RayFlags); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::RayQuery_RayFlags); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6505,12 +7035,14 @@ struct DxilInst_RayQuery_WorldRayOrigin { // Construction and identification DxilInst_RayQuery_WorldRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_WorldRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_WorldRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6525,22 +7057,32 @@ struct DxilInst_RayQuery_WorldRayOrigin { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_component_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction returns world ray direction struct DxilInst_RayQuery_WorldRayDirection { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_WorldRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_WorldRayDirection(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_WorldRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_WorldRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6555,22 +7097,32 @@ struct DxilInst_RayQuery_WorldRayDirection { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_component_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; -/// This instruction returns float representing the parametric starting point for the ray. +/// This instruction returns float representing the parametric starting point +/// for the ray. struct DxilInst_RayQuery_RayTMin { llvm::Instruction *Instr; // Construction and identification DxilInst_RayQuery_RayTMin(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_RayTMin); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::RayQuery_RayTMin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6584,18 +7136,22 @@ struct DxilInst_RayQuery_RayTMin { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns float representing the parametric point on the ray for the current candidate triangle hit. +/// This instruction returns float representing the parametric point on the ray +/// for the current candidate triangle hit. struct DxilInst_RayQuery_CandidateTriangleRayT { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateTriangleRayT(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateTriangleRayT(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleRayT); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateTriangleRayT); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6609,18 +7165,21 @@ struct DxilInst_RayQuery_CandidateTriangleRayT { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns float representing the parametric point on the ray for the current committed hit. +/// This instruction returns float representing the parametric point on the ray +/// for the current committed hit. struct DxilInst_RayQuery_CommittedRayT { llvm::Instruction *Instr; // Construction and identification DxilInst_RayQuery_CommittedRayT(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedRayT); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedRayT); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6638,14 +7197,17 @@ struct DxilInst_RayQuery_CommittedRayT { struct DxilInst_RayQuery_CandidateInstanceIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateInstanceIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateInstanceIndex(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceIndex); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6663,14 +7225,17 @@ struct DxilInst_RayQuery_CandidateInstanceIndex { struct DxilInst_RayQuery_CandidateInstanceID { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateInstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateInstanceID(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceID); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceID); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6688,14 +7253,17 @@ struct DxilInst_RayQuery_CandidateInstanceID { struct DxilInst_RayQuery_CandidateGeometryIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateGeometryIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateGeometryIndex(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateGeometryIndex); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateGeometryIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6713,14 +7281,17 @@ struct DxilInst_RayQuery_CandidateGeometryIndex { struct DxilInst_RayQuery_CandidatePrimitiveIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidatePrimitiveIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidatePrimitiveIndex(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidatePrimitiveIndex); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidatePrimitiveIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6738,14 +7309,17 @@ struct DxilInst_RayQuery_CandidatePrimitiveIndex { struct DxilInst_RayQuery_CandidateObjectRayOrigin { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateObjectRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateObjectRayOrigin(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6760,22 +7334,32 @@ struct DxilInst_RayQuery_CandidateObjectRayOrigin { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_component_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction returns candidate object ray direction struct DxilInst_RayQuery_CandidateObjectRayDirection { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateObjectRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateObjectRayDirection(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CandidateObjectRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6790,22 +7374,32 @@ struct DxilInst_RayQuery_CandidateObjectRayDirection { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_component_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction returns committed hit instance index struct DxilInst_RayQuery_CommittedInstanceIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedInstanceIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedInstanceIndex(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceIndex); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6823,14 +7417,17 @@ struct DxilInst_RayQuery_CommittedInstanceIndex { struct DxilInst_RayQuery_CommittedInstanceID { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedInstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedInstanceID(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceID); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceID); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6848,14 +7445,17 @@ struct DxilInst_RayQuery_CommittedInstanceID { struct DxilInst_RayQuery_CommittedGeometryIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedGeometryIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedGeometryIndex(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedGeometryIndex); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedGeometryIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6873,14 +7473,17 @@ struct DxilInst_RayQuery_CommittedGeometryIndex { struct DxilInst_RayQuery_CommittedPrimitiveIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedPrimitiveIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedPrimitiveIndex(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedPrimitiveIndex); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedPrimitiveIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6898,14 +7501,17 @@ struct DxilInst_RayQuery_CommittedPrimitiveIndex { struct DxilInst_RayQuery_CommittedObjectRayOrigin { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedObjectRayOrigin(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedObjectRayOrigin(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectRayOrigin); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectRayOrigin); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6920,22 +7526,32 @@ struct DxilInst_RayQuery_CommittedObjectRayOrigin { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_component_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; /// This instruction returns committed object ray direction struct DxilInst_RayQuery_CommittedObjectRayDirection { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedObjectRayDirection(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedObjectRayDirection(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectRayDirection); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RayQuery_CommittedObjectRayDirection); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6950,22 +7566,32 @@ struct DxilInst_RayQuery_CommittedObjectRayDirection { void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_component() const { return Instr->getOperand(2); } void set_component(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_component_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; -/// This instruction The autogenerated index of the current geometry in the bottom-level structure +/// This instruction The autogenerated index of the current geometry in the +/// bottom-level structure struct DxilInst_GeometryIndex { llvm::Instruction *Instr; // Construction and identification DxilInst_GeometryIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GeometryIndex); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::GeometryIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -6976,14 +7602,19 @@ struct DxilInst_GeometryIndex { struct DxilInst_RayQuery_CandidateInstanceContributionToHitGroupIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CandidateInstanceContributionToHitGroupIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CandidateInstanceContributionToHitGroupIndex( + llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CandidateInstanceContributionToHitGroupIndex); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode:: + RayQuery_CandidateInstanceContributionToHitGroupIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7001,14 +7632,19 @@ struct DxilInst_RayQuery_CandidateInstanceContributionToHitGroupIndex { struct DxilInst_RayQuery_CommittedInstanceContributionToHitGroupIndex { llvm::Instruction *Instr; // Construction and identification - DxilInst_RayQuery_CommittedInstanceContributionToHitGroupIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_RayQuery_CommittedInstanceContributionToHitGroupIndex( + llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RayQuery_CommittedInstanceContributionToHitGroupIndex); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode:: + RayQuery_CommittedInstanceContributionToHitGroupIndex); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7028,12 +7664,14 @@ struct DxilInst_AnnotateHandle { // Construction and identification DxilInst_AnnotateHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AnnotateHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::AnnotateHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7056,12 +7694,14 @@ struct DxilInst_CreateHandleFromBinding { // Construction and identification DxilInst_CreateHandleFromBinding(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandleFromBinding); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::CreateHandleFromBinding); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7079,8 +7719,15 @@ struct DxilInst_CreateHandleFromBinding { void set_index(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_nonUniformIndex() const { return Instr->getOperand(3); } void set_nonUniformIndex(llvm::Value *val) { Instr->setOperand(3, val); } - bool get_nonUniformIndex_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } - void set_nonUniformIndex_val(bool val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } + bool get_nonUniformIndex_val() const { + return (bool)(llvm::dyn_cast(Instr->getOperand(3)) + ->getZExtValue()); + } + void set_nonUniformIndex_val(bool val) { + Instr->setOperand(3, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 1), + llvm::APInt(1, (uint64_t)val))); + } }; /// This instruction create resource handle from heap @@ -7089,12 +7736,14 @@ struct DxilInst_CreateHandleFromHeap { // Construction and identification DxilInst_CreateHandleFromHeap(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandleFromHeap); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::CreateHandleFromHeap); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7110,15 +7759,30 @@ struct DxilInst_CreateHandleFromHeap { void set_index(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_samplerHeap() const { return Instr->getOperand(2); } void set_samplerHeap(llvm::Value *val) { Instr->setOperand(2, val); } - bool get_samplerHeap_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_samplerHeap_val(bool val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } + bool get_samplerHeap_val() const { + return (bool)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_samplerHeap_val(bool val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 1), + llvm::APInt(1, (uint64_t)val))); + } llvm::Value *get_nonUniformIndex() const { return Instr->getOperand(3); } void set_nonUniformIndex(llvm::Value *val) { Instr->setOperand(3, val); } - bool get_nonUniformIndex_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } - void set_nonUniformIndex_val(bool val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } + bool get_nonUniformIndex_val() const { + return (bool)(llvm::dyn_cast(Instr->getOperand(3)) + ->getZExtValue()); + } + void set_nonUniformIndex_val(bool val) { + Instr->setOperand(3, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 1), + llvm::APInt(1, (uint64_t)val))); + } }; -/// This instruction unpacks 4 8-bit signed or unsigned values into int32 or int16 vector +/// This instruction unpacks 4 8-bit signed or unsigned values into int32 or +/// int16 vector struct DxilInst_Unpack4x8 { llvm::Instruction *Instr; // Construction and identification @@ -7129,7 +7793,8 @@ struct DxilInst_Unpack4x8 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7146,7 +7811,8 @@ struct DxilInst_Unpack4x8 { void set_pk(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction packs vector of 4 signed or unsigned values into a packed datatype, drops or clamps unused bits +/// This instruction packs vector of 4 signed or unsigned values into a packed +/// datatype, drops or clamps unused bits struct DxilInst_Pack4x8 { llvm::Instruction *Instr; // Construction and identification @@ -7157,7 +7823,8 @@ struct DxilInst_Pack4x8 { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7189,12 +7856,14 @@ struct DxilInst_IsHelperLane { // Construction and identification DxilInst_IsHelperLane(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsHelperLane); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::IsHelperLane); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7212,7 +7881,8 @@ struct DxilInst_QuadVote { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7227,22 +7897,32 @@ struct DxilInst_QuadVote { void set_cond(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_op() const { return Instr->getOperand(2); } void set_op(llvm::Value *val) { Instr->setOperand(2, val); } - int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_op_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_op_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_op_val(int8_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } }; -/// This instruction Gather raw elements from 4 texels with no type conversions (SRV type is constrained) +/// This instruction Gather raw elements from 4 texels with no type conversions +/// (SRV type is constrained) struct DxilInst_TextureGatherRaw { llvm::Instruction *Instr; // Construction and identification DxilInst_TextureGatherRaw(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGatherRaw); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::TextureGatherRaw); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (9 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7277,18 +7957,21 @@ struct DxilInst_TextureGatherRaw { void set_offset1(llvm::Value *val) { Instr->setOperand(8, val); } }; -/// This instruction samples a texture and compares a single component against the specified comparison value +/// This instruction samples a texture and compares a single component against +/// the specified comparison value struct DxilInst_SampleCmpLevel { llvm::Instruction *Instr; // Construction and identification DxilInst_SampleCmpLevel(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpLevel); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::SampleCmpLevel); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (12 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7338,12 +8021,14 @@ struct DxilInst_TextureStoreSample { // Construction and identification DxilInst_TextureStoreSample(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureStoreSample); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::TextureStoreSample); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7380,8 +8065,15 @@ struct DxilInst_TextureStoreSample { void set_value3(llvm::Value *val) { Instr->setOperand(8, val); } llvm::Value *get_mask() const { return Instr->getOperand(9); } void set_mask(llvm::Value *val) { Instr->setOperand(9, val); } - int8_t get_mask_val() const { return (int8_t)(llvm::dyn_cast(Instr->getOperand(9))->getZExtValue()); } - void set_mask_val(int8_t val) { Instr->setOperand(9, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); } + int8_t get_mask_val() const { + return (int8_t)(llvm::dyn_cast(Instr->getOperand(9)) + ->getZExtValue()); + } + void set_mask_val(int8_t val) { + Instr->setOperand(9, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 8), + llvm::APInt(8, (uint64_t)val))); + } llvm::Value *get_sampleIdx() const { return Instr->getOperand(10); } void set_sampleIdx(llvm::Value *val) { Instr->setOperand(10, val); } }; @@ -7390,14 +8082,17 @@ struct DxilInst_TextureStoreSample { struct DxilInst_AllocateNodeOutputRecords { llvm::Instruction *Instr; // Construction and identification - DxilInst_AllocateNodeOutputRecords(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_AllocateNodeOutputRecords(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AllocateNodeOutputRecords); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::AllocateNodeOutputRecords); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7415,22 +8110,32 @@ struct DxilInst_AllocateNodeOutputRecords { void set_numRecords(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_perThread() const { return Instr->getOperand(3); } void set_perThread(llvm::Value *val) { Instr->setOperand(3, val); } - bool get_perThread_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } - void set_perThread_val(bool val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } + bool get_perThread_val() const { + return (bool)(llvm::dyn_cast(Instr->getOperand(3)) + ->getZExtValue()); + } + void set_perThread_val(bool val) { + Instr->setOperand(3, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 1), + llvm::APInt(1, (uint64_t)val))); + } }; -/// This instruction retrieve node input/output record pointer in address space 6 +/// This instruction retrieve node input/output record pointer in address space +/// 6 struct DxilInst_GetNodeRecordPtr { llvm::Instruction *Instr; // Construction and identification DxilInst_GetNodeRecordPtr(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetNodeRecordPtr); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::GetNodeRecordPtr); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7447,18 +8152,21 @@ struct DxilInst_GetNodeRecordPtr { void set_arrayIndex(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction Select the next logical output count for an EmptyNodeOutput for the whole group or per thread. +/// This instruction Select the next logical output count for an EmptyNodeOutput +/// for the whole group or per thread. struct DxilInst_IncrementOutputCount { llvm::Instruction *Instr; // Construction and identification DxilInst_IncrementOutputCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IncrementOutputCount); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::IncrementOutputCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7476,8 +8184,15 @@ struct DxilInst_IncrementOutputCount { void set_count(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_perThread() const { return Instr->getOperand(3); } void set_perThread(llvm::Value *val) { Instr->setOperand(3, val); } - bool get_perThread_val() const { return (bool)(llvm::dyn_cast(Instr->getOperand(3))->getZExtValue()); } - void set_perThread_val(bool val) { Instr->setOperand(3, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 1), llvm::APInt(1, (uint64_t)val))); } + bool get_perThread_val() const { + return (bool)(llvm::dyn_cast(Instr->getOperand(3)) + ->getZExtValue()); + } + void set_perThread_val(bool val) { + Instr->setOperand(3, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 1), + llvm::APInt(1, (uint64_t)val))); + } }; /// This instruction indicates all outputs for a given records are complete @@ -7486,12 +8201,14 @@ struct DxilInst_OutputComplete { // Construction and identification DxilInst_OutputComplete(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::OutputComplete); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::OutputComplete); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7505,18 +8222,21 @@ struct DxilInst_OutputComplete { void set_output(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns the number of records that have been coalesced into the current thread group +/// This instruction returns the number of records that have been coalesced into +/// the current thread group struct DxilInst_GetInputRecordCount { llvm::Instruction *Instr; // Construction and identification DxilInst_GetInputRecordCount(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetInputRecordCount); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::GetInputRecordCount); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7530,18 +8250,22 @@ struct DxilInst_GetInputRecordCount { void set_input(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction returns true if the current thread group is the last to access the input +/// This instruction returns true if the current thread group is the last to +/// access the input struct DxilInst_FinishedCrossGroupSharing { llvm::Instruction *Instr; // Construction and identification - DxilInst_FinishedCrossGroupSharing(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_FinishedCrossGroupSharing(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FinishedCrossGroupSharing); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::FinishedCrossGroupSharing); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7555,18 +8279,21 @@ struct DxilInst_FinishedCrossGroupSharing { void set_input(llvm::Value *val) { Instr->setOperand(1, val); } }; -/// This instruction Request a barrier for a set of memory types and/or thread group execution sync +/// This instruction Request a barrier for a set of memory types and/or thread +/// group execution sync struct DxilInst_BarrierByMemoryType { llvm::Instruction *Instr; // Construction and identification DxilInst_BarrierByMemoryType(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BarrierByMemoryType); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::BarrierByMemoryType); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7579,26 +8306,43 @@ struct DxilInst_BarrierByMemoryType { // Accessors llvm::Value *get_MemoryTypeFlags() const { return Instr->getOperand(1); } void set_MemoryTypeFlags(llvm::Value *val) { Instr->setOperand(1, val); } - int32_t get_MemoryTypeFlags_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } - void set_MemoryTypeFlags_val(int32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_MemoryTypeFlags_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(1)) + ->getZExtValue()); + } + void set_MemoryTypeFlags_val(int32_t val) { + Instr->setOperand(1, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } llvm::Value *get_SemanticFlags() const { return Instr->getOperand(2); } void set_SemanticFlags(llvm::Value *val) { Instr->setOperand(2, val); } - int32_t get_SemanticFlags_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_SemanticFlags_val(int32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_SemanticFlags_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_SemanticFlags_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; -/// This instruction Request a barrier for just the memory used by the specified object +/// This instruction Request a barrier for just the memory used by the specified +/// object struct DxilInst_BarrierByMemoryHandle { llvm::Instruction *Instr; // Construction and identification DxilInst_BarrierByMemoryHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BarrierByMemoryHandle); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::BarrierByMemoryHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7613,22 +8357,33 @@ struct DxilInst_BarrierByMemoryHandle { void set_object(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_SemanticFlags() const { return Instr->getOperand(2); } void set_SemanticFlags(llvm::Value *val) { Instr->setOperand(2, val); } - int32_t get_SemanticFlags_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_SemanticFlags_val(int32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_SemanticFlags_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_SemanticFlags_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; -/// This instruction Request a barrier for just the memory used by the node record +/// This instruction Request a barrier for just the memory used by the node +/// record struct DxilInst_BarrierByNodeRecordHandle { llvm::Instruction *Instr; // Construction and identification - DxilInst_BarrierByNodeRecordHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_BarrierByNodeRecordHandle(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BarrierByNodeRecordHandle); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::BarrierByNodeRecordHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7643,8 +8398,15 @@ struct DxilInst_BarrierByNodeRecordHandle { void set_object(llvm::Value *val) { Instr->setOperand(1, val); } llvm::Value *get_SemanticFlags() const { return Instr->getOperand(2); } void set_SemanticFlags(llvm::Value *val) { Instr->setOperand(2, val); } - int32_t get_SemanticFlags_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_SemanticFlags_val(int32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_SemanticFlags_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_SemanticFlags_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; /// This instruction Creates a handle to a NodeOutput @@ -7653,12 +8415,14 @@ struct DxilInst_CreateNodeOutputHandle { // Construction and identification DxilInst_CreateNodeOutputHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateNodeOutputHandle); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::CreateNodeOutputHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7670,22 +8434,32 @@ struct DxilInst_CreateNodeOutputHandle { // Accessors llvm::Value *get_MetadataIdx() const { return Instr->getOperand(1); } void set_MetadataIdx(llvm::Value *val) { Instr->setOperand(1, val); } - int32_t get_MetadataIdx_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } - void set_MetadataIdx_val(int32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_MetadataIdx_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(1)) + ->getZExtValue()); + } + void set_MetadataIdx_val(int32_t val) { + Instr->setOperand(1, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; -/// This instruction returns the handle for the location in the output node array at the indicated index +/// This instruction returns the handle for the location in the output node +/// array at the indicated index struct DxilInst_IndexNodeHandle { llvm::Instruction *Instr; // Construction and identification DxilInst_IndexNodeHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IndexNodeHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::IndexNodeHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7708,12 +8482,14 @@ struct DxilInst_AnnotateNodeHandle { // Construction and identification DxilInst_AnnotateNodeHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AnnotateNodeHandle); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::AnnotateNodeHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7734,14 +8510,17 @@ struct DxilInst_AnnotateNodeHandle { struct DxilInst_CreateNodeInputRecordHandle { llvm::Instruction *Instr; // Construction and identification - DxilInst_CreateNodeInputRecordHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_CreateNodeInputRecordHandle(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateNodeInputRecordHandle); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::CreateNodeInputRecordHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7753,22 +8532,32 @@ struct DxilInst_CreateNodeInputRecordHandle { // Accessors llvm::Value *get_MetadataIdx() const { return Instr->getOperand(1); } void set_MetadataIdx(llvm::Value *val) { Instr->setOperand(1, val); } - int32_t get_MetadataIdx_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } - void set_MetadataIdx_val(int32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_MetadataIdx_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(1)) + ->getZExtValue()); + } + void set_MetadataIdx_val(int32_t val) { + Instr->setOperand(1, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; /// This instruction annotate handle with node record properties struct DxilInst_AnnotateNodeRecordHandle { llvm::Instruction *Instr; // Construction and identification - DxilInst_AnnotateNodeRecordHandle(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_AnnotateNodeRecordHandle(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AnnotateNodeRecordHandle); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::AnnotateNodeRecordHandle); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7785,18 +8574,21 @@ struct DxilInst_AnnotateNodeRecordHandle { void set_props(llvm::Value *val) { Instr->setOperand(2, val); } }; -/// This instruction returns true if the specified output node is present in the work graph +/// This instruction returns true if the specified output node is present in the +/// work graph struct DxilInst_NodeOutputIsValid { llvm::Instruction *Instr; // Construction and identification DxilInst_NodeOutputIsValid(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::NodeOutputIsValid); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::NodeOutputIsValid); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7814,32 +8606,38 @@ struct DxilInst_NodeOutputIsValid { struct DxilInst_GetRemainingRecursionLevels { llvm::Instruction *Instr; // Construction and identification - DxilInst_GetRemainingRecursionLevels(llvm::Instruction *pInstr) : Instr(pInstr) {} + DxilInst_GetRemainingRecursionLevels(llvm::Instruction *pInstr) + : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetRemainingRecursionLevels); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::GetRemainingRecursionLevels); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata bool requiresUniformInputs() const { return false; } }; -/// This instruction samples a texture using a gradient and compares a single component against the specified comparison value +/// This instruction samples a texture using a gradient and compares a single +/// component against the specified comparison value struct DxilInst_SampleCmpGrad { llvm::Instruction *Instr; // Construction and identification DxilInst_SampleCmpGrad(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpGrad); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::SampleCmpGrad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (18 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (18 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7901,18 +8699,22 @@ struct DxilInst_SampleCmpGrad { void set_clamp(llvm::Value *val) { Instr->setOperand(17, val); } }; -/// This instruction samples a texture after applying the input bias to the mipmap level and compares a single component against the specified comparison value +/// This instruction samples a texture after applying the input bias to the +/// mipmap level and compares a single component against the specified +/// comparison value struct DxilInst_SampleCmpBias { llvm::Instruction *Instr; // Construction and identification DxilInst_SampleCmpBias(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpBias); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::SampleCmpBias); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7959,18 +8761,21 @@ struct DxilInst_SampleCmpBias { void set_clamp(llvm::Value *val) { Instr->setOperand(12, val); } }; -/// This instruction returns the BaseVertexLocation from DrawIndexedInstanced or StartVertexLocation from DrawInstanced +/// This instruction returns the BaseVertexLocation from DrawIndexedInstanced or +/// StartVertexLocation from DrawInstanced struct DxilInst_StartVertexLocation { llvm::Instruction *Instr; // Construction and identification DxilInst_StartVertexLocation(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StartVertexLocation); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::StartVertexLocation); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -7983,12 +8788,14 @@ struct DxilInst_StartInstanceLocation { // Construction and identification DxilInst_StartInstanceLocation(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StartInstanceLocation); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::StartInstanceLocation); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -8001,12 +8808,14 @@ struct DxilInst_AllocateRayQuery2 { // Construction and identification DxilInst_AllocateRayQuery2(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AllocateRayQuery2); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::AllocateRayQuery2); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -8019,12 +8828,26 @@ struct DxilInst_AllocateRayQuery2 { // Accessors llvm::Value *get_constRayFlags() const { return Instr->getOperand(1); } void set_constRayFlags(llvm::Value *val) { Instr->setOperand(1, val); } - uint32_t get_constRayFlags_val() const { return (uint32_t)(llvm::dyn_cast(Instr->getOperand(1))->getZExtValue()); } - void set_constRayFlags_val(uint32_t val) { Instr->setOperand(1, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + uint32_t get_constRayFlags_val() const { + return (uint32_t)(llvm::dyn_cast(Instr->getOperand(1)) + ->getZExtValue()); + } + void set_constRayFlags_val(uint32_t val) { + Instr->setOperand(1, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } llvm::Value *get_constRayQueryFlags() const { return Instr->getOperand(2); } void set_constRayQueryFlags(llvm::Value *val) { Instr->setOperand(2, val); } - uint32_t get_constRayQueryFlags_val() const { return (uint32_t)(llvm::dyn_cast(Instr->getOperand(2))->getZExtValue()); } - void set_constRayQueryFlags_val(uint32_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + uint32_t get_constRayQueryFlags_val() const { + return (uint32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_constRayQueryFlags_val(uint32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; /// This instruction Creates a new HitObject representing a miss @@ -8033,12 +8856,14 @@ struct DxilInst_HitObject_MakeMiss { // Construction and identification DxilInst_HitObject_MakeMiss(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::HitObject_MakeMiss); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::HitObject_MakeMiss); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (11 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -8085,12 +8910,14 @@ struct DxilInst_HitObject_MakeNop { // Construction and identification DxilInst_HitObject_MakeNop(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::HitObject_MakeNop); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::HitObject_MakeNop); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (1 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -8103,12 +8930,14 @@ struct DxilInst_RawBufferVectorLoad { // Construction and identification DxilInst_RawBufferVectorLoad(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferVectorLoad); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RawBufferVectorLoad); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (5 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -8129,8 +8958,15 @@ struct DxilInst_RawBufferVectorLoad { void set_elementOffset(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_alignment() const { return Instr->getOperand(4); } void set_alignment(llvm::Value *val) { Instr->setOperand(4, val); } - int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(4))->getZExtValue()); } - void set_alignment_val(int32_t val) { Instr->setOperand(4, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_alignment_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(4)) + ->getZExtValue()); + } + void set_alignment_val(int32_t val) { + Instr->setOperand(4, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; /// This instruction writes to a RWByteAddressBuffer or RWStructuredBuffer @@ -8139,12 +8975,14 @@ struct DxilInst_RawBufferVectorStore { // Construction and identification DxilInst_RawBufferVectorStore(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RawBufferVectorStore); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::RawBufferVectorStore); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (6 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -8168,8 +9006,15 @@ struct DxilInst_RawBufferVectorStore { void set_value0(llvm::Value *val) { Instr->setOperand(4, val); } llvm::Value *get_alignment() const { return Instr->getOperand(5); } void set_alignment(llvm::Value *val) { Instr->setOperand(5, val); } - int32_t get_alignment_val() const { return (int32_t)(llvm::dyn_cast(Instr->getOperand(5))->getZExtValue()); } - void set_alignment_val(int32_t val) { Instr->setOperand(5, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); } + int32_t get_alignment_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(5)) + ->getZExtValue()); + } + void set_alignment_val(int32_t val) { + Instr->setOperand(5, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } }; /// This instruction Matrix-Vector Multiply @@ -8183,7 +9028,8 @@ struct DxilInst_MatVecMul { // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (13 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -8236,12 +9082,14 @@ struct DxilInst_MatVecMulAdd { // Construction and identification DxilInst_MatVecMulAdd(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MatVecMulAdd); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::MatVecMulAdd); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (16 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (16 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -8303,12 +9151,14 @@ struct DxilInst_OuterProductAccumulate { // Construction and identification DxilInst_OuterProductAccumulate(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::OuterProductAccumulate); + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::OuterProductAccumulate); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (8 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (8 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata @@ -8346,12 +9196,14 @@ struct DxilInst_VectorAccumulate { // Construction and identification DxilInst_VectorAccumulate(llvm::Instruction *pInstr) : Instr(pInstr) {} operator bool() const { - return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::VectorAccumulate); + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::VectorAccumulate); } // Validation support bool isAllowed() const { return true; } bool isArgumentListValid() const { - if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) return false; + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; return true; } // Metadata diff --git a/include/dxc/HLSL/HLOperations.h b/include/dxc/HLSL/HLOperations.h index 38a62f1a92..41def3ba2c 100644 --- a/include/dxc/HLSL/HLOperations.h +++ b/include/dxc/HLSL/HLOperations.h @@ -450,7 +450,6 @@ const unsigned kMatVecMulMatrixLayoutIdx = 11; const unsigned kMatVecMulMatrixTransposeIdx = 12; const unsigned kMatVecMulMatrixStrideIdx = 13; - // MatVecMulAdd const unsigned kMatVecMulAddOutputVectorIdx = 1; const unsigned kMatVecMulAddIsOutputUnsignedIdx = 2; @@ -469,7 +468,6 @@ const unsigned kMatVecMulAddBiasBufferIdx = 14; const unsigned kMatVecMulAddBiasOffsetIdx = 15; const unsigned kMatVecMulAddBiasInterpretationIdx = 16; - // OuterProductAccumulate const unsigned kOuterProdAccInputVec1Idx = 1; const unsigned kOuterProdAccInputVec2Idx = 2; diff --git a/lib/DXIL/DxilOperations.cpp b/lib/DXIL/DxilOperations.cpp index 2ee7d7923b..ce29e11368 100644 --- a/lib/DXIL/DxilOperations.cpp +++ b/lib/DXIL/DxilOperations.cpp @@ -39,485 +39,2648 @@ import hctdb_instrhelp /* hctdb_instrhelp.get_oloads_props()*/ // OPCODE-OLOADS:BEGIN const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = { - // Temporary, indexable, input, output registers - { OC::TempRegLoad, "TempRegLoad", OCC::TempRegLoad, "tempRegLoad", Attribute::ReadOnly , 1, {{0x63}} , {{0x0}} }, // Overloads: hfwi - { OC::TempRegStore, "TempRegStore", OCC::TempRegStore, "tempRegStore", Attribute::None , 1, {{0x63}} , {{0x0}} }, // Overloads: hfwi - { OC::MinPrecXRegLoad, "MinPrecXRegLoad", OCC::MinPrecXRegLoad, "minPrecXRegLoad", Attribute::ReadOnly , 1, {{0x21}} , {{0x0}} }, // Overloads: hw - { OC::MinPrecXRegStore, "MinPrecXRegStore", OCC::MinPrecXRegStore, "minPrecXRegStore", Attribute::None , 1, {{0x21}} , {{0x0}} }, // Overloads: hw - { OC::LoadInput, "LoadInput", OCC::LoadInput, "loadInput", Attribute::ReadNone , 1, {{0x63}} , {{0x0}} }, // Overloads: hfwi - { OC::StoreOutput, "StoreOutput", OCC::StoreOutput, "storeOutput", Attribute::None , 1, {{0x63}} , {{0x0}} }, // Overloads: hfwi - - // Unary float - { OC::FAbs, "FAbs", OCC::Unary, "unary", Attribute::ReadNone , 1, {{0x7}} , {{0x0}} }, // Overloads: hfd - { OC::Saturate, "Saturate", OCC::Unary, "unary", Attribute::ReadNone , 1, {{0x7}} , {{0x0}} }, // Overloads: hfd - { OC::IsNaN, "IsNaN", OCC::IsSpecialFloat, "isSpecialFloat", Attribute::ReadNone , 1, {{0x3}} , {{0x0}} }, // Overloads: hf - { OC::IsInf, "IsInf", OCC::IsSpecialFloat, "isSpecialFloat", Attribute::ReadNone , 1, {{0x3}} , {{0x0}} }, // Overloads: hf - { OC::IsFinite, "IsFinite", OCC::IsSpecialFloat, "isSpecialFloat", Attribute::ReadNone , 1, {{0x3}} , {{0x0}} }, // Overloads: hf - { OC::IsNormal, "IsNormal", OCC::IsSpecialFloat, "isSpecialFloat", Attribute::ReadNone , 1, {{0x3}} , {{0x0}} }, // Overloads: hf - { OC::Cos, "Cos", OCC::Unary, "unary", Attribute::ReadNone , 1, {{0x403}} , {{0x3}} }, // Overloads: hfhctdb_instrhelp.get_oloads_funcs()*/ switch (opCode) { // return opCode // OPCODE-OLOAD-FUNCS:BEGIN - // Temporary, indexable, input, output registers - case OpCode::TempRegLoad: A(pETy); A(pI32); A(pI32); break; - case OpCode::TempRegStore: A(pV); A(pI32); A(pI32); A(pETy); break; - case OpCode::MinPrecXRegLoad: A(pETy); A(pI32); A(pPF32);A(pI32); A(pI8); break; - case OpCode::MinPrecXRegStore: A(pV); A(pI32); A(pPF32);A(pI32); A(pI8); A(pETy); break; - case OpCode::LoadInput: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI32); break; - case OpCode::StoreOutput: A(pV); A(pI32); A(pI32); A(pI32); A(pI8); A(pETy); break; - - // Unary float - case OpCode::FAbs: A(pETy); A(pI32); A(pETy); break; - case OpCode::Saturate: A(pETy); A(pI32); A(pETy); break; - case OpCode::IsNaN: A(pI1); A(pI32); A(pETy); break; - case OpCode::IsInf: A(pI1); A(pI32); A(pETy); break; - case OpCode::IsFinite: A(pI1); A(pI32); A(pETy); break; - case OpCode::IsNormal: A(pI1); A(pI32); A(pETy); break; - case OpCode::Cos: A(pETy); A(pI32); A(pETy); break; - case OpCode::Sin: A(pETy); A(pI32); A(pETy); break; - case OpCode::Tan: A(pETy); A(pI32); A(pETy); break; - case OpCode::Acos: A(pETy); A(pI32); A(pETy); break; - case OpCode::Asin: A(pETy); A(pI32); A(pETy); break; - case OpCode::Atan: A(pETy); A(pI32); A(pETy); break; - case OpCode::Hcos: A(pETy); A(pI32); A(pETy); break; - case OpCode::Hsin: A(pETy); A(pI32); A(pETy); break; - case OpCode::Htan: A(pETy); A(pI32); A(pETy); break; - case OpCode::Exp: A(pETy); A(pI32); A(pETy); break; - case OpCode::Frc: A(pETy); A(pI32); A(pETy); break; - case OpCode::Log: A(pETy); A(pI32); A(pETy); break; - case OpCode::Sqrt: A(pETy); A(pI32); A(pETy); break; - case OpCode::Rsqrt: A(pETy); A(pI32); A(pETy); break; - - // Unary float - rounding - case OpCode::Round_ne: A(pETy); A(pI32); A(pETy); break; - case OpCode::Round_ni: A(pETy); A(pI32); A(pETy); break; - case OpCode::Round_pi: A(pETy); A(pI32); A(pETy); break; - case OpCode::Round_z: A(pETy); A(pI32); A(pETy); break; - - // Unary int - case OpCode::Bfrev: A(pETy); A(pI32); A(pETy); break; - case OpCode::Countbits: A(pI32); A(pI32); A(pETy); break; - case OpCode::FirstbitLo: A(pI32); A(pI32); A(pETy); break; - - // Unary uint - case OpCode::FirstbitHi: A(pI32); A(pI32); A(pETy); break; - - // Unary int - case OpCode::FirstbitSHi: A(pI32); A(pI32); A(pETy); break; - - // Binary float - case OpCode::FMax: A(pETy); A(pI32); A(pETy); A(pETy); break; - case OpCode::FMin: A(pETy); A(pI32); A(pETy); A(pETy); break; - - // Binary int - case OpCode::IMax: A(pETy); A(pI32); A(pETy); A(pETy); break; - case OpCode::IMin: A(pETy); A(pI32); A(pETy); A(pETy); break; - - // Binary uint - case OpCode::UMax: A(pETy); A(pI32); A(pETy); A(pETy); break; - case OpCode::UMin: A(pETy); A(pI32); A(pETy); A(pETy); break; - - // Binary int with two outputs - case OpCode::IMul: A(p2I32); A(pI32); A(pETy); A(pETy); break; - - // Binary uint with two outputs - case OpCode::UMul: A(p2I32); A(pI32); A(pETy); A(pETy); break; - case OpCode::UDiv: A(p2I32); A(pI32); A(pETy); A(pETy); break; - - // Binary uint with carry or borrow - case OpCode::UAddc: A(pI32C); A(pI32); A(pETy); A(pETy); break; - case OpCode::USubb: A(pI32C); A(pI32); A(pETy); A(pETy); break; - - // Tertiary float - case OpCode::FMad: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; - case OpCode::Fma: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; - - // Tertiary int - case OpCode::IMad: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; - - // Tertiary uint - case OpCode::UMad: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; - - // Tertiary int - case OpCode::Msad: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; - case OpCode::Ibfe: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; - - // Tertiary uint - case OpCode::Ubfe: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); break; - - // Quaternary - case OpCode::Bfi: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); break; - - // Dot - case OpCode::Dot2: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); break; - case OpCode::Dot3: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); break; - case OpCode::Dot4: A(pETy); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); A(pETy); break; - - // Resources - case OpCode::CreateHandle: A(pRes); A(pI32); A(pI8); A(pI32); A(pI32); A(pI1); break; - case OpCode::CBufferLoad: A(pETy); A(pI32); A(pRes); A(pI32); A(pI32); break; - case OpCode::CBufferLoadLegacy: CBRT(pETy); A(pI32); A(pRes); A(pI32); break; - - // Resources - sample - case OpCode::Sample: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); break; - case OpCode::SampleBias: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); break; - case OpCode::SampleLevel: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); break; - case OpCode::SampleGrad: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; - case OpCode::SampleCmp: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); break; - case OpCode::SampleCmpLevelZero: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); break; - - // Resources - case OpCode::TextureLoad: RRT(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); break; - case OpCode::TextureStore: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pI8); break; - case OpCode::BufferLoad: RRT(pETy); A(pI32); A(pRes); A(pI32); A(pI32); break; - case OpCode::BufferStore: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pI8); break; - case OpCode::BufferUpdateCounter: A(pI32); A(pI32); A(pRes); A(pI8); break; - case OpCode::CheckAccessFullyMapped: A(pI1); A(pI32); A(pI32); break; - case OpCode::GetDimensions: A(pDim); A(pI32); A(pRes); A(pI32); break; - - // Resources - gather - case OpCode::TextureGather: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); break; - case OpCode::TextureGatherCmp: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); break; - - // Resources - sample - case OpCode::Texture2DMSGetSamplePosition:A(pPos); A(pI32); A(pRes); A(pI32); break; - case OpCode::RenderTargetGetSamplePosition:A(pPos); A(pI32); A(pI32); break; - case OpCode::RenderTargetGetSampleCount:A(pI32); A(pI32); break; - - // Synchronization - case OpCode::AtomicBinOp: A(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pETy); break; - case OpCode::AtomicCompareExchange: A(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pETy); A(pETy); break; - case OpCode::Barrier: A(pV); A(pI32); A(pI32); break; - - // Derivatives - case OpCode::CalculateLOD: A(pF32); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pI1); break; - - // Pixel shader - case OpCode::Discard: A(pV); A(pI32); A(pI1); break; - - // Derivatives - case OpCode::DerivCoarseX: A(pETy); A(pI32); A(pETy); break; - case OpCode::DerivCoarseY: A(pETy); A(pI32); A(pETy); break; - case OpCode::DerivFineX: A(pETy); A(pI32); A(pETy); break; - case OpCode::DerivFineY: A(pETy); A(pI32); A(pETy); break; - - // Pixel shader - case OpCode::EvalSnapped: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI32); A(pI32); break; - case OpCode::EvalSampleIndex: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI32); break; - case OpCode::EvalCentroid: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); break; - case OpCode::SampleIndex: A(pI32); A(pI32); break; - case OpCode::Coverage: A(pI32); A(pI32); break; - case OpCode::InnerCoverage: A(pI32); A(pI32); break; - - // Compute/Mesh/Amplification/Node shader - case OpCode::ThreadId: A(pI32); A(pI32); A(pI32); break; - case OpCode::GroupId: A(pI32); A(pI32); A(pI32); break; - case OpCode::ThreadIdInGroup: A(pI32); A(pI32); A(pI32); break; - case OpCode::FlattenedThreadIdInGroup:A(pI32); A(pI32); break; - - // Geometry shader - case OpCode::EmitStream: A(pV); A(pI32); A(pI8); break; - case OpCode::CutStream: A(pV); A(pI32); A(pI8); break; - case OpCode::EmitThenCutStream: A(pV); A(pI32); A(pI8); break; - case OpCode::GSInstanceID: A(pI32); A(pI32); break; - - // Double precision - case OpCode::MakeDouble: A(pF64); A(pI32); A(pI32); A(pI32); break; - case OpCode::SplitDouble: A(pSDT); A(pI32); A(pF64); break; - - // Domain and hull shader - case OpCode::LoadOutputControlPoint: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI32); break; - case OpCode::LoadPatchConstant: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); break; - - // Domain shader - case OpCode::DomainLocation: A(pF32); A(pI32); A(pI8); break; - - // Hull shader - case OpCode::StorePatchConstant: A(pV); A(pI32); A(pI32); A(pI32); A(pI8); A(pETy); break; - case OpCode::OutputControlPointID: A(pI32); A(pI32); break; - - // Hull, Domain and Geometry shaders - case OpCode::PrimitiveID: A(pI32); A(pI32); break; - - // Other - case OpCode::CycleCounterLegacy: A(p2I32); A(pI32); break; - - // Wave - case OpCode::WaveIsFirstLane: A(pI1); A(pI32); break; - case OpCode::WaveGetLaneIndex: A(pI32); A(pI32); break; - case OpCode::WaveGetLaneCount: A(pI32); A(pI32); break; - case OpCode::WaveAnyTrue: A(pI1); A(pI32); A(pI1); break; - case OpCode::WaveAllTrue: A(pI1); A(pI32); A(pI1); break; - case OpCode::WaveActiveAllEqual: A(pI1); A(pI32); A(pETy); break; - case OpCode::WaveActiveBallot: A(p4I32); A(pI32); A(pI1); break; - case OpCode::WaveReadLaneAt: A(pETy); A(pI32); A(pETy); A(pI32); break; - case OpCode::WaveReadLaneFirst: A(pETy); A(pI32); A(pETy); break; - case OpCode::WaveActiveOp: A(pETy); A(pI32); A(pETy); A(pI8); A(pI8); break; - case OpCode::WaveActiveBit: A(pETy); A(pI32); A(pETy); A(pI8); break; - case OpCode::WavePrefixOp: A(pETy); A(pI32); A(pETy); A(pI8); A(pI8); break; - - // Quad Wave Ops - case OpCode::QuadReadLaneAt: A(pETy); A(pI32); A(pETy); A(pI32); break; - case OpCode::QuadOp: A(pETy); A(pI32); A(pETy); A(pI8); break; - - // Bitcasts with different sizes - case OpCode::BitcastI16toF16: A(pF16); A(pI32); A(pI16); break; - case OpCode::BitcastF16toI16: A(pI16); A(pI32); A(pF16); break; - case OpCode::BitcastI32toF32: A(pF32); A(pI32); A(pI32); break; - case OpCode::BitcastF32toI32: A(pI32); A(pI32); A(pF32); break; - case OpCode::BitcastI64toF64: A(pF64); A(pI32); A(pI64); break; - case OpCode::BitcastF64toI64: A(pI64); A(pI32); A(pF64); break; - - // Legacy floating-point - case OpCode::LegacyF32ToF16: A(pI32); A(pI32); A(pF32); break; - case OpCode::LegacyF16ToF32: A(pF32); A(pI32); A(pI32); break; - - // Double precision - case OpCode::LegacyDoubleToFloat: A(pF32); A(pI32); A(pF64); break; - case OpCode::LegacyDoubleToSInt32: A(pI32); A(pI32); A(pF64); break; - case OpCode::LegacyDoubleToUInt32: A(pI32); A(pI32); A(pF64); break; - - // Wave - case OpCode::WaveAllBitCount: A(pI32); A(pI32); A(pI1); break; - case OpCode::WavePrefixBitCount: A(pI32); A(pI32); A(pI1); break; - - // Pixel shader - case OpCode::AttributeAtVertex: A(pETy); A(pI32); A(pI32); A(pI32); A(pI8); A(pI8); break; - - // Graphics shader - case OpCode::ViewID: A(pI32); A(pI32); break; - - // Resources - case OpCode::RawBufferLoad: RRT(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI8); A(pI32); break; - case OpCode::RawBufferStore: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pI8); A(pI32); break; - - // Raytracing object space uint System Values - case OpCode::InstanceID: A(pI32); A(pI32); break; - case OpCode::InstanceIndex: A(pI32); A(pI32); break; - - // Raytracing hit uint System Values - case OpCode::HitKind: A(pI32); A(pI32); break; - - // Raytracing uint System Values - case OpCode::RayFlags: A(pI32); A(pI32); break; - - // Ray Dispatch Arguments - case OpCode::DispatchRaysIndex: A(pI32); A(pI32); A(pI8); break; - case OpCode::DispatchRaysDimensions: A(pI32); A(pI32); A(pI8); break; - - // Ray Vectors - case OpCode::WorldRayOrigin: A(pF32); A(pI32); A(pI8); break; - case OpCode::WorldRayDirection: A(pF32); A(pI32); A(pI8); break; - - // Ray object space Vectors - case OpCode::ObjectRayOrigin: A(pF32); A(pI32); A(pI8); break; - case OpCode::ObjectRayDirection: A(pF32); A(pI32); A(pI8); break; - - // Ray Transforms - case OpCode::ObjectToWorld: A(pF32); A(pI32); A(pI32); A(pI8); break; - case OpCode::WorldToObject: A(pF32); A(pI32); A(pI32); A(pI8); break; - - // RayT - case OpCode::RayTMin: A(pF32); A(pI32); break; - case OpCode::RayTCurrent: A(pF32); A(pI32); break; - - // AnyHit Terminals - case OpCode::IgnoreHit: A(pV); A(pI32); break; - case OpCode::AcceptHitAndEndSearch: A(pV); A(pI32); break; - - // Indirect Shader Invocation - case OpCode::TraceRay: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(udt); break; - case OpCode::ReportHit: A(pI1); A(pI32); A(pF32); A(pI32); A(udt); break; - case OpCode::CallShader: A(pV); A(pI32); A(pI32); A(udt); break; - - // Library create handle from resource struct (like HL intrinsic) - case OpCode::CreateHandleForLib: A(pRes); A(pI32); A(obj); break; - - // Raytracing object space uint System Values - case OpCode::PrimitiveIndex: A(pI32); A(pI32); break; - - // Dot product with accumulate - case OpCode::Dot2AddHalf: A(pETy); A(pI32); A(pETy); A(pF16); A(pF16); A(pF16); A(pF16); break; - case OpCode::Dot4AddI8Packed: A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); break; - case OpCode::Dot4AddU8Packed: A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); break; - - // Wave - case OpCode::WaveMatch: A(p4I32); A(pI32); A(pETy); break; - case OpCode::WaveMultiPrefixOp: A(pETy); A(pI32); A(pETy); A(pI32); A(pI32); A(pI32); A(pI32); A(pI8); A(pI8); break; - case OpCode::WaveMultiPrefixBitCount:A(pI32); A(pI32); A(pI1); A(pI32); A(pI32); A(pI32); A(pI32); break; - - // Mesh shader instructions - case OpCode::SetMeshOutputCounts: A(pV); A(pI32); A(pI32); A(pI32); break; - case OpCode::EmitIndices: A(pV); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); break; - case OpCode::GetMeshPayload: A(pETy); A(pI32); break; - case OpCode::StoreVertexOutput: A(pV); A(pI32); A(pI32); A(pI32); A(pI8); A(pETy); A(pI32); break; - case OpCode::StorePrimitiveOutput: A(pV); A(pI32); A(pI32); A(pI32); A(pI8); A(pETy); A(pI32); break; - - // Amplification shader instructions - case OpCode::DispatchMesh: A(pV); A(pI32); A(pI32); A(pI32); A(pI32); A(pETy); break; - - // Sampler Feedback - case OpCode::WriteSamplerFeedback: A(pV); A(pI32); A(pRes); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; - case OpCode::WriteSamplerFeedbackBias:A(pV); A(pI32); A(pRes); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; - case OpCode::WriteSamplerFeedbackLevel:A(pV); A(pI32); A(pRes); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; - case OpCode::WriteSamplerFeedbackGrad:A(pV); A(pI32); A(pRes); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; - - // Inline Ray Query - case OpCode::AllocateRayQuery: A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_TraceRayInline:A(pV); A(pI32); A(pI32); A(pRes); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; - case OpCode::RayQuery_Proceed: A(pI1); A(pI32); A(pI32); break; - case OpCode::RayQuery_Abort: A(pV); A(pI32); A(pI32); break; - case OpCode::RayQuery_CommitNonOpaqueTriangleHit:A(pV); A(pI32); A(pI32); break; - case OpCode::RayQuery_CommitProceduralPrimitiveHit:A(pV); A(pI32); A(pI32); A(pF32); break; - case OpCode::RayQuery_CommittedStatus:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidateType: A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidateObjectToWorld3x4:A(pF32); A(pI32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_CandidateWorldToObject3x4:A(pF32); A(pI32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_CommittedObjectToWorld3x4:A(pF32); A(pI32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_CommittedWorldToObject3x4:A(pF32); A(pI32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_CandidateProceduralPrimitiveNonOpaque:A(pI1); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidateTriangleFrontFace:A(pI1); A(pI32); A(pI32); break; - case OpCode::RayQuery_CommittedTriangleFrontFace:A(pI1); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidateTriangleBarycentrics:A(pF32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_CommittedTriangleBarycentrics:A(pF32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_RayFlags: A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_WorldRayOrigin:A(pF32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_WorldRayDirection:A(pF32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_RayTMin: A(pF32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidateTriangleRayT:A(pF32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CommittedRayT: A(pF32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidateInstanceIndex:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidateInstanceID:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidateGeometryIndex:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidatePrimitiveIndex:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CandidateObjectRayOrigin:A(pF32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_CandidateObjectRayDirection:A(pF32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_CommittedInstanceIndex:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CommittedInstanceID:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CommittedGeometryIndex:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CommittedPrimitiveIndex:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CommittedObjectRayOrigin:A(pF32); A(pI32); A(pI32); A(pI8); break; - case OpCode::RayQuery_CommittedObjectRayDirection:A(pF32); A(pI32); A(pI32); A(pI8); break; - - // Raytracing object space uint System Values, raytracing tier 1.1 - case OpCode::GeometryIndex: A(pI32); A(pI32); break; - - // Inline Ray Query - case OpCode::RayQuery_CandidateInstanceContributionToHitGroupIndex:A(pI32); A(pI32); A(pI32); break; - case OpCode::RayQuery_CommittedInstanceContributionToHitGroupIndex:A(pI32); A(pI32); A(pI32); break; - - // Get handle from heap - case OpCode::AnnotateHandle: A(pRes); A(pI32); A(pRes); A(resProperty);break; - case OpCode::CreateHandleFromBinding:A(pRes); A(pI32); A(resBind);A(pI32); A(pI1); break; - case OpCode::CreateHandleFromHeap: A(pRes); A(pI32); A(pI32); A(pI1); A(pI1); break; - - // Unpacking intrinsics - case OpCode::Unpack4x8: VEC4(pETy); A(pI32); A(pI8); A(pI32); break; - - // Packing intrinsics - case OpCode::Pack4x8: A(pI32); A(pI32); A(pI8); A(pETy); A(pETy); A(pETy); A(pETy); break; - - // Helper Lanes - case OpCode::IsHelperLane: A(pI1); A(pI32); break; - - // Quad Wave Ops - case OpCode::QuadVote: A(pI1); A(pI32); A(pI1); A(pI8); break; - - // Resources - gather - case OpCode::TextureGatherRaw: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); break; - - // Resources - sample - case OpCode::SampleCmpLevel: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); break; - - // Resources - case OpCode::TextureStoreSample: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pI8); A(pI32); break; - - // - case OpCode::Reserved0: A(pV); A(pI32); break; - case OpCode::Reserved1: A(pV); A(pI32); break; - case OpCode::Reserved2: A(pV); A(pI32); break; - case OpCode::Reserved3: A(pV); A(pI32); break; - case OpCode::Reserved4: A(pV); A(pI32); break; - case OpCode::Reserved5: A(pV); A(pI32); break; - case OpCode::Reserved6: A(pV); A(pI32); break; - case OpCode::Reserved7: A(pV); A(pI32); break; - case OpCode::Reserved8: A(pV); A(pI32); break; - case OpCode::Reserved9: A(pV); A(pI32); break; - case OpCode::Reserved10: A(pV); A(pI32); break; - case OpCode::Reserved11: A(pV); A(pI32); break; - - // Create/Annotate Node Handles - case OpCode::AllocateNodeOutputRecords:A(pNodeRecordHandle);A(pI32); A(pNodeHandle);A(pI32); A(pI1); break; - - // Get Pointer to Node Record in Address Space 6 - case OpCode::GetNodeRecordPtr: A(pETy); A(pI32); A(pNodeRecordHandle);A(pI32); break; - - // Work Graph intrinsics - case OpCode::IncrementOutputCount: A(pV); A(pI32); A(pNodeHandle);A(pI32); A(pI1); break; - case OpCode::OutputComplete: A(pV); A(pI32); A(pNodeRecordHandle);break; - case OpCode::GetInputRecordCount: A(pI32); A(pI32); A(pNodeRecordHandle);break; - case OpCode::FinishedCrossGroupSharing:A(pI1); A(pI32); A(pNodeRecordHandle);break; - - // Synchronization - case OpCode::BarrierByMemoryType: A(pV); A(pI32); A(pI32); A(pI32); break; - case OpCode::BarrierByMemoryHandle: A(pV); A(pI32); A(pRes); A(pI32); break; - case OpCode::BarrierByNodeRecordHandle:A(pV); A(pI32); A(pNodeRecordHandle);A(pI32); break; - - // Create/Annotate Node Handles - case OpCode::CreateNodeOutputHandle: A(pNodeHandle);A(pI32); A(pI32); break; - case OpCode::IndexNodeHandle: A(pNodeHandle);A(pI32); A(pNodeHandle);A(pI32); break; - case OpCode::AnnotateNodeHandle: A(pNodeHandle);A(pI32); A(pNodeHandle);A(nodeProperty);break; - case OpCode::CreateNodeInputRecordHandle:A(pNodeRecordHandle);A(pI32); A(pI32); break; - case OpCode::AnnotateNodeRecordHandle:A(pNodeRecordHandle);A(pI32); A(pNodeRecordHandle);A(nodeRecordProperty);break; - - // Work Graph intrinsics - case OpCode::NodeOutputIsValid: A(pI1); A(pI32); A(pNodeHandle);break; - case OpCode::GetRemainingRecursionLevels:A(pI32); A(pI32); break; - - // Comparison Samples - case OpCode::SampleCmpGrad: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; - case OpCode::SampleCmpBias: RRT(pETy); A(pI32); A(pRes); A(pRes); A(pF32); A(pF32); A(pF32); A(pF32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); break; - - // Extended Command Information - case OpCode::StartVertexLocation: A(pI32); A(pI32); break; - case OpCode::StartInstanceLocation: A(pI32); A(pI32); break; - - // Inline Ray Query - case OpCode::AllocateRayQuery2: A(pI32); A(pI32); A(pI32); A(pI32); break; - - // - case OpCode::ReservedA0: A(pV); A(pI32); break; - case OpCode::ReservedA1: A(pV); A(pI32); break; - case OpCode::ReservedA2: A(pV); A(pI32); break; - case OpCode::ReservedB0: A(pV); A(pI32); break; - case OpCode::ReservedB1: A(pV); A(pI32); break; - case OpCode::ReservedB2: A(pV); A(pI32); break; - - // Shader Execution Reordering - case OpCode::HitObject_MakeMiss: A(pHit); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); break; - case OpCode::HitObject_MakeNop: A(pHit); A(pI32); break; - - // - case OpCode::ReservedB5: A(pV); A(pI32); break; - case OpCode::ReservedB6: A(pV); A(pI32); break; - case OpCode::ReservedB7: A(pV); A(pI32); break; - case OpCode::ReservedB8: A(pV); A(pI32); break; - case OpCode::ReservedB9: A(pV); A(pI32); break; - case OpCode::ReservedB10: A(pV); A(pI32); break; - case OpCode::ReservedB11: A(pV); A(pI32); break; - case OpCode::ReservedB12: A(pV); A(pI32); break; - case OpCode::ReservedB13: A(pV); A(pI32); break; - case OpCode::ReservedB14: A(pV); A(pI32); break; - case OpCode::ReservedB15: A(pV); A(pI32); break; - case OpCode::ReservedB16: A(pV); A(pI32); break; - case OpCode::ReservedB17: A(pV); A(pI32); break; - case OpCode::ReservedB18: A(pV); A(pI32); break; - case OpCode::ReservedB19: A(pV); A(pI32); break; - case OpCode::ReservedB20: A(pV); A(pI32); break; - case OpCode::ReservedB21: A(pV); A(pI32); break; - case OpCode::ReservedB22: A(pV); A(pI32); break; - case OpCode::ReservedB23: A(pV); A(pI32); break; - case OpCode::ReservedB24: A(pV); A(pI32); break; - case OpCode::ReservedB25: A(pV); A(pI32); break; - case OpCode::ReservedB26: A(pV); A(pI32); break; - case OpCode::ReservedB27: A(pV); A(pI32); break; - case OpCode::ReservedB28: A(pV); A(pI32); break; - case OpCode::ReservedB29: A(pV); A(pI32); break; - case OpCode::ReservedB30: A(pV); A(pI32); break; - case OpCode::ReservedC0: A(pV); A(pI32); break; - case OpCode::ReservedC1: A(pV); A(pI32); break; - case OpCode::ReservedC2: A(pV); A(pI32); break; - case OpCode::ReservedC3: A(pV); A(pI32); break; - case OpCode::ReservedC4: A(pV); A(pI32); break; - case OpCode::ReservedC5: A(pV); A(pI32); break; - case OpCode::ReservedC6: A(pV); A(pI32); break; - case OpCode::ReservedC7: A(pV); A(pI32); break; - case OpCode::ReservedC8: A(pV); A(pI32); break; - case OpCode::ReservedC9: A(pV); A(pI32); break; - case OpCode::RawBufferVectorLoad: RRT(pETy); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); break; - case OpCode::RawBufferVectorStore: A(pV); A(pI32); A(pRes); A(pI32); A(pI32); A(pETy); A(pI32); break; - case OpCode::MatVecMul: EXT(0); A(pI32); EXT(1); A(pI1); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pI1); A(pI32); A(pI1); break; - case OpCode::MatVecMulAdd: EXT(0); A(pI32); EXT(1); A(pI1); A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pI1); A(pI32); A(pRes); A(pI32); A(pI32); A(pI1); break; - case OpCode::OuterProductAccumulate: A(pV); A(pI32); EXT(0); EXT(1); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); break; - case OpCode::VectorAccumulate: A(pV); A(pI32); A(pETy); A(pRes); A(pI32); break; - // OPCODE-OLOAD-FUNCS:END - default: - DXASSERT(false, "otherwise unhandled case"); + // Temporary, indexable, input, output registers + case OpCode::TempRegLoad: + A(pETy); + A(pI32); + A(pI32); + break; + case OpCode::TempRegStore: + A(pV); + A(pI32); + A(pI32); + A(pETy); + break; + case OpCode::MinPrecXRegLoad: + A(pETy); + A(pI32); + A(pPF32); + A(pI32); + A(pI8); + break; + case OpCode::MinPrecXRegStore: + A(pV); + A(pI32); + A(pPF32); + A(pI32); + A(pI8); + A(pETy); + break; + case OpCode::LoadInput: + A(pETy); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pI32); + break; + case OpCode::StoreOutput: + A(pV); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pETy); break; - } -#undef RRT -#undef A - FunctionType *pFT; - DXASSERT(ArgTypes.size() > 1, "otherwise forgot to initialize arguments"); - pFT = FunctionType::get( - ArgTypes[0], ArrayRef(&ArgTypes[1], ArgTypes.size() - 1), false); + // Unary float + case OpCode::FAbs: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Saturate: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::IsNaN: + A(pI1); + A(pI32); + A(pETy); + break; + case OpCode::IsInf: + A(pI1); + A(pI32); + A(pETy); + break; + case OpCode::IsFinite: + A(pI1); + A(pI32); + A(pETy); + break; + case OpCode::IsNormal: + A(pI1); + A(pI32); + A(pETy); + break; + case OpCode::Cos: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Sin: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Tan: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Acos: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Asin: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Atan: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Hcos: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Hsin: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Htan: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Exp: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Frc: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Log: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Sqrt: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Rsqrt: + A(pETy); + A(pI32); + A(pETy); + break; - SmallVector FuncStorage; - StringRef FuncName = - ConstructOverloadName(pOverloadType, opCode, FuncStorage); + // Unary float - rounding + case OpCode::Round_ne: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Round_ni: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Round_pi: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Round_z: + A(pETy); + A(pI32); + A(pETy); + break; - // Try to find existing function with the same name in the module. - // This needs to happen after the switch statement that constructs arguments - // and return values to ensure that ResRetType is constructed in the - // RefreshCache case. - if (Function *existF = m_pModule->getFunction(FuncName)) { - if (existF->getFunctionType() != pFT) - return nullptr; - F = existF; - UpdateCache(opClass, pOverloadType, F); - return F; - } + // Unary int + case OpCode::Bfrev: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::Countbits: + A(pI32); + A(pI32); + A(pETy); + break; + case OpCode::FirstbitLo: + A(pI32); + A(pI32); + A(pETy); + break; - F = cast(m_pModule->getOrInsertFunction(FuncName, pFT)); + // Unary uint + case OpCode::FirstbitHi: + A(pI32); + A(pI32); + A(pETy); + break; - UpdateCache(opClass, pOverloadType, F); - F->setCallingConv(CallingConv::C); - F->addFnAttr(Attribute::NoUnwind); - if (OpProps.FuncAttr != Attribute::None) - F->addFnAttr(OpProps.FuncAttr); + // Unary int + case OpCode::FirstbitSHi: + A(pI32); + A(pI32); + A(pETy); + break; - return F; -} + // Binary float + case OpCode::FMax: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + break; + case OpCode::FMin: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + break; -const SmallMapVector & -OP::GetOpFuncList(OpCode opCode) const { - return m_OpCodeClassCache[(unsigned)m_OpCodeProps[(unsigned)opCode] - .opCodeClass] - .pOverloads; -} + // Binary int + case OpCode::IMax: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + break; + case OpCode::IMin: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + break; -bool OP::IsDxilOpUsed(OpCode opcode) const { - auto &FnList = GetOpFuncList(opcode); - for (auto &it : FnList) { - llvm::Function *F = it.second; - if (!F) { - continue; - } - if (!F->user_empty()) { - return true; - } - } - return false; -} + // Binary uint + case OpCode::UMax: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + break; + case OpCode::UMin: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + break; -void OP::RemoveFunction(Function *F) { - if (OP::IsDxilOpFunc(F)) { - OpCodeClass opClass = m_FunctionToOpClass[F]; - for (auto it : m_OpCodeClassCache[(unsigned)opClass].pOverloads) { - if (it.second == F) { - m_OpCodeClassCache[(unsigned)opClass].pOverloads.erase(it.first); - m_FunctionToOpClass.erase(F); - break; - } - } - } -} + // Binary int with two outputs + case OpCode::IMul: + A(p2I32); + A(pI32); + A(pETy); + A(pETy); + break; -bool OP::GetOpCodeClass(const Function *F, OP::OpCodeClass &opClass) { - auto iter = m_FunctionToOpClass.find(F); - if (iter == m_FunctionToOpClass.end()) { - // When no user, cannot get opcode. - DXASSERT(F->user_empty() || !IsDxilOpFunc(F), - "dxil function without an opcode class mapping?"); - opClass = OP::OpCodeClass::NumOpClasses; - return false; - } - opClass = iter->second; - return true; -} + // Binary uint with two outputs + case OpCode::UMul: + A(p2I32); + A(pI32); + A(pETy); + A(pETy); + break; + case OpCode::UDiv: + A(p2I32); + A(pI32); + A(pETy); + A(pETy); + break; -bool OP::UseMinPrecision() { - return m_LowPrecisionMode == DXIL::LowPrecisionMode::UseMinPrecision; -} + // Binary uint with carry or borrow + case OpCode::UAddc: + A(pI32C); + A(pI32); + A(pETy); + A(pETy); + break; + case OpCode::USubb: + A(pI32C); + A(pI32); + A(pETy); + A(pETy); + break; -void OP::InitWithMinPrecision(bool bMinPrecision) { - DXIL::LowPrecisionMode mode = - bMinPrecision ? DXIL::LowPrecisionMode::UseMinPrecision - : DXIL::LowPrecisionMode::UseNativeLowPrecision; - DXASSERT((mode == m_LowPrecisionMode || - m_LowPrecisionMode == DXIL::LowPrecisionMode::Undefined), - "LowPrecisionMode should only be set once."); + // Tertiary float + case OpCode::FMad: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + break; + case OpCode::Fma: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + break; - if (mode != m_LowPrecisionMode) { - m_LowPrecisionMode = mode; + // Tertiary int + case OpCode::IMad: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + break; - // The following FixOverloadNames() and RefreshCache() calls interact with - // the type cache, which can only be correctly constructed once we know - // the min precision mode. That's why they are called here, rather than - // in the constructor. + // Tertiary uint + case OpCode::UMad: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + break; - // When loading a module into an existing context where types are merged, - // type names may change. When this happens, any intrinsics overloaded on - // UDT types will no longer have matching overload names. - // This causes RefreshCache() to assert. - // This fixes the function names to they match the expected types, - // preventing RefreshCache() from failing due to this issue. - FixOverloadNames(); + // Tertiary int + case OpCode::Msad: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + break; + case OpCode::Ibfe: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + break; - // Try to find existing intrinsic function. - RefreshCache(); - } -} + // Tertiary uint + case OpCode::Ubfe: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + break; -uint64_t OP::GetAllocSizeForType(llvm::Type *Ty) { - return m_pModule->getDataLayout().getTypeAllocSize(Ty); -} + // Quaternary + case OpCode::Bfi: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + break; -llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { - DXASSERT(F, "not work on nullptr"); - Type *Ty = F->getReturnType(); - FunctionType *FT = F->getFunctionType(); - LLVMContext &Ctx = F->getContext(); - // clang-format off - // Python lines need to be not formatted. - /* hctdb_instrhelp.get_funcs_oload_type()*/ - // clang-format on - switch (opCode) { // return OpCode - // OPCODE-OLOAD-TYPES:BEGIN - case OpCode::TempRegStore: - case OpCode::CallShader: - case OpCode::Pack4x8: - if (FT->getNumParams() <= 2) return nullptr; - return FT->getParamType(2); - case OpCode::MinPrecXRegStore: - case OpCode::StoreOutput: + // Dot + case OpCode::Dot2: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + break; + case OpCode::Dot3: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + break; + case OpCode::Dot4: + A(pETy); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + break; + + // Resources + case OpCode::CreateHandle: + A(pRes); + A(pI32); + A(pI8); + A(pI32); + A(pI32); + A(pI1); + break; + case OpCode::CBufferLoad: + A(pETy); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + break; + case OpCode::CBufferLoadLegacy: + CBRT(pETy); + A(pI32); + A(pRes); + A(pI32); + break; + + // Resources - sample + case OpCode::Sample: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + break; + case OpCode::SampleBias: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + A(pF32); + break; + case OpCode::SampleLevel: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + break; + case OpCode::SampleGrad: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + break; + case OpCode::SampleCmp: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + A(pF32); + break; + case OpCode::SampleCmpLevelZero: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + break; + + // Resources + case OpCode::TextureLoad: + RRT(pETy); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::TextureStore: + A(pV); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pI8); + break; + case OpCode::BufferLoad: + RRT(pETy); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + break; + case OpCode::BufferStore: + A(pV); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pI8); + break; + case OpCode::BufferUpdateCounter: + A(pI32); + A(pI32); + A(pRes); + A(pI8); + break; + case OpCode::CheckAccessFullyMapped: + A(pI1); + A(pI32); + A(pI32); + break; + case OpCode::GetDimensions: + A(pDim); + A(pI32); + A(pRes); + A(pI32); + break; + + // Resources - gather + case OpCode::TextureGather: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::TextureGatherCmp: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + break; + + // Resources - sample + case OpCode::Texture2DMSGetSamplePosition: + A(pPos); + A(pI32); + A(pRes); + A(pI32); + break; + case OpCode::RenderTargetGetSamplePosition: + A(pPos); + A(pI32); + A(pI32); + break; + case OpCode::RenderTargetGetSampleCount: + A(pI32); + A(pI32); + break; + + // Synchronization + case OpCode::AtomicBinOp: + A(pETy); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pETy); + break; + case OpCode::AtomicCompareExchange: + A(pETy); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + A(pETy); + A(pETy); + break; + case OpCode::Barrier: + A(pV); + A(pI32); + A(pI32); + break; + + // Derivatives + case OpCode::CalculateLOD: + A(pF32); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pI1); + break; + + // Pixel shader + case OpCode::Discard: + A(pV); + A(pI32); + A(pI1); + break; + + // Derivatives + case OpCode::DerivCoarseX: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::DerivCoarseY: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::DerivFineX: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::DerivFineY: + A(pETy); + A(pI32); + A(pETy); + break; + + // Pixel shader + case OpCode::EvalSnapped: + A(pETy); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pI32); + A(pI32); + break; + case OpCode::EvalSampleIndex: + A(pETy); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pI32); + break; + case OpCode::EvalCentroid: + A(pETy); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::SampleIndex: + A(pI32); + A(pI32); + break; + case OpCode::Coverage: + A(pI32); + A(pI32); + break; + case OpCode::InnerCoverage: + A(pI32); + A(pI32); + break; + + // Compute/Mesh/Amplification/Node shader + case OpCode::ThreadId: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::GroupId: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::ThreadIdInGroup: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::FlattenedThreadIdInGroup: + A(pI32); + A(pI32); + break; + + // Geometry shader + case OpCode::EmitStream: + A(pV); + A(pI32); + A(pI8); + break; + case OpCode::CutStream: + A(pV); + A(pI32); + A(pI8); + break; + case OpCode::EmitThenCutStream: + A(pV); + A(pI32); + A(pI8); + break; + case OpCode::GSInstanceID: + A(pI32); + A(pI32); + break; + + // Double precision + case OpCode::MakeDouble: + A(pF64); + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::SplitDouble: + A(pSDT); + A(pI32); + A(pF64); + break; + + // Domain and hull shader + case OpCode::LoadOutputControlPoint: + A(pETy); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pI32); + break; + case OpCode::LoadPatchConstant: + A(pETy); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + break; + + // Domain shader + case OpCode::DomainLocation: + A(pF32); + A(pI32); + A(pI8); + break; + + // Hull shader + case OpCode::StorePatchConstant: + A(pV); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pETy); + break; + case OpCode::OutputControlPointID: + A(pI32); + A(pI32); + break; + + // Hull, Domain and Geometry shaders + case OpCode::PrimitiveID: + A(pI32); + A(pI32); + break; + + // Other + case OpCode::CycleCounterLegacy: + A(p2I32); + A(pI32); + break; + + // Wave + case OpCode::WaveIsFirstLane: + A(pI1); + A(pI32); + break; + case OpCode::WaveGetLaneIndex: + A(pI32); + A(pI32); + break; + case OpCode::WaveGetLaneCount: + A(pI32); + A(pI32); + break; + case OpCode::WaveAnyTrue: + A(pI1); + A(pI32); + A(pI1); + break; + case OpCode::WaveAllTrue: + A(pI1); + A(pI32); + A(pI1); + break; + case OpCode::WaveActiveAllEqual: + A(pI1); + A(pI32); + A(pETy); + break; + case OpCode::WaveActiveBallot: + A(p4I32); + A(pI32); + A(pI1); + break; + case OpCode::WaveReadLaneAt: + A(pETy); + A(pI32); + A(pETy); + A(pI32); + break; + case OpCode::WaveReadLaneFirst: + A(pETy); + A(pI32); + A(pETy); + break; + case OpCode::WaveActiveOp: + A(pETy); + A(pI32); + A(pETy); + A(pI8); + A(pI8); + break; + case OpCode::WaveActiveBit: + A(pETy); + A(pI32); + A(pETy); + A(pI8); + break; + case OpCode::WavePrefixOp: + A(pETy); + A(pI32); + A(pETy); + A(pI8); + A(pI8); + break; + + // Quad Wave Ops + case OpCode::QuadReadLaneAt: + A(pETy); + A(pI32); + A(pETy); + A(pI32); + break; + case OpCode::QuadOp: + A(pETy); + A(pI32); + A(pETy); + A(pI8); + break; + + // Bitcasts with different sizes + case OpCode::BitcastI16toF16: + A(pF16); + A(pI32); + A(pI16); + break; + case OpCode::BitcastF16toI16: + A(pI16); + A(pI32); + A(pF16); + break; + case OpCode::BitcastI32toF32: + A(pF32); + A(pI32); + A(pI32); + break; + case OpCode::BitcastF32toI32: + A(pI32); + A(pI32); + A(pF32); + break; + case OpCode::BitcastI64toF64: + A(pF64); + A(pI32); + A(pI64); + break; + case OpCode::BitcastF64toI64: + A(pI64); + A(pI32); + A(pF64); + break; + + // Legacy floating-point + case OpCode::LegacyF32ToF16: + A(pI32); + A(pI32); + A(pF32); + break; + case OpCode::LegacyF16ToF32: + A(pF32); + A(pI32); + A(pI32); + break; + + // Double precision + case OpCode::LegacyDoubleToFloat: + A(pF32); + A(pI32); + A(pF64); + break; + case OpCode::LegacyDoubleToSInt32: + A(pI32); + A(pI32); + A(pF64); + break; + case OpCode::LegacyDoubleToUInt32: + A(pI32); + A(pI32); + A(pF64); + break; + + // Wave + case OpCode::WaveAllBitCount: + A(pI32); + A(pI32); + A(pI1); + break; + case OpCode::WavePrefixBitCount: + A(pI32); + A(pI32); + A(pI1); + break; + + // Pixel shader + case OpCode::AttributeAtVertex: + A(pETy); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pI8); + break; + + // Graphics shader + case OpCode::ViewID: + A(pI32); + A(pI32); + break; + + // Resources + case OpCode::RawBufferLoad: + RRT(pETy); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI8); + A(pI32); + break; + case OpCode::RawBufferStore: + A(pV); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pI8); + A(pI32); + break; + + // Raytracing object space uint System Values + case OpCode::InstanceID: + A(pI32); + A(pI32); + break; + case OpCode::InstanceIndex: + A(pI32); + A(pI32); + break; + + // Raytracing hit uint System Values + case OpCode::HitKind: + A(pI32); + A(pI32); + break; + + // Raytracing uint System Values + case OpCode::RayFlags: + A(pI32); + A(pI32); + break; + + // Ray Dispatch Arguments + case OpCode::DispatchRaysIndex: + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::DispatchRaysDimensions: + A(pI32); + A(pI32); + A(pI8); + break; + + // Ray Vectors + case OpCode::WorldRayOrigin: + A(pF32); + A(pI32); + A(pI8); + break; + case OpCode::WorldRayDirection: + A(pF32); + A(pI32); + A(pI8); + break; + + // Ray object space Vectors + case OpCode::ObjectRayOrigin: + A(pF32); + A(pI32); + A(pI8); + break; + case OpCode::ObjectRayDirection: + A(pF32); + A(pI32); + A(pI8); + break; + + // Ray Transforms + case OpCode::ObjectToWorld: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::WorldToObject: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + + // RayT + case OpCode::RayTMin: + A(pF32); + A(pI32); + break; + case OpCode::RayTCurrent: + A(pF32); + A(pI32); + break; + + // AnyHit Terminals + case OpCode::IgnoreHit: + A(pV); + A(pI32); + break; + case OpCode::AcceptHitAndEndSearch: + A(pV); + A(pI32); + break; + + // Indirect Shader Invocation + case OpCode::TraceRay: + A(pV); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(udt); + break; + case OpCode::ReportHit: + A(pI1); + A(pI32); + A(pF32); + A(pI32); + A(udt); + break; + case OpCode::CallShader: + A(pV); + A(pI32); + A(pI32); + A(udt); + break; + + // Library create handle from resource struct (like HL intrinsic) + case OpCode::CreateHandleForLib: + A(pRes); + A(pI32); + A(obj); + break; + + // Raytracing object space uint System Values + case OpCode::PrimitiveIndex: + A(pI32); + A(pI32); + break; + + // Dot product with accumulate + case OpCode::Dot2AddHalf: + A(pETy); + A(pI32); + A(pETy); + A(pF16); + A(pF16); + A(pF16); + A(pF16); + break; + case OpCode::Dot4AddI8Packed: + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::Dot4AddU8Packed: + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + break; + + // Wave + case OpCode::WaveMatch: + A(p4I32); + A(pI32); + A(pETy); + break; + case OpCode::WaveMultiPrefixOp: + A(pETy); + A(pI32); + A(pETy); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pI8); + break; + case OpCode::WaveMultiPrefixBitCount: + A(pI32); + A(pI32); + A(pI1); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + break; + + // Mesh shader instructions + case OpCode::SetMeshOutputCounts: + A(pV); + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::EmitIndices: + A(pV); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::GetMeshPayload: + A(pETy); + A(pI32); + break; + case OpCode::StoreVertexOutput: + A(pV); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pETy); + A(pI32); + break; + case OpCode::StorePrimitiveOutput: + A(pV); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + A(pETy); + A(pI32); + break; + + // Amplification shader instructions + case OpCode::DispatchMesh: + A(pV); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pETy); + break; + + // Sampler Feedback + case OpCode::WriteSamplerFeedback: + A(pV); + A(pI32); + A(pRes); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + break; + case OpCode::WriteSamplerFeedbackBias: + A(pV); + A(pI32); + A(pRes); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + break; + case OpCode::WriteSamplerFeedbackLevel: + A(pV); + A(pI32); + A(pRes); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + break; + case OpCode::WriteSamplerFeedbackGrad: + A(pV); + A(pI32); + A(pRes); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + break; + + // Inline Ray Query + case OpCode::AllocateRayQuery: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_TraceRayInline: + A(pV); + A(pI32); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + break; + case OpCode::RayQuery_Proceed: + A(pI1); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_Abort: + A(pV); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CommitNonOpaqueTriangleHit: + A(pV); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CommitProceduralPrimitiveHit: + A(pV); + A(pI32); + A(pI32); + A(pF32); + break; + case OpCode::RayQuery_CommittedStatus: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidateType: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidateObjectToWorld3x4: + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_CandidateWorldToObject3x4: + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_CommittedObjectToWorld3x4: + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_CommittedWorldToObject3x4: + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_CandidateProceduralPrimitiveNonOpaque: + A(pI1); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidateTriangleFrontFace: + A(pI1); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CommittedTriangleFrontFace: + A(pI1); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidateTriangleBarycentrics: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_CommittedTriangleBarycentrics: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_RayFlags: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_WorldRayOrigin: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_WorldRayDirection: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_RayTMin: + A(pF32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidateTriangleRayT: + A(pF32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CommittedRayT: + A(pF32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidateInstanceIndex: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidateInstanceID: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidateGeometryIndex: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidatePrimitiveIndex: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CandidateObjectRayOrigin: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_CandidateObjectRayDirection: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_CommittedInstanceIndex: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CommittedInstanceID: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CommittedGeometryIndex: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CommittedPrimitiveIndex: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CommittedObjectRayOrigin: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + case OpCode::RayQuery_CommittedObjectRayDirection: + A(pF32); + A(pI32); + A(pI32); + A(pI8); + break; + + // Raytracing object space uint System Values, raytracing tier 1.1 + case OpCode::GeometryIndex: + A(pI32); + A(pI32); + break; + + // Inline Ray Query + case OpCode::RayQuery_CandidateInstanceContributionToHitGroupIndex: + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RayQuery_CommittedInstanceContributionToHitGroupIndex: + A(pI32); + A(pI32); + A(pI32); + break; + + // Get handle from heap + case OpCode::AnnotateHandle: + A(pRes); + A(pI32); + A(pRes); + A(resProperty); + break; + case OpCode::CreateHandleFromBinding: + A(pRes); + A(pI32); + A(resBind); + A(pI32); + A(pI1); + break; + case OpCode::CreateHandleFromHeap: + A(pRes); + A(pI32); + A(pI32); + A(pI1); + A(pI1); + break; + + // Unpacking intrinsics + case OpCode::Unpack4x8: + VEC4(pETy); + A(pI32); + A(pI8); + A(pI32); + break; + + // Packing intrinsics + case OpCode::Pack4x8: + A(pI32); + A(pI32); + A(pI8); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + break; + + // Helper Lanes + case OpCode::IsHelperLane: + A(pI1); + A(pI32); + break; + + // Quad Wave Ops + case OpCode::QuadVote: + A(pI1); + A(pI32); + A(pI1); + A(pI8); + break; + + // Resources - gather + case OpCode::TextureGatherRaw: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + break; + + // Resources - sample + case OpCode::SampleCmpLevel: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + A(pF32); + break; + + // Resources + case OpCode::TextureStoreSample: + A(pV); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + A(pETy); + A(pETy); + A(pETy); + A(pETy); + A(pI8); + A(pI32); + break; + + // + case OpCode::Reserved0: + A(pV); + A(pI32); + break; + case OpCode::Reserved1: + A(pV); + A(pI32); + break; + case OpCode::Reserved2: + A(pV); + A(pI32); + break; + case OpCode::Reserved3: + A(pV); + A(pI32); + break; + case OpCode::Reserved4: + A(pV); + A(pI32); + break; + case OpCode::Reserved5: + A(pV); + A(pI32); + break; + case OpCode::Reserved6: + A(pV); + A(pI32); + break; + case OpCode::Reserved7: + A(pV); + A(pI32); + break; + case OpCode::Reserved8: + A(pV); + A(pI32); + break; + case OpCode::Reserved9: + A(pV); + A(pI32); + break; + case OpCode::Reserved10: + A(pV); + A(pI32); + break; + case OpCode::Reserved11: + A(pV); + A(pI32); + break; + + // Create/Annotate Node Handles + case OpCode::AllocateNodeOutputRecords: + A(pNodeRecordHandle); + A(pI32); + A(pNodeHandle); + A(pI32); + A(pI1); + break; + + // Get Pointer to Node Record in Address Space 6 + case OpCode::GetNodeRecordPtr: + A(pETy); + A(pI32); + A(pNodeRecordHandle); + A(pI32); + break; + + // Work Graph intrinsics + case OpCode::IncrementOutputCount: + A(pV); + A(pI32); + A(pNodeHandle); + A(pI32); + A(pI1); + break; + case OpCode::OutputComplete: + A(pV); + A(pI32); + A(pNodeRecordHandle); + break; + case OpCode::GetInputRecordCount: + A(pI32); + A(pI32); + A(pNodeRecordHandle); + break; + case OpCode::FinishedCrossGroupSharing: + A(pI1); + A(pI32); + A(pNodeRecordHandle); + break; + + // Synchronization + case OpCode::BarrierByMemoryType: + A(pV); + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::BarrierByMemoryHandle: + A(pV); + A(pI32); + A(pRes); + A(pI32); + break; + case OpCode::BarrierByNodeRecordHandle: + A(pV); + A(pI32); + A(pNodeRecordHandle); + A(pI32); + break; + + // Create/Annotate Node Handles + case OpCode::CreateNodeOutputHandle: + A(pNodeHandle); + A(pI32); + A(pI32); + break; + case OpCode::IndexNodeHandle: + A(pNodeHandle); + A(pI32); + A(pNodeHandle); + A(pI32); + break; + case OpCode::AnnotateNodeHandle: + A(pNodeHandle); + A(pI32); + A(pNodeHandle); + A(nodeProperty); + break; + case OpCode::CreateNodeInputRecordHandle: + A(pNodeRecordHandle); + A(pI32); + A(pI32); + break; + case OpCode::AnnotateNodeRecordHandle: + A(pNodeRecordHandle); + A(pI32); + A(pNodeRecordHandle); + A(nodeRecordProperty); + break; + + // Work Graph intrinsics + case OpCode::NodeOutputIsValid: + A(pI1); + A(pI32); + A(pNodeHandle); + break; + case OpCode::GetRemainingRecursionLevels: + A(pI32); + A(pI32); + break; + + // Comparison Samples + case OpCode::SampleCmpGrad: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + break; + case OpCode::SampleCmpBias: + RRT(pETy); + A(pI32); + A(pRes); + A(pRes); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + A(pF32); + A(pF32); + break; + + // Extended Command Information + case OpCode::StartVertexLocation: + A(pI32); + A(pI32); + break; + case OpCode::StartInstanceLocation: + A(pI32); + A(pI32); + break; + + // Inline Ray Query + case OpCode::AllocateRayQuery2: + A(pI32); + A(pI32); + A(pI32); + A(pI32); + break; + + // + case OpCode::ReservedA0: + A(pV); + A(pI32); + break; + case OpCode::ReservedA1: + A(pV); + A(pI32); + break; + case OpCode::ReservedA2: + A(pV); + A(pI32); + break; + case OpCode::ReservedB0: + A(pV); + A(pI32); + break; + case OpCode::ReservedB1: + A(pV); + A(pI32); + break; + case OpCode::ReservedB2: + A(pV); + A(pI32); + break; + + // Shader Execution Reordering + case OpCode::HitObject_MakeMiss: + A(pHit); + A(pI32); + A(pI32); + A(pI32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + A(pF32); + break; + case OpCode::HitObject_MakeNop: + A(pHit); + A(pI32); + break; + + // + case OpCode::ReservedB5: + A(pV); + A(pI32); + break; + case OpCode::ReservedB6: + A(pV); + A(pI32); + break; + case OpCode::ReservedB7: + A(pV); + A(pI32); + break; + case OpCode::ReservedB8: + A(pV); + A(pI32); + break; + case OpCode::ReservedB9: + A(pV); + A(pI32); + break; + case OpCode::ReservedB10: + A(pV); + A(pI32); + break; + case OpCode::ReservedB11: + A(pV); + A(pI32); + break; + case OpCode::ReservedB12: + A(pV); + A(pI32); + break; + case OpCode::ReservedB13: + A(pV); + A(pI32); + break; + case OpCode::ReservedB14: + A(pV); + A(pI32); + break; + case OpCode::ReservedB15: + A(pV); + A(pI32); + break; + case OpCode::ReservedB16: + A(pV); + A(pI32); + break; + case OpCode::ReservedB17: + A(pV); + A(pI32); + break; + case OpCode::ReservedB18: + A(pV); + A(pI32); + break; + case OpCode::ReservedB19: + A(pV); + A(pI32); + break; + case OpCode::ReservedB20: + A(pV); + A(pI32); + break; + case OpCode::ReservedB21: + A(pV); + A(pI32); + break; + case OpCode::ReservedB22: + A(pV); + A(pI32); + break; + case OpCode::ReservedB23: + A(pV); + A(pI32); + break; + case OpCode::ReservedB24: + A(pV); + A(pI32); + break; + case OpCode::ReservedB25: + A(pV); + A(pI32); + break; + case OpCode::ReservedB26: + A(pV); + A(pI32); + break; + case OpCode::ReservedB27: + A(pV); + A(pI32); + break; + case OpCode::ReservedB28: + A(pV); + A(pI32); + break; + case OpCode::ReservedB29: + A(pV); + A(pI32); + break; + case OpCode::ReservedB30: + A(pV); + A(pI32); + break; + case OpCode::ReservedC0: + A(pV); + A(pI32); + break; + case OpCode::ReservedC1: + A(pV); + A(pI32); + break; + case OpCode::ReservedC2: + A(pV); + A(pI32); + break; + case OpCode::ReservedC3: + A(pV); + A(pI32); + break; + case OpCode::ReservedC4: + A(pV); + A(pI32); + break; + case OpCode::ReservedC5: + A(pV); + A(pI32); + break; + case OpCode::ReservedC6: + A(pV); + A(pI32); + break; + case OpCode::ReservedC7: + A(pV); + A(pI32); + break; + case OpCode::ReservedC8: + A(pV); + A(pI32); + break; + case OpCode::ReservedC9: + A(pV); + A(pI32); + break; + case OpCode::RawBufferVectorLoad: + RRT(pETy); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::RawBufferVectorStore: + A(pV); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pETy); + A(pI32); + break; + case OpCode::MatVecMul: + EXT(0); + A(pI32); + EXT(1); + A(pI1); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI1); + A(pI32); + A(pI1); + break; + case OpCode::MatVecMulAdd: + EXT(0); + A(pI32); + EXT(1); + A(pI1); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + A(pI1); + A(pI32); + A(pRes); + A(pI32); + A(pI32); + A(pI1); + break; + case OpCode::OuterProductAccumulate: + A(pV); + A(pI32); + EXT(0); + EXT(1); + A(pRes); + A(pI32); + A(pI32); + A(pI32); + A(pI32); + break; + case OpCode::VectorAccumulate: + A(pV); + A(pI32); + A(pETy); + A(pRes); + A(pI32); + break; + // OPCODE-OLOAD-FUNCS:END + default: + DXASSERT(false, "otherwise unhandled case"); + break; + } +#undef RRT +#undef A + + FunctionType *pFT; + DXASSERT(ArgTypes.size() > 1, "otherwise forgot to initialize arguments"); + pFT = FunctionType::get( + ArgTypes[0], ArrayRef(&ArgTypes[1], ArgTypes.size() - 1), false); + + SmallVector FuncStorage; + StringRef FuncName = + ConstructOverloadName(pOverloadType, opCode, FuncStorage); + + // Try to find existing function with the same name in the module. + // This needs to happen after the switch statement that constructs arguments + // and return values to ensure that ResRetType is constructed in the + // RefreshCache case. + if (Function *existF = m_pModule->getFunction(FuncName)) { + if (existF->getFunctionType() != pFT) + return nullptr; + F = existF; + UpdateCache(opClass, pOverloadType, F); + return F; + } + + F = cast(m_pModule->getOrInsertFunction(FuncName, pFT)); + + UpdateCache(opClass, pOverloadType, F); + F->setCallingConv(CallingConv::C); + F->addFnAttr(Attribute::NoUnwind); + if (OpProps.FuncAttr != Attribute::None) + F->addFnAttr(OpProps.FuncAttr); + + return F; +} + +const SmallMapVector & +OP::GetOpFuncList(OpCode opCode) const { + return m_OpCodeClassCache[(unsigned)m_OpCodeProps[(unsigned)opCode] + .opCodeClass] + .pOverloads; +} + +bool OP::IsDxilOpUsed(OpCode opcode) const { + auto &FnList = GetOpFuncList(opcode); + for (auto &it : FnList) { + llvm::Function *F = it.second; + if (!F) { + continue; + } + if (!F->user_empty()) { + return true; + } + } + return false; +} + +void OP::RemoveFunction(Function *F) { + if (OP::IsDxilOpFunc(F)) { + OpCodeClass opClass = m_FunctionToOpClass[F]; + for (auto it : m_OpCodeClassCache[(unsigned)opClass].pOverloads) { + if (it.second == F) { + m_OpCodeClassCache[(unsigned)opClass].pOverloads.erase(it.first); + m_FunctionToOpClass.erase(F); + break; + } + } + } +} + +bool OP::GetOpCodeClass(const Function *F, OP::OpCodeClass &opClass) { + auto iter = m_FunctionToOpClass.find(F); + if (iter == m_FunctionToOpClass.end()) { + // When no user, cannot get opcode. + DXASSERT(F->user_empty() || !IsDxilOpFunc(F), + "dxil function without an opcode class mapping?"); + opClass = OP::OpCodeClass::NumOpClasses; + return false; + } + opClass = iter->second; + return true; +} + +bool OP::UseMinPrecision() { + return m_LowPrecisionMode == DXIL::LowPrecisionMode::UseMinPrecision; +} + +void OP::InitWithMinPrecision(bool bMinPrecision) { + DXIL::LowPrecisionMode mode = + bMinPrecision ? DXIL::LowPrecisionMode::UseMinPrecision + : DXIL::LowPrecisionMode::UseNativeLowPrecision; + DXASSERT((mode == m_LowPrecisionMode || + m_LowPrecisionMode == DXIL::LowPrecisionMode::Undefined), + "LowPrecisionMode should only be set once."); + + if (mode != m_LowPrecisionMode) { + m_LowPrecisionMode = mode; + + // The following FixOverloadNames() and RefreshCache() calls interact with + // the type cache, which can only be correctly constructed once we know + // the min precision mode. That's why they are called here, rather than + // in the constructor. + + // When loading a module into an existing context where types are merged, + // type names may change. When this happens, any intrinsics overloaded on + // UDT types will no longer have matching overload names. + // This causes RefreshCache() to assert. + // This fixes the function names to they match the expected types, + // preventing RefreshCache() from failing due to this issue. + FixOverloadNames(); + + // Try to find existing intrinsic function. + RefreshCache(); + } +} + +uint64_t OP::GetAllocSizeForType(llvm::Type *Ty) { + return m_pModule->getDataLayout().getTypeAllocSize(Ty); +} + +llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { + DXASSERT(F, "not work on nullptr"); + Type *Ty = F->getReturnType(); + FunctionType *FT = F->getFunctionType(); + LLVMContext &Ctx = F->getContext(); + // clang-format off + // Python lines need to be not formatted. + /* hctdb_instrhelp.get_funcs_oload_type()*/ + // clang-format on + switch (opCode) { // return OpCode + // OPCODE-OLOAD-TYPES:BEGIN + case OpCode::TempRegStore: + case OpCode::CallShader: + case OpCode::Pack4x8: + if (FT->getNumParams() <= 2) + return nullptr; + return FT->getParamType(2); + case OpCode::MinPrecXRegStore: + case OpCode::StoreOutput: case OpCode::BufferStore: case OpCode::StorePatchConstant: case OpCode::RawBufferStore: @@ -2171,7 +6009,8 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::StorePrimitiveOutput: case OpCode::DispatchMesh: case OpCode::RawBufferVectorStore: - if (FT->getNumParams() <= 4) return nullptr; + if (FT->getNumParams() <= 4) + return nullptr; return FT->getParamType(4); case OpCode::IsNaN: case OpCode::IsInf: @@ -2190,17 +6029,21 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::CreateHandleForLib: case OpCode::WaveMatch: case OpCode::VectorAccumulate: - if (FT->getNumParams() <= 1) return nullptr; + if (FT->getNumParams() <= 1) + return nullptr; return FT->getParamType(1); case OpCode::TextureStore: case OpCode::TextureStoreSample: - if (FT->getNumParams() <= 5) return nullptr; + if (FT->getNumParams() <= 5) + return nullptr; return FT->getParamType(5); case OpCode::TraceRay: - if (FT->getNumParams() <= 15) return nullptr; + if (FT->getNumParams() <= 15) + return nullptr; return FT->getParamType(15); case OpCode::ReportHit: - if (FT->getNumParams() <= 3) return nullptr; + if (FT->getNumParams() <= 3) + return nullptr; return FT->getParamType(3); case OpCode::CreateHandle: case OpCode::BufferUpdateCounter: @@ -2414,8 +6257,7 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::SampleCmpLevel: case OpCode::SampleCmpGrad: case OpCode::SampleCmpBias: - case OpCode::RawBufferVectorLoad: - { + case OpCode::RawBufferVectorLoad: { StructType *ST = cast(Ty); return ST->getElementType(0); } @@ -2423,13 +6265,15 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::MatVecMulAdd: if (FT->getNumParams() < 2) return nullptr; - return llvm::StructType::get(Ctx, {FT->getReturnType(), FT->getParamType(1)}); - + return llvm::StructType::get(Ctx, + {FT->getReturnType(), FT->getParamType(1)}); + case OpCode::OuterProductAccumulate: if (FT->getNumParams() < 3) return nullptr; - return llvm::StructType::get(Ctx, {FT->getParamType(1), FT->getParamType(2)}); - + return llvm::StructType::get(Ctx, + {FT->getParamType(1), FT->getParamType(2)}); + // OPCODE-OLOAD-TYPES:END default: return Ty; diff --git a/lib/DXIL/DxilShaderModel.cpp b/lib/DXIL/DxilShaderModel.cpp index c8e08a9231..861e8586e0 100644 --- a/lib/DXIL/DxilShaderModel.cpp +++ b/lib/DXIL/DxilShaderModel.cpp @@ -79,111 +79,114 @@ const ShaderModel *ShaderModel::Get(Kind Kind, unsigned Major, unsigned Minor) { /* hctdb_instrhelp.get_shader_model_get()*/ // VALRULE-TEXT:BEGIN const static std::pair hashToIdxMap[] = { - {1024,0}, //ps_4_0 - {1025,1}, //ps_4_1 - {1280,2}, //ps_5_0 - {1281,3}, //ps_5_1 - {1536,4}, //ps_6_0 - {1537,5}, //ps_6_1 - {1538,6}, //ps_6_2 - {1539,7}, //ps_6_3 - {1540,8}, //ps_6_4 - {1541,9}, //ps_6_5 - {1542,10}, //ps_6_6 - {1543,11}, //ps_6_7 - {1544,12}, //ps_6_8 - {1545,13}, //ps_6_9 - {66560,14}, //vs_4_0 - {66561,15}, //vs_4_1 - {66816,16}, //vs_5_0 - {66817,17}, //vs_5_1 - {67072,18}, //vs_6_0 - {67073,19}, //vs_6_1 - {67074,20}, //vs_6_2 - {67075,21}, //vs_6_3 - {67076,22}, //vs_6_4 - {67077,23}, //vs_6_5 - {67078,24}, //vs_6_6 - {67079,25}, //vs_6_7 - {67080,26}, //vs_6_8 - {67081,27}, //vs_6_9 - {132096,28}, //gs_4_0 - {132097,29}, //gs_4_1 - {132352,30}, //gs_5_0 - {132353,31}, //gs_5_1 - {132608,32}, //gs_6_0 - {132609,33}, //gs_6_1 - {132610,34}, //gs_6_2 - {132611,35}, //gs_6_3 - {132612,36}, //gs_6_4 - {132613,37}, //gs_6_5 - {132614,38}, //gs_6_6 - {132615,39}, //gs_6_7 - {132616,40}, //gs_6_8 - {132617,41}, //gs_6_9 - {197888,42}, //hs_5_0 - {197889,43}, //hs_5_1 - {198144,44}, //hs_6_0 - {198145,45}, //hs_6_1 - {198146,46}, //hs_6_2 - {198147,47}, //hs_6_3 - {198148,48}, //hs_6_4 - {198149,49}, //hs_6_5 - {198150,50}, //hs_6_6 - {198151,51}, //hs_6_7 - {198152,52}, //hs_6_8 - {198153,53}, //hs_6_9 - {263424,54}, //ds_5_0 - {263425,55}, //ds_5_1 - {263680,56}, //ds_6_0 - {263681,57}, //ds_6_1 - {263682,58}, //ds_6_2 - {263683,59}, //ds_6_3 - {263684,60}, //ds_6_4 - {263685,61}, //ds_6_5 - {263686,62}, //ds_6_6 - {263687,63}, //ds_6_7 - {263688,64}, //ds_6_8 - {263689,65}, //ds_6_9 - {328704,66}, //cs_4_0 - {328705,67}, //cs_4_1 - {328960,68}, //cs_5_0 - {328961,69}, //cs_5_1 - {329216,70}, //cs_6_0 - {329217,71}, //cs_6_1 - {329218,72}, //cs_6_2 - {329219,73}, //cs_6_3 - {329220,74}, //cs_6_4 - {329221,75}, //cs_6_5 - {329222,76}, //cs_6_6 - {329223,77}, //cs_6_7 - {329224,78}, //cs_6_8 - {329225,79}, //cs_6_9 - {394753,80}, //lib_6_1 - {394754,81}, //lib_6_2 - {394755,82}, //lib_6_3 - {394756,83}, //lib_6_4 - {394757,84}, //lib_6_5 - {394758,85}, //lib_6_6 - {394759,86}, //lib_6_7 - {394760,87}, //lib_6_8 - {394761,88}, //lib_6_9 - // lib_6_x is for offline linking only, and relaxes restrictions - {394767,89},//lib_6_x - {853509,90}, //ms_6_5 - {853510,91}, //ms_6_6 - {853511,92}, //ms_6_7 - {853512,93}, //ms_6_8 - {853513,94}, //ms_6_9 - {919045,95}, //as_6_5 - {919046,96}, //as_6_6 - {919047,97}, //as_6_7 - {919048,98}, //as_6_8 - {919049,99}, //as_6_9 + {1024, 0}, // ps_4_0 + {1025, 1}, // ps_4_1 + {1280, 2}, // ps_5_0 + {1281, 3}, // ps_5_1 + {1536, 4}, // ps_6_0 + {1537, 5}, // ps_6_1 + {1538, 6}, // ps_6_2 + {1539, 7}, // ps_6_3 + {1540, 8}, // ps_6_4 + {1541, 9}, // ps_6_5 + {1542, 10}, // ps_6_6 + {1543, 11}, // ps_6_7 + {1544, 12}, // ps_6_8 + {1545, 13}, // ps_6_9 + {66560, 14}, // vs_4_0 + {66561, 15}, // vs_4_1 + {66816, 16}, // vs_5_0 + {66817, 17}, // vs_5_1 + {67072, 18}, // vs_6_0 + {67073, 19}, // vs_6_1 + {67074, 20}, // vs_6_2 + {67075, 21}, // vs_6_3 + {67076, 22}, // vs_6_4 + {67077, 23}, // vs_6_5 + {67078, 24}, // vs_6_6 + {67079, 25}, // vs_6_7 + {67080, 26}, // vs_6_8 + {67081, 27}, // vs_6_9 + {132096, 28}, // gs_4_0 + {132097, 29}, // gs_4_1 + {132352, 30}, // gs_5_0 + {132353, 31}, // gs_5_1 + {132608, 32}, // gs_6_0 + {132609, 33}, // gs_6_1 + {132610, 34}, // gs_6_2 + {132611, 35}, // gs_6_3 + {132612, 36}, // gs_6_4 + {132613, 37}, // gs_6_5 + {132614, 38}, // gs_6_6 + {132615, 39}, // gs_6_7 + {132616, 40}, // gs_6_8 + {132617, 41}, // gs_6_9 + {197888, 42}, // hs_5_0 + {197889, 43}, // hs_5_1 + {198144, 44}, // hs_6_0 + {198145, 45}, // hs_6_1 + {198146, 46}, // hs_6_2 + {198147, 47}, // hs_6_3 + {198148, 48}, // hs_6_4 + {198149, 49}, // hs_6_5 + {198150, 50}, // hs_6_6 + {198151, 51}, // hs_6_7 + {198152, 52}, // hs_6_8 + {198153, 53}, // hs_6_9 + {263424, 54}, // ds_5_0 + {263425, 55}, // ds_5_1 + {263680, 56}, // ds_6_0 + {263681, 57}, // ds_6_1 + {263682, 58}, // ds_6_2 + {263683, 59}, // ds_6_3 + {263684, 60}, // ds_6_4 + {263685, 61}, // ds_6_5 + {263686, 62}, // ds_6_6 + {263687, 63}, // ds_6_7 + {263688, 64}, // ds_6_8 + {263689, 65}, // ds_6_9 + {328704, 66}, // cs_4_0 + {328705, 67}, // cs_4_1 + {328960, 68}, // cs_5_0 + {328961, 69}, // cs_5_1 + {329216, 70}, // cs_6_0 + {329217, 71}, // cs_6_1 + {329218, 72}, // cs_6_2 + {329219, 73}, // cs_6_3 + {329220, 74}, // cs_6_4 + {329221, 75}, // cs_6_5 + {329222, 76}, // cs_6_6 + {329223, 77}, // cs_6_7 + {329224, 78}, // cs_6_8 + {329225, 79}, // cs_6_9 + {394753, 80}, // lib_6_1 + {394754, 81}, // lib_6_2 + {394755, 82}, // lib_6_3 + {394756, 83}, // lib_6_4 + {394757, 84}, // lib_6_5 + {394758, 85}, // lib_6_6 + {394759, 86}, // lib_6_7 + {394760, 87}, // lib_6_8 + {394761, 88}, // lib_6_9 + // lib_6_x is for offline linking only, and relaxes restrictions + {394767, 89}, // lib_6_x + {853509, 90}, // ms_6_5 + {853510, 91}, // ms_6_6 + {853511, 92}, // ms_6_7 + {853512, 93}, // ms_6_8 + {853513, 94}, // ms_6_9 + {919045, 95}, // as_6_5 + {919046, 96}, // as_6_6 + {919047, 97}, // as_6_7 + {919048, 98}, // as_6_8 + {919049, 99}, // as_6_9 }; unsigned hash = (unsigned)Kind << 16 | Major << 8 | Minor; - auto pred = [](const std::pair& elem, unsigned val){ return elem.first < val;}; - auto it = std::lower_bound(std::begin(hashToIdxMap), std::end(hashToIdxMap), hash, pred); + auto pred = [](const std::pair &elem, unsigned val) { + return elem.first < val; + }; + auto it = std::lower_bound(std::begin(hashToIdxMap), std::end(hashToIdxMap), + hash, pred); if (it == std::end(hashToIdxMap) || it->first != hash) return GetInvalid(); return &ms_ShaderModels[it->second]; @@ -291,50 +294,50 @@ const ShaderModel *ShaderModel::GetByName(llvm::StringRef Name) { if (Major == 6) { Minor = 2; break; - } - else return GetInvalid(); + } else + return GetInvalid(); case '3': if (Major == 6) { Minor = 3; break; - } - else return GetInvalid(); + } else + return GetInvalid(); case '4': if (Major == 6) { Minor = 4; break; - } - else return GetInvalid(); + } else + return GetInvalid(); case '5': if (Major == 6) { Minor = 5; break; - } - else return GetInvalid(); + } else + return GetInvalid(); case '6': if (Major == 6) { Minor = 6; break; - } - else return GetInvalid(); + } else + return GetInvalid(); case '7': if (Major == 6) { Minor = 7; break; - } - else return GetInvalid(); + } else + return GetInvalid(); case '8': if (Major == 6) { Minor = 8; break; - } - else return GetInvalid(); + } else + return GetInvalid(); case '9': if (Major == 6) { Minor = 9; break; - } - else return GetInvalid(); + } else + return GetInvalid(); // VALRULE-TEXT:END case 'x': if (kind == Kind::Library && Major == 6) { @@ -656,7 +659,8 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Library, 6, 8, "lib_6_8", 32, 32, true, true, UINT_MAX), SM(Kind::Library, 6, 9, "lib_6_9", 32, 32, true, true, UINT_MAX), // lib_6_x is for offline linking only, and relaxes restrictions - SM(Kind::Library, 6, kOfflineMinor, "lib_6_x", 32, 32, true, true, UINT_MAX), + SM(Kind::Library, 6, kOfflineMinor, "lib_6_x", 32, 32, true, true, + UINT_MAX), SM(Kind::Mesh, 6, 5, "ms_6_5", 0, 0, true, true, UINT_MAX), SM(Kind::Mesh, 6, 6, "ms_6_6", 0, 0, true, true, UINT_MAX), SM(Kind::Mesh, 6, 7, "ms_6_7", 0, 0, true, true, UINT_MAX), @@ -668,7 +672,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Amplification, 6, 8, "as_6_8", 0, 0, true, true, UINT_MAX), SM(Kind::Amplification, 6, 9, "as_6_9", 0, 0, true, true, UINT_MAX), // Values before Invalid must remain sorted by Kind, then Major, then Minor. - SM(Kind::Invalid, 0, 0, "invalid", 0, 0, false, false, 0), + SM(Kind::Invalid, 0, 0, "invalid", 0, 0, false, false, 0), // VALRULE-TEXT:END }; diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index 82a06cd047..391617ac6b 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -6311,28 +6311,36 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); // input - Value *inputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulInputVectorIdx); - Value *isInputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsInputUnsignedIdx); + Value *inputVector = + CI->getArgOperand(HLOperandIndex::kMatVecMulInputVectorIdx); + Value *isInputUnsigned = + CI->getArgOperand(HLOperandIndex::kMatVecMulIsInputUnsignedIdx); Value *inputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulInputInterpretationIdx); // matrix - Value *matrixBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixBufferIdx); - Value *matrixOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixOffsetIdx); + Value *matrixBuffer = + CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixBufferIdx); + Value *matrixOffset = + CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixOffsetIdx); Value *matrixInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixInterpretationIdx); Value *matrixM = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixMIdx); Value *matrixK = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixKIdx); - Value *matrixLayout = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixLayoutIdx); + Value *matrixLayout = + CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixLayoutIdx); Value *matrixTranspose = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixTransposeIdx); - Value *matrixStride = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixStrideIdx); + Value *matrixStride = + CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixStrideIdx); // output - Value *isOutputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsOutputUnsignedIdx); + Value *isOutputUnsigned = + CI->getArgOperand(HLOperandIndex::kMatVecMulIsOutputUnsignedIdx); - Function *dxilFunc = - hlslOP->GetOpFunc(opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx) - ->getType() - ->getPointerElementType(), inputVector->getType()}); + Function *dxilFunc = hlslOP->GetOpFunc( + opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx) + ->getType() + ->getPointerElementType(), + inputVector->getType()}); Value *NewCI = Builder.CreateCall( dxilFunc, @@ -6340,48 +6348,60 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, matrixOffset, matrixInterpretation, matrixM, matrixK, matrixLayout, matrixTranspose, matrixStride, isOutputUnsigned}); - Value *OutParam = CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx); + Value *OutParam = + CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx); Builder.CreateStore(NewCI, OutParam); return nullptr; } Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, - HLOperationLowerHelper &helper, - HLObjectOperationLowerHelper *pObjHelper, - bool &Translated) { + HLOperationLowerHelper &helper, + HLObjectOperationLowerHelper *pObjHelper, + bool &Translated) { hlsl::OP *hlslOP = &helper.hlslOP; IRBuilder<> Builder(CI); Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); // input vector - Value *inputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputVectorIdx); - Value *isInputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsInputUnsignedIdx); + Value *inputVector = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputVectorIdx); + Value *isInputUnsigned = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsInputUnsignedIdx); Value *inputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputInterpretationIdx); - // matrix - Value *matrixBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixBufferIdx); - Value *matrixOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixOffsetIdx); + // matrix + Value *matrixBuffer = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixBufferIdx); + Value *matrixOffset = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixOffsetIdx); Value *matrixInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixInterpretationIdx); Value *matrixM = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixMIdx); Value *matrixK = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixKIdx); - Value *matrixLayout = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixLayoutIdx); + Value *matrixLayout = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixLayoutIdx); Value *matrixTranspose = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixTransposeIdx); - Value *matrixStride = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixStrideIdx); + Value *matrixStride = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixStrideIdx); // bias - Value *biasBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasBufferIdx); - Value *biasOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasOffsetIdx); - Value *biasInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasInterpretationIdx); + Value *biasBuffer = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasBufferIdx); + Value *biasOffset = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasOffsetIdx); + Value *biasInterpretation = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasInterpretationIdx); // output - Value *isOutputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsOutputUnsignedIdx); + Value *isOutputUnsigned = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsOutputUnsignedIdx); - Function *dxilFunc = - hlslOP->GetOpFunc(opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx) - ->getType() - ->getPointerElementType(), inputVector->getType()}); + Function *dxilFunc = hlslOP->GetOpFunc( + opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx) + ->getType() + ->getPointerElementType(), + inputVector->getType()}); Value *NewCI = Builder.CreateCall( dxilFunc, {opArg, inputVector, isInputUnsigned, inputInterpretation, @@ -6389,44 +6409,53 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, matrixK, matrixLayout, matrixTranspose, matrixStride, biasBuffer, biasOffset, biasInterpretation, isOutputUnsigned}); - Value *OutParam = CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx); + Value *OutParam = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx); Builder.CreateStore(NewCI, OutParam); return nullptr; } -Value *TranslateOuterProductAccumulate(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, - HLOperationLowerHelper &helper, - HLObjectOperationLowerHelper *pObjHelper, - bool &Translated) { +Value *TranslateOuterProductAccumulate(CallInst *CI, IntrinsicOp IOP, + OP::OpCode opcode, + HLOperationLowerHelper &helper, + HLObjectOperationLowerHelper *pObjHelper, + bool &Translated) { hlsl::OP *hlslOP = &helper.hlslOP; IRBuilder<> Builder(CI); Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); // input - Value *inputVector1 = CI->getArgOperand(HLOperandIndex::kOuterProdAccInputVec1Idx); - Value *inputVector2 = CI->getArgOperand(HLOperandIndex::kOuterProdAccInputVec2Idx); + Value *inputVector1 = + CI->getArgOperand(HLOperandIndex::kOuterProdAccInputVec1Idx); + Value *inputVector2 = + CI->getArgOperand(HLOperandIndex::kOuterProdAccInputVec2Idx); // matrix - Value *matrixBuffer = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixIdx); - Value *matrixOffset = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixOffsetIdx); + Value *matrixBuffer = + CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixIdx); + Value *matrixOffset = + CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixOffsetIdx); Value *matrixInterpretation = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixInterpretationIdx); - Value *matrixLayout = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixLayoutIdx); - Value *matrixStride = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixStrideIdx); + Value *matrixLayout = + CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixLayoutIdx); + Value *matrixStride = + CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixStrideIdx); - Function *dxilFunc = - hlslOP->GetOpFunc(opcode, {inputVector1->getType(), inputVector2->getType()}); + Function *dxilFunc = hlslOP->GetOpFunc( + opcode, {inputVector1->getType(), inputVector2->getType()}); return Builder.CreateCall( dxilFunc, {opArg, inputVector1, inputVector2, matrixBuffer, matrixOffset, matrixInterpretation, matrixLayout, matrixStride}); } -Value *TranslateVectorAccumulate(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, - HLOperationLowerHelper &helper, - HLObjectOperationLowerHelper *pObjHelper, - bool &Translated) { +Value *TranslateVectorAccumulate(CallInst *CI, IntrinsicOp IOP, + OP::OpCode opcode, + HLOperationLowerHelper &helper, + HLObjectOperationLowerHelper *pObjHelper, + bool &Translated) { hlsl::OP *hlslOP = &helper.hlslOP; IRBuilder<> Builder(CI); @@ -6436,10 +6465,10 @@ Value *TranslateVectorAccumulate(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcod Value *inputVector = CI->getArgOperand(HLOperandIndex::kVectorAccInputVecIdx); // matrix Value *matrixBuffer = CI->getArgOperand(HLOperandIndex::kVectorAccMatrixIdx); - Value *matrixOffset = CI->getArgOperand(HLOperandIndex::kVectorAccMatrixOffsetIdx); - - Function *dxilFunc = - hlslOP->GetOpFunc(opcode, {inputVector->getType()}); + Value *matrixOffset = + CI->getArgOperand(HLOperandIndex::kVectorAccMatrixOffsetIdx); + + Function *dxilFunc = hlslOP->GetOpFunc(opcode, {inputVector->getType()}); return Builder.CreateCall(dxilFunc, {opArg, inputVector, matrixBuffer, matrixOffset}); @@ -6693,7 +6722,8 @@ IntrinsicLower gLowerTable[] = { {IntrinsicOp::IOP_asint16, TranslateBitcast, DXIL::OpCode::NumOpCodes}, {IntrinsicOp::IOP_asuint, TranslateAsUint, DXIL::OpCode::SplitDouble}, {IntrinsicOp::IOP_asuint16, TranslateAsUint, DXIL::OpCode::NumOpCodes}, - {IntrinsicOp::IOP_atan, TrivialVectorizableUnaryOperation, DXIL::OpCode::Atan}, + {IntrinsicOp::IOP_atan, TrivialVectorizableUnaryOperation, + DXIL::OpCode::Atan}, {IntrinsicOp::IOP_atan2, TranslateAtan2, DXIL::OpCode::NumOpCodes}, {IntrinsicOp::IOP_ceil, TrivialUnaryOperation, DXIL::OpCode::Round_pi}, {IntrinsicOp::IOP_clamp, TranslateClamp, DXIL::OpCode::NumOpCodes}, @@ -6784,7 +6814,8 @@ IntrinsicLower gLowerTable[] = { {IntrinsicOp::IOP_sqrt, TrivialUnaryOperation, DXIL::OpCode::Sqrt}, {IntrinsicOp::IOP_step, TranslateStep, DXIL::OpCode::NumOpCodes}, {IntrinsicOp::IOP_tan, TrivialUnaryOperation, DXIL::OpCode::Tan}, - {IntrinsicOp::IOP_tanh, TrivialVectorizableUnaryOperation, DXIL::OpCode::Htan}, + {IntrinsicOp::IOP_tanh, TrivialVectorizableUnaryOperation, + DXIL::OpCode::Htan}, {IntrinsicOp::IOP_tex1D, EmptyLower, DXIL::OpCode::NumOpCodes}, {IntrinsicOp::IOP_tex1Dbias, EmptyLower, DXIL::OpCode::NumOpCodes}, {IntrinsicOp::IOP_tex1Dgrad, EmptyLower, DXIL::OpCode::NumOpCodes}, From 6ec25f80e62e001513d46d1d0aa5dc121d65952a Mon Sep 17 00:00:00 2001 From: anupamac Date: Tue, 1 Apr 2025 19:09:17 -0700 Subject: [PATCH 06/93] Fix variable names per LLVM coding standards --- lib/HLSL/HLOperationLower.cpp | 206 +++++++++++++++++++--------------- 1 file changed, 117 insertions(+), 89 deletions(-) diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index 391617ac6b..88ed6d039f 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -6301,114 +6301,132 @@ Value *TranslateSelect(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, return Builder.CreateSelect(cond, t, f); } -Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, - HLOperationLowerHelper &helper, - HLObjectOperationLowerHelper *pObjHelper, +Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, + HLOperationLowerHelper &Helper, + HLObjectOperationLowerHelper *ObjHelper, bool &Translated) { - hlsl::OP *hlslOP = &helper.hlslOP; + hlsl::OP *HlslOp = &Helper.hlslOP; IRBuilder<> Builder(CI); - Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); - // input - Value *inputVector = + Constant *OpArg = HlslOp->GetU32Const(static_cast(OpCode)); + + // Input parameters + Value *InputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulInputVectorIdx); - Value *isInputUnsigned = + Value *IsInputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsInputUnsignedIdx); - Value *inputInterpretation = + Value *InputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulInputInterpretationIdx); - // matrix - Value *matrixBuffer = + + // Matrix parameters + Value *MatrixBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixBufferIdx); - Value *matrixOffset = + Value *MatrixOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixOffsetIdx); - Value *matrixInterpretation = + Value *MatrixInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixInterpretationIdx); - Value *matrixM = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixMIdx); - Value *matrixK = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixKIdx); - Value *matrixLayout = + Value *MatrixM = + CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixMIdx); + Value *MatrixK = + CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixKIdx); + Value *MatrixLayout = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixLayoutIdx); - Value *matrixTranspose = + Value *MatrixTranspose = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixTransposeIdx); - Value *matrixStride = + Value *MatrixStride = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixStrideIdx); - // output - Value *isOutputUnsigned = + + // Output parameters + Value *IsOutputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsOutputUnsignedIdx); - Function *dxilFunc = hlslOP->GetOpFunc( - opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx) + // Get the DXIL function for the operation + Function *DxilFunc = HlslOp->GetOpFunc( + OpCode, {CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx) ->getType() ->getPointerElementType(), - inputVector->getType()}); + InputVector->getType()}); + // Create a call to the DXIL function Value *NewCI = Builder.CreateCall( - dxilFunc, - {opArg, inputVector, isInputUnsigned, inputInterpretation, matrixBuffer, - matrixOffset, matrixInterpretation, matrixM, matrixK, matrixLayout, - matrixTranspose, matrixStride, isOutputUnsigned}); + DxilFunc, + {OpArg, InputVector, IsInputUnsigned, InputInterpretation, MatrixBuffer, + MatrixOffset, MatrixInterpretation, MatrixM, MatrixK, + MatrixLayout, MatrixTranspose, MatrixStride, IsOutputUnsigned}); + // Get the output parameter and store the result Value *OutParam = CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx); + Builder.CreateStore(NewCI, OutParam); return nullptr; } -Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, - HLOperationLowerHelper &helper, - HLObjectOperationLowerHelper *pObjHelper, +Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, + HLOperationLowerHelper &Helper, + HLObjectOperationLowerHelper *ObjHelper, bool &Translated) { - hlsl::OP *hlslOP = &helper.hlslOP; + hlsl::OP *HlslOp = &Helper.hlslOP; IRBuilder<> Builder(CI); - Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); - // input vector - Value *inputVector = + Constant *OpArg = HlslOp->GetU32Const(static_cast(OpCode)); + + // Input vector parameters + Value *InputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputVectorIdx); - Value *isInputUnsigned = + Value *IsInputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsInputUnsignedIdx); - Value *inputInterpretation = + Value *InputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputInterpretationIdx); - // matrix - Value *matrixBuffer = + + // Matrix parameters + Value *MatrixBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixBufferIdx); - Value *matrixOffset = + Value *MatrixOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixOffsetIdx); - Value *matrixInterpretation = + Value *MatrixInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixInterpretationIdx); - Value *matrixM = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixMIdx); - Value *matrixK = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixKIdx); - Value *matrixLayout = + Value *MatrixM = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixMIdx); + Value *MatrixK = + CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixKIdx); + Value *MatrixLayout = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixLayoutIdx); - Value *matrixTranspose = + Value *MatrixTranspose = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixTransposeIdx); - Value *matrixStride = + Value *MatrixStride = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixStrideIdx); - // bias - Value *biasBuffer = + + // Bias parameters + Value *BiasBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasBufferIdx); - Value *biasOffset = + Value *BiasOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasOffsetIdx); - Value *biasInterpretation = + Value *BiasInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasInterpretationIdx); - // output - Value *isOutputUnsigned = + + // Output parameters + Value *IsOutputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsOutputUnsignedIdx); - Function *dxilFunc = hlslOP->GetOpFunc( - opcode, {CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx) + // Get the DXIL function for the operation + Function *DxilFunc = HlslOp->GetOpFunc( + OpCode, {CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx) ->getType() ->getPointerElementType(), - inputVector->getType()}); + InputVector->getType()}); + // Create a call to the DXIL function Value *NewCI = Builder.CreateCall( - dxilFunc, {opArg, inputVector, isInputUnsigned, inputInterpretation, - matrixBuffer, matrixOffset, matrixInterpretation, matrixM, - matrixK, matrixLayout, matrixTranspose, matrixStride, - biasBuffer, biasOffset, biasInterpretation, isOutputUnsigned}); + DxilFunc, {OpArg, InputVector, IsInputUnsigned, InputInterpretation, + MatrixBuffer, MatrixOffset, MatrixInterpretation, MatrixM, + MatrixK, MatrixLayout, MatrixTranspose, MatrixStride, + BiasBuffer, BiasOffset, BiasInterpretation, IsOutputUnsigned}); + // Store the result in the output parameter Value *OutParam = CI->getArgOperand(HLOperandIndex::kMatVecMulAddOutputVectorIdx); Builder.CreateStore(NewCI, OutParam); @@ -6417,62 +6435,72 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode, } Value *TranslateOuterProductAccumulate(CallInst *CI, IntrinsicOp IOP, - OP::OpCode opcode, - HLOperationLowerHelper &helper, - HLObjectOperationLowerHelper *pObjHelper, + OP::OpCode OpCode, + HLOperationLowerHelper &Helper, + HLObjectOperationLowerHelper *ObjHelper, bool &Translated) { - hlsl::OP *hlslOP = &helper.hlslOP; + hlsl::OP *HlslOp = &Helper.hlslOP; IRBuilder<> Builder(CI); - Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); - // input - Value *inputVector1 = + Constant *OpArg = HlslOp->GetU32Const(static_cast(OpCode)); + + // Input vector parameters + Value *InputVector1 = CI->getArgOperand(HLOperandIndex::kOuterProdAccInputVec1Idx); - Value *inputVector2 = + Value *InputVector2 = CI->getArgOperand(HLOperandIndex::kOuterProdAccInputVec2Idx); - // matrix - Value *matrixBuffer = + + // Matrix parameters + Value *MatrixBuffer = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixIdx); - Value *matrixOffset = + Value *MatrixOffset = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixOffsetIdx); - Value *matrixInterpretation = + Value *MatrixInterpretation = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixInterpretationIdx); - Value *matrixLayout = + Value *MatrixLayout = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixLayoutIdx); - Value *matrixStride = + Value *MatrixStride = CI->getArgOperand(HLOperandIndex::kOuterProdAccMatrixStrideIdx); - Function *dxilFunc = hlslOP->GetOpFunc( - opcode, {inputVector1->getType(), inputVector2->getType()}); + // Get the DXIL function for the operation + Function *DxilFunc = HlslOp->GetOpFunc( + OpCode, {InputVector1->getType(), InputVector2->getType()}); return Builder.CreateCall( - dxilFunc, {opArg, inputVector1, inputVector2, matrixBuffer, matrixOffset, - matrixInterpretation, matrixLayout, matrixStride}); + DxilFunc, {OpArg, InputVector1, InputVector2, MatrixBuffer, MatrixOffset, + MatrixInterpretation, MatrixLayout, MatrixStride}); } Value *TranslateVectorAccumulate(CallInst *CI, IntrinsicOp IOP, - OP::OpCode opcode, - HLOperationLowerHelper &helper, - HLObjectOperationLowerHelper *pObjHelper, + OP::OpCode OpCode, + HLOperationLowerHelper &Helper, + HLObjectOperationLowerHelper *ObjHelper, bool &Translated) { - hlsl::OP *hlslOP = &helper.hlslOP; + hlsl::OP *HlslOp = &Helper.hlslOP; IRBuilder<> Builder(CI); - Constant *opArg = hlslOP->GetU32Const((unsigned)opcode); - // input - Value *inputVector = CI->getArgOperand(HLOperandIndex::kVectorAccInputVecIdx); - // matrix - Value *matrixBuffer = CI->getArgOperand(HLOperandIndex::kVectorAccMatrixIdx); - Value *matrixOffset = + Constant *OpArg = HlslOp->GetU32Const(static_cast(OpCode)); + + // Input vector parameter + Value *InputVector = + CI->getArgOperand(HLOperandIndex::kVectorAccInputVecIdx); + + // Matrix parameters + Value *MatrixBuffer = + CI->getArgOperand(HLOperandIndex::kVectorAccMatrixIdx); + Value *MatrixOffset = CI->getArgOperand(HLOperandIndex::kVectorAccMatrixOffsetIdx); - Function *dxilFunc = hlslOP->GetOpFunc(opcode, {inputVector->getType()}); + // Get the DXIL function for the operation + Function *DxilFunc = HlslOp->GetOpFunc(OpCode, {InputVector->getType()}); - return Builder.CreateCall(dxilFunc, - {opArg, inputVector, matrixBuffer, matrixOffset}); + return Builder.CreateCall(DxilFunc, + {OpArg, InputVector, MatrixBuffer, MatrixOffset}); } + + } // namespace // Lower table. From 3081f9e3354fd824d588de3d5e94b7716ca7b1d3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 2 Apr 2025 15:32:46 +0000 Subject: [PATCH 07/93] chore: autopublish 2025-04-02T15:32:45Z --- lib/HLSL/HLOperationLower.cpp | 45 +++++++++++++++-------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index 88ed6d039f..b6f47eb197 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -6312,33 +6312,31 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, Constant *OpArg = HlslOp->GetU32Const(static_cast(OpCode)); // Input parameters - Value *InputVector = + Value *InputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulInputVectorIdx); - Value *IsInputUnsigned = + Value *IsInputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsInputUnsignedIdx); - Value *InputInterpretation = + Value *InputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulInputInterpretationIdx); // Matrix parameters - Value *MatrixBuffer = + Value *MatrixBuffer = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixBufferIdx); - Value *MatrixOffset = + Value *MatrixOffset = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixOffsetIdx); - Value *MatrixInterpretation = + Value *MatrixInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixInterpretationIdx); - Value *MatrixM = - CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixMIdx); - Value *MatrixK = - CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixKIdx); - Value *MatrixLayout = + Value *MatrixM = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixMIdx); + Value *MatrixK = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixKIdx); + Value *MatrixLayout = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixLayoutIdx); - Value *MatrixTranspose = + Value *MatrixTranspose = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixTransposeIdx); - Value *MatrixStride = + Value *MatrixStride = CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixStrideIdx); // Output parameters - Value *IsOutputUnsigned = + Value *IsOutputUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsOutputUnsignedIdx); // Get the DXIL function for the operation @@ -6352,13 +6350,13 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, Value *NewCI = Builder.CreateCall( DxilFunc, {OpArg, InputVector, IsInputUnsigned, InputInterpretation, MatrixBuffer, - MatrixOffset, MatrixInterpretation, MatrixM, MatrixK, - MatrixLayout, MatrixTranspose, MatrixStride, IsOutputUnsigned}); + MatrixOffset, MatrixInterpretation, MatrixM, MatrixK, MatrixLayout, + MatrixTranspose, MatrixStride, IsOutputUnsigned}); // Get the output parameter and store the result Value *OutParam = CI->getArgOperand(HLOperandIndex::kMatVecMulOutputVectorIdx); - + Builder.CreateStore(NewCI, OutParam); return nullptr; @@ -6389,10 +6387,8 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixOffsetIdx); Value *MatrixInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixInterpretationIdx); - Value *MatrixM = - CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixMIdx); - Value *MatrixK = - CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixKIdx); + Value *MatrixM = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixMIdx); + Value *MatrixK = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixKIdx); Value *MatrixLayout = CI->getArgOperand(HLOperandIndex::kMatVecMulAddMatrixLayoutIdx); Value *MatrixTranspose = @@ -6484,12 +6480,10 @@ Value *TranslateVectorAccumulate(CallInst *CI, IntrinsicOp IOP, Constant *OpArg = HlslOp->GetU32Const(static_cast(OpCode)); // Input vector parameter - Value *InputVector = - CI->getArgOperand(HLOperandIndex::kVectorAccInputVecIdx); + Value *InputVector = CI->getArgOperand(HLOperandIndex::kVectorAccInputVecIdx); // Matrix parameters - Value *MatrixBuffer = - CI->getArgOperand(HLOperandIndex::kVectorAccMatrixIdx); + Value *MatrixBuffer = CI->getArgOperand(HLOperandIndex::kVectorAccMatrixIdx); Value *MatrixOffset = CI->getArgOperand(HLOperandIndex::kVectorAccMatrixOffsetIdx); @@ -6500,7 +6494,6 @@ Value *TranslateVectorAccumulate(CallInst *CI, IntrinsicOp IOP, {OpArg, InputVector, MatrixBuffer, MatrixOffset}); } - } // namespace // Lower table. From ae115e122ab30fdcc59b622b7a60409f5d550ec0 Mon Sep 17 00:00:00 2001 From: Anupama Chandrasekhar Date: Wed, 2 Apr 2025 09:50:58 -0700 Subject: [PATCH 08/93] Update utils/hct/hctdb.py Co-authored-by: Damyan Pepper --- utils/hct/hctdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 8fa8f9baff..f5b95d2311 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -5939,7 +5939,7 @@ def UFI(name, **mappings): self.set_op_count_for_version(1, 9, next_op_idx) assert next_op_idx == 309, ( - "305 is expected next operation index but encountered %d and thus opcodes are broken" + "309 is expected next operation index but encountered %d and thus opcodes are broken" % next_op_idx ) From 2b2656dfd2b1a0d934f0bc52e1cfaf3f632649b0 Mon Sep 17 00:00:00 2001 From: anupamac Date: Wed, 2 Apr 2025 13:48:42 -0700 Subject: [PATCH 09/93] Change isSigned to isUnsigned --- include/dxc/DXIL/DxilInstructions.h | 24 ++++++++++++------------ utils/hct/gen_intrin_main.txt | 2 +- utils/hct/hctdb.py | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/dxc/DXIL/DxilInstructions.h b/include/dxc/DXIL/DxilInstructions.h index 367aeec708..24c32a5d6d 100644 --- a/include/dxc/DXIL/DxilInstructions.h +++ b/include/dxc/DXIL/DxilInstructions.h @@ -9037,7 +9037,7 @@ struct DxilInst_MatVecMul { // Operand indexes enum OperandIdx { arg_inputVector = 1, - arg_isInputSigned = 2, + arg_isInputUnsigned = 2, arg_inputInterpretation = 3, arg_matrixBuffer = 4, arg_matrixOffset = 5, @@ -9047,13 +9047,13 @@ struct DxilInst_MatVecMul { arg_matrixLayout = 9, arg_matrixTranspose = 10, arg_matrixStride = 11, - arg_isOutputSigned = 12, + arg_isOutputUnsigned = 12, }; // Accessors llvm::Value *get_inputVector() const { return Instr->getOperand(1); } void set_inputVector(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_isInputSigned() const { return Instr->getOperand(2); } - void set_isInputSigned(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_isInputUnsigned() const { return Instr->getOperand(2); } + void set_isInputUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_inputInterpretation() const { return Instr->getOperand(3); } void set_inputInterpretation(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_matrixBuffer() const { return Instr->getOperand(4); } @@ -9072,8 +9072,8 @@ struct DxilInst_MatVecMul { void set_matrixTranspose(llvm::Value *val) { Instr->setOperand(10, val); } llvm::Value *get_matrixStride() const { return Instr->getOperand(11); } void set_matrixStride(llvm::Value *val) { Instr->setOperand(11, val); } - llvm::Value *get_isOutputSigned() const { return Instr->getOperand(12); } - void set_isOutputSigned(llvm::Value *val) { Instr->setOperand(12, val); } + llvm::Value *get_isOutputUnsigned() const { return Instr->getOperand(12); } + void set_isOutputUnsigned(llvm::Value *val) { Instr->setOperand(12, val); } }; /// This instruction Matrix-Vector Multiply Add @@ -9097,7 +9097,7 @@ struct DxilInst_MatVecMulAdd { // Operand indexes enum OperandIdx { arg_inputVector = 1, - arg_isInputSigned = 2, + arg_isInputUnsigned = 2, arg_inputInterpretation = 3, arg_matrixBuffer = 4, arg_matrixOffset = 5, @@ -9110,13 +9110,13 @@ struct DxilInst_MatVecMulAdd { arg_biasBuffer = 12, arg_biasOffset = 13, arg_biasIntepretation = 14, - arg_isOutputSigned = 15, + arg_isOutputUnsigned = 15, }; // Accessors llvm::Value *get_inputVector() const { return Instr->getOperand(1); } void set_inputVector(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_isInputSigned() const { return Instr->getOperand(2); } - void set_isInputSigned(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_isInputUnsigned() const { return Instr->getOperand(2); } + void set_isInputUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_inputInterpretation() const { return Instr->getOperand(3); } void set_inputInterpretation(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_matrixBuffer() const { return Instr->getOperand(4); } @@ -9141,8 +9141,8 @@ struct DxilInst_MatVecMulAdd { void set_biasOffset(llvm::Value *val) { Instr->setOperand(13, val); } llvm::Value *get_biasIntepretation() const { return Instr->getOperand(14); } void set_biasIntepretation(llvm::Value *val) { Instr->setOperand(14, val); } - llvm::Value *get_isOutputSigned() const { return Instr->getOperand(15); } - void set_isOutputSigned(llvm::Value *val) { Instr->setOperand(15, val); } + llvm::Value *get_isOutputUnsigned() const { return Instr->getOperand(15); } + void set_isOutputUnsigned(llvm::Value *val) { Instr->setOperand(15, val); } }; /// This instruction Outer Product Accumulate diff --git a/utils/hct/gen_intrin_main.txt b/utils/hct/gen_intrin_main.txt index aee831189b..43e2560046 100644 --- a/utils/hct/gen_intrin_main.txt +++ b/utils/hct/gen_intrin_main.txt @@ -380,7 +380,7 @@ void [[]] Barrier(in NodeRecordOrUAV o, in uint SemanticFlags); uint [[]] GetRemainingRecursionLevels(); -void [[]] __builtin_MatVecMul(out numeric output_vector, in bool isOutputSigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer matrix_buffer, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride); +void [[]] __builtin_MatVecMul(out numeric output_vector, in bool isOutputUnsigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer matrix_buffer, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride); void [[]] __builtin_MatVecMulAdd(out numeric output_vector, in bool isOutputUnsigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer matrix_buffer, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride, in ByteAddressBuffer bias_vector, in uint bias_offset, in uint bias_interpretation); diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index f5b95d2311..5a136efbfa 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -5858,7 +5858,7 @@ def UFI(name, **mappings): [ db_dxil_param(0, "$x0", "outputVector", "output vector"), db_dxil_param(2, "$x1", "inputVector", "input vector"), - db_dxil_param(3, "i1", "isInputSigned", "input signed op kind"), + db_dxil_param(3, "i1", "isInputUnsigned", "input signed op kind"), db_dxil_param(4, "i32", "inputInterpretation", "input interpretation"), db_dxil_param(5, "res", "matrixBuffer", "matrix resource"), db_dxil_param(6, "i32", "matrixOffset", "matrix offset"), @@ -5868,7 +5868,7 @@ def UFI(name, **mappings): db_dxil_param(10, "i32", "matrixLayout", "matrix layout"), db_dxil_param(11, "i1", "matrixTranspose", "matrix transpose"), db_dxil_param(12, "i32", "matrixStride", "matrix stride"), - db_dxil_param(13, "i1", "isOutputSigned", "output signed op kind"), + db_dxil_param(13, "i1", "isOutputUnsigned", "output signed op kind"), ], ) next_op_idx += 1 @@ -5883,7 +5883,7 @@ def UFI(name, **mappings): [ db_dxil_param(0, "$x0", "outputVector", "output vector"), db_dxil_param(2, "$x1", "inputVector", "input vector"), - db_dxil_param(3, "i1", "isInputSigned", "input signed op kind"), + db_dxil_param(3, "i1", "isInputUnsigned", "input signed op kind"), db_dxil_param(4, "i32", "inputInterpretation", "input interpretation"), db_dxil_param(5, "res", "matrixBuffer", "matrix resource"), db_dxil_param(6, "i32", "matrixOffset", "matrix offset"), @@ -5896,7 +5896,7 @@ def UFI(name, **mappings): db_dxil_param(13, "res", "biasBuffer", "bias vector resource"), db_dxil_param(14, "i32", "biasOffset", "bias vector offset"), db_dxil_param(15, "i32", "biasIntepretation", "bias vector intepretation"), - db_dxil_param(16, "i1", "isOutputSigned", "output signed op kind"), + db_dxil_param(16, "i1", "isOutputUnsigned", "output signed op kind"), ], ) next_op_idx += 1 From 5ef516a3a1d3629ff670417d2e3dbd2d103ad544 Mon Sep 17 00:00:00 2001 From: anupamac Date: Wed, 2 Apr 2025 17:44:53 -0700 Subject: [PATCH 10/93] Change HLSL intrinsic args from snake to upper camel case --- include/dxc/DXIL/DxilInstructions.h | 48 ++++++++++++++--------------- utils/hct/gen_intrin_main.txt | 14 ++++----- utils/hct/hctdb.py | 16 +++++----- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/include/dxc/DXIL/DxilInstructions.h b/include/dxc/DXIL/DxilInstructions.h index 24c32a5d6d..07407bb5fd 100644 --- a/include/dxc/DXIL/DxilInstructions.h +++ b/include/dxc/DXIL/DxilInstructions.h @@ -9037,23 +9037,23 @@ struct DxilInst_MatVecMul { // Operand indexes enum OperandIdx { arg_inputVector = 1, - arg_isInputUnsigned = 2, + arg_inputIsUnsigned = 2, arg_inputInterpretation = 3, arg_matrixBuffer = 4, arg_matrixOffset = 5, arg_matrixIntepretation = 6, - arg_M = 7, - arg_K = 8, + arg_matrixM = 7, + arg_matrixK = 8, arg_matrixLayout = 9, arg_matrixTranspose = 10, arg_matrixStride = 11, - arg_isOutputUnsigned = 12, + arg_outputIsUnsigned = 12, }; // Accessors llvm::Value *get_inputVector() const { return Instr->getOperand(1); } void set_inputVector(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_isInputUnsigned() const { return Instr->getOperand(2); } - void set_isInputUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_inputIsUnsigned() const { return Instr->getOperand(2); } + void set_inputIsUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_inputInterpretation() const { return Instr->getOperand(3); } void set_inputInterpretation(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_matrixBuffer() const { return Instr->getOperand(4); } @@ -9062,18 +9062,18 @@ struct DxilInst_MatVecMul { void set_matrixOffset(llvm::Value *val) { Instr->setOperand(5, val); } llvm::Value *get_matrixIntepretation() const { return Instr->getOperand(6); } void set_matrixIntepretation(llvm::Value *val) { Instr->setOperand(6, val); } - llvm::Value *get_M() const { return Instr->getOperand(7); } - void set_M(llvm::Value *val) { Instr->setOperand(7, val); } - llvm::Value *get_K() const { return Instr->getOperand(8); } - void set_K(llvm::Value *val) { Instr->setOperand(8, val); } + llvm::Value *get_matrixM() const { return Instr->getOperand(7); } + void set_matrixM(llvm::Value *val) { Instr->setOperand(7, val); } + llvm::Value *get_matrixK() const { return Instr->getOperand(8); } + void set_matrixK(llvm::Value *val) { Instr->setOperand(8, val); } llvm::Value *get_matrixLayout() const { return Instr->getOperand(9); } void set_matrixLayout(llvm::Value *val) { Instr->setOperand(9, val); } llvm::Value *get_matrixTranspose() const { return Instr->getOperand(10); } void set_matrixTranspose(llvm::Value *val) { Instr->setOperand(10, val); } llvm::Value *get_matrixStride() const { return Instr->getOperand(11); } void set_matrixStride(llvm::Value *val) { Instr->setOperand(11, val); } - llvm::Value *get_isOutputUnsigned() const { return Instr->getOperand(12); } - void set_isOutputUnsigned(llvm::Value *val) { Instr->setOperand(12, val); } + llvm::Value *get_outputIsUnsigned() const { return Instr->getOperand(12); } + void set_outputIsUnsigned(llvm::Value *val) { Instr->setOperand(12, val); } }; /// This instruction Matrix-Vector Multiply Add @@ -9097,26 +9097,26 @@ struct DxilInst_MatVecMulAdd { // Operand indexes enum OperandIdx { arg_inputVector = 1, - arg_isInputUnsigned = 2, + arg_inputIsUnsigned = 2, arg_inputInterpretation = 3, arg_matrixBuffer = 4, arg_matrixOffset = 5, arg_matrixIntepretation = 6, - arg_M = 7, - arg_K = 8, + arg_matrixM = 7, + arg_matrixK = 8, arg_matrixLayout = 9, arg_matrixTranspose = 10, arg_matrixStride = 11, arg_biasBuffer = 12, arg_biasOffset = 13, arg_biasIntepretation = 14, - arg_isOutputUnsigned = 15, + arg_outputIsUnsigned = 15, }; // Accessors llvm::Value *get_inputVector() const { return Instr->getOperand(1); } void set_inputVector(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_isInputUnsigned() const { return Instr->getOperand(2); } - void set_isInputUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_inputIsUnsigned() const { return Instr->getOperand(2); } + void set_inputIsUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_inputInterpretation() const { return Instr->getOperand(3); } void set_inputInterpretation(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_matrixBuffer() const { return Instr->getOperand(4); } @@ -9125,10 +9125,10 @@ struct DxilInst_MatVecMulAdd { void set_matrixOffset(llvm::Value *val) { Instr->setOperand(5, val); } llvm::Value *get_matrixIntepretation() const { return Instr->getOperand(6); } void set_matrixIntepretation(llvm::Value *val) { Instr->setOperand(6, val); } - llvm::Value *get_M() const { return Instr->getOperand(7); } - void set_M(llvm::Value *val) { Instr->setOperand(7, val); } - llvm::Value *get_K() const { return Instr->getOperand(8); } - void set_K(llvm::Value *val) { Instr->setOperand(8, val); } + llvm::Value *get_matrixM() const { return Instr->getOperand(7); } + void set_matrixM(llvm::Value *val) { Instr->setOperand(7, val); } + llvm::Value *get_matrixK() const { return Instr->getOperand(8); } + void set_matrixK(llvm::Value *val) { Instr->setOperand(8, val); } llvm::Value *get_matrixLayout() const { return Instr->getOperand(9); } void set_matrixLayout(llvm::Value *val) { Instr->setOperand(9, val); } llvm::Value *get_matrixTranspose() const { return Instr->getOperand(10); } @@ -9141,8 +9141,8 @@ struct DxilInst_MatVecMulAdd { void set_biasOffset(llvm::Value *val) { Instr->setOperand(13, val); } llvm::Value *get_biasIntepretation() const { return Instr->getOperand(14); } void set_biasIntepretation(llvm::Value *val) { Instr->setOperand(14, val); } - llvm::Value *get_isOutputUnsigned() const { return Instr->getOperand(15); } - void set_isOutputUnsigned(llvm::Value *val) { Instr->setOperand(15, val); } + llvm::Value *get_outputIsUnsigned() const { return Instr->getOperand(15); } + void set_outputIsUnsigned(llvm::Value *val) { Instr->setOperand(15, val); } }; /// This instruction Outer Product Accumulate diff --git a/utils/hct/gen_intrin_main.txt b/utils/hct/gen_intrin_main.txt index 43e2560046..fe261f6799 100644 --- a/utils/hct/gen_intrin_main.txt +++ b/utils/hct/gen_intrin_main.txt @@ -380,13 +380,13 @@ void [[]] Barrier(in NodeRecordOrUAV o, in uint SemanticFlags); uint [[]] GetRemainingRecursionLevels(); -void [[]] __builtin_MatVecMul(out numeric output_vector, in bool isOutputUnsigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer matrix_buffer, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride); - -void [[]] __builtin_MatVecMulAdd(out numeric output_vector, in bool isOutputUnsigned, in numeric input_vector, in bool isInputUnsigned, in uint input_interpretation, in ByteAddressBuffer matrix_buffer, in uint matrix_offset, in uint matrix_interpretation, in uint M, in uint K, in uint matrix_layout, in bool matrix_is_transposed, in uint matrix_stride, in ByteAddressBuffer bias_vector, in uint bias_offset, in uint bias_interpretation); - -void [[]] __builtin_OuterProductAccumulate(in numeric input_vector1, in numeric input_vector2, in RWByteAddressBuffer matrix_buffer, in uint matrix_offset, in uint matrix_interpretation, in uint matrix_layout, in uint matrix_stride); - -void [[]] __builtin_VectorAccumulate(in numeric input_vector, in RWByteAddressBuffer matrix_buffer, in uint matrix_offset); +void [[]] __builtin_MatVecMul(out numeric OutputVector, in bool OutputIsUnsigned, in numeric InputVector, in bool InputIsUnsigned, in uint InputInterpretation, in ByteAddressBuffer MatrixBuffer, in uint MatrixOffset, in uint MatrixInterpretation, in uint M, in uint K, in uint MatrixLayout, in bool MatrixIsTransposed, in uint MatrixStride); + +void [[]] __builtin_MatVecMulAdd(out numeric OutputVector, in bool OutputIsUnsigned, in numeric InputVector, in bool InputIsUnsigned, in uint InputInterpretation, in ByteAddressBuffer MatrixBuffer, in uint MatrixOffset, in uint MatrixInterpretation, in uint M, in uint K, in uint MatrixLayout, in bool MatrixIsTransposed, in uint MatrixStride, in ByteAddressBuffer BiasVector, in uint BiasOffset, in uint BiasInterpretation); + +void [[]] __builtin_OuterProductAccumulate(in numeric InputVector1, in numeric InputVector2, in RWByteAddressBuffer MatrixBuffer, in uint MatrixOffset, in uint MatrixInterpretation, in uint MatrixLayout, in uint MatrixStride); + +void [[]] __builtin_VectorAccumulate(in numeric InputVector, in RWByteAddressBuffer MatrixBuffer, in uint MatrixOffset); } namespace diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 5a136efbfa..a3235c786e 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -5858,17 +5858,17 @@ def UFI(name, **mappings): [ db_dxil_param(0, "$x0", "outputVector", "output vector"), db_dxil_param(2, "$x1", "inputVector", "input vector"), - db_dxil_param(3, "i1", "isInputUnsigned", "input signed op kind"), + db_dxil_param(3, "i1", "inputIsUnsigned", "input signed op kind"), db_dxil_param(4, "i32", "inputInterpretation", "input interpretation"), db_dxil_param(5, "res", "matrixBuffer", "matrix resource"), db_dxil_param(6, "i32", "matrixOffset", "matrix offset"), db_dxil_param(7, "i32", "matrixIntepretation", "matrix intepretation"), - db_dxil_param(8, "i32", "M", "matrix M dimension"), - db_dxil_param(9, "i32", "K", "matrix K dimension"), + db_dxil_param(8, "i32", "matrixM", "matrix M dimension"), + db_dxil_param(9, "i32", "matrixK", "matrix K dimension"), db_dxil_param(10, "i32", "matrixLayout", "matrix layout"), db_dxil_param(11, "i1", "matrixTranspose", "matrix transpose"), db_dxil_param(12, "i32", "matrixStride", "matrix stride"), - db_dxil_param(13, "i1", "isOutputUnsigned", "output signed op kind"), + db_dxil_param(13, "i1", "outputIsUnsigned", "output signed op kind"), ], ) next_op_idx += 1 @@ -5883,20 +5883,20 @@ def UFI(name, **mappings): [ db_dxil_param(0, "$x0", "outputVector", "output vector"), db_dxil_param(2, "$x1", "inputVector", "input vector"), - db_dxil_param(3, "i1", "isInputUnsigned", "input signed op kind"), + db_dxil_param(3, "i1", "inputIsUnsigned", "input signed op kind"), db_dxil_param(4, "i32", "inputInterpretation", "input interpretation"), db_dxil_param(5, "res", "matrixBuffer", "matrix resource"), db_dxil_param(6, "i32", "matrixOffset", "matrix offset"), db_dxil_param(7, "i32", "matrixIntepretation", "matrix intepretation"), - db_dxil_param(8, "i32", "M", "matrix M dimension"), - db_dxil_param(9, "i32", "K", "matrix K dimension"), + db_dxil_param(8, "i32", "matrixM", "matrix M dimension"), + db_dxil_param(9, "i32", "matrixK", "matrix K dimension"), db_dxil_param(10, "i32", "matrixLayout", "matrix layout"), db_dxil_param(11, "i1", "matrixTranspose", "matrix transpose"), db_dxil_param(12, "i32", "matrixStride", "matrix stride"), db_dxil_param(13, "res", "biasBuffer", "bias vector resource"), db_dxil_param(14, "i32", "biasOffset", "bias vector offset"), db_dxil_param(15, "i32", "biasIntepretation", "bias vector intepretation"), - db_dxil_param(16, "i1", "isOutputUnsigned", "output signed op kind"), + db_dxil_param(16, "i1", "outputIsUnsigned", "output signed op kind"), ], ) next_op_idx += 1 From 8c2d9ae60754143b22dc24f31c5b9761a187c2c7 Mon Sep 17 00:00:00 2001 From: anupamac Date: Wed, 2 Apr 2025 17:49:24 -0700 Subject: [PATCH 11/93] Name change for readability --- lib/HLSL/HLOperationLower.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index b6f47eb197..3288b18a13 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -6314,7 +6314,7 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, // Input parameters Value *InputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulInputVectorIdx); - Value *IsInputUnsigned = + Value *InputIsUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsInputUnsignedIdx); Value *InputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulInputInterpretationIdx); @@ -6336,7 +6336,7 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, CI->getArgOperand(HLOperandIndex::kMatVecMulMatrixStrideIdx); // Output parameters - Value *IsOutputUnsigned = + Value *OutputIsUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulIsOutputUnsignedIdx); // Get the DXIL function for the operation @@ -6349,9 +6349,9 @@ Value *TranslateMatVecMul(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, // Create a call to the DXIL function Value *NewCI = Builder.CreateCall( DxilFunc, - {OpArg, InputVector, IsInputUnsigned, InputInterpretation, MatrixBuffer, + {OpArg, InputVector, InputIsUnsigned, InputInterpretation, MatrixBuffer, MatrixOffset, MatrixInterpretation, MatrixM, MatrixK, MatrixLayout, - MatrixTranspose, MatrixStride, IsOutputUnsigned}); + MatrixTranspose, MatrixStride, OutputIsUnsigned}); // Get the output parameter and store the result Value *OutParam = @@ -6375,7 +6375,7 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, // Input vector parameters Value *InputVector = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputVectorIdx); - Value *IsInputUnsigned = + Value *InputIsUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsInputUnsignedIdx); Value *InputInterpretation = CI->getArgOperand(HLOperandIndex::kMatVecMulAddInputInterpretationIdx); @@ -6405,7 +6405,7 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, CI->getArgOperand(HLOperandIndex::kMatVecMulAddBiasInterpretationIdx); // Output parameters - Value *IsOutputUnsigned = + Value *OutputIsUnsigned = CI->getArgOperand(HLOperandIndex::kMatVecMulAddIsOutputUnsignedIdx); // Get the DXIL function for the operation @@ -6417,10 +6417,10 @@ Value *TranslateMatVecMulAdd(CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode, // Create a call to the DXIL function Value *NewCI = Builder.CreateCall( - DxilFunc, {OpArg, InputVector, IsInputUnsigned, InputInterpretation, + DxilFunc, {OpArg, InputVector, InputIsUnsigned, InputInterpretation, MatrixBuffer, MatrixOffset, MatrixInterpretation, MatrixM, MatrixK, MatrixLayout, MatrixTranspose, MatrixStride, - BiasBuffer, BiasOffset, BiasInterpretation, IsOutputUnsigned}); + BiasBuffer, BiasOffset, BiasInterpretation, OutputIsUnsigned}); // Store the result in the output parameter Value *OutParam = From df287776200198cf6abb80bd5864098dadec6bea Mon Sep 17 00:00:00 2001 From: anupamac Date: Wed, 2 Apr 2025 17:54:48 -0700 Subject: [PATCH 12/93] Review Feedback: Add description for DXIL ops --- utils/hct/hctdb.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index a3235c786e..f97f9d2995 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -5852,7 +5852,7 @@ def UFI(name, **mappings): "MatVecMul", next_op_idx, "MatVecMul", - "Matrix-Vector Multiply", + "Multiplies a MxK dimension matrix and a K sized input vector", " Date: Thu, 3 Apr 2025 10:08:42 -0700 Subject: [PATCH 13/93] Fix generated files --- include/dxc/DXIL/DxilConstants.h | 17 ++++++++++++----- include/dxc/DXIL/DxilInstructions.h | 14 ++++++++++---- include/dxc/HlslIntrinsicOp.h | 12 ++++++------ utils/hct/hlsl_intrinsic_opcodes.json | 8 ++++++-- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index 182ecbaaf3..dbb4c96fb4 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -487,10 +487,15 @@ inline bool IsFeedbackTexture(DXIL::ResourceKind ResourceKind) { // Enumeration for operations specified by DXIL enum class OpCode : unsigned { // - MatVecMul = 305, // Matrix-Vector Multiply - MatVecMulAdd = 306, // Matrix-Vector Multiply Add - OuterProductAccumulate = 307, // Outer Product Accumulate - RawBufferVectorLoad = 303, // reads from a raw buffer and structured buffer + MatVecMul = + 305, // Multiplies a MxK dimension matrix and a K sized input vector + MatVecMulAdd = 306, // multiplies a MxK dimension matrix and a K sized input + // vector and adds an M-sized bias vector + OuterProductAccumulate = + 307, // Computes the outer product between column vectors and an MxN + // matrix is accumulated component-wise atomically (with device + // scope) in memory + RawBufferVectorLoad = 303, // reads from a raw buffer and structured buffer RawBufferVectorStore = 304, // writes to a RWByteAddressBuffer or RWStructuredBuffer Reserved0 = 226, // Reserved @@ -547,7 +552,9 @@ enum class OpCode : unsigned { ReservedC7 = 300, // reserved ReservedC8 = 301, // reserved ReservedC9 = 302, // reserved - VectorAccumulate = 308, // Vector Accumulate + VectorAccumulate = 308, // Accumulates the components of a vector + // component-wise atomically (with device scope) to + // the corresponding elements of an array in memory // Amplification shader instructions DispatchMesh = 173, // Amplification shader intrinsic DispatchMesh diff --git a/include/dxc/DXIL/DxilInstructions.h b/include/dxc/DXIL/DxilInstructions.h index 07407bb5fd..f7bb1fefd3 100644 --- a/include/dxc/DXIL/DxilInstructions.h +++ b/include/dxc/DXIL/DxilInstructions.h @@ -9017,7 +9017,8 @@ struct DxilInst_RawBufferVectorStore { } }; -/// This instruction Matrix-Vector Multiply +/// This instruction Multiplies a MxK dimension matrix and a K sized input +/// vector struct DxilInst_MatVecMul { llvm::Instruction *Instr; // Construction and identification @@ -9076,7 +9077,8 @@ struct DxilInst_MatVecMul { void set_outputIsUnsigned(llvm::Value *val) { Instr->setOperand(12, val); } }; -/// This instruction Matrix-Vector Multiply Add +/// This instruction multiplies a MxK dimension matrix and a K sized input +/// vector and adds an M-sized bias vector struct DxilInst_MatVecMulAdd { llvm::Instruction *Instr; // Construction and identification @@ -9145,7 +9147,9 @@ struct DxilInst_MatVecMulAdd { void set_outputIsUnsigned(llvm::Value *val) { Instr->setOperand(15, val); } }; -/// This instruction Outer Product Accumulate +/// This instruction Computes the outer product between column vectors and an +/// MxN matrix is accumulated component-wise atomically (with device scope) in +/// memory struct DxilInst_OuterProductAccumulate { llvm::Instruction *Instr; // Construction and identification @@ -9190,7 +9194,9 @@ struct DxilInst_OuterProductAccumulate { void set_matrixLayout(llvm::Value *val) { Instr->setOperand(7, val); } }; -/// This instruction Vector Accumulate +/// This instruction Accumulates the components of a vector component-wise +/// atomically (with device scope) to the corresponding elements of an array in +/// memory struct DxilInst_VectorAccumulate { llvm::Instruction *Instr; // Construction and identification diff --git a/include/dxc/HlslIntrinsicOp.h b/include/dxc/HlslIntrinsicOp.h index aaed521472..03a6742976 100644 --- a/include/dxc/HlslIntrinsicOp.h +++ b/include/dxc/HlslIntrinsicOp.h @@ -107,6 +107,10 @@ enum class IntrinsicOp { IOP_WorldToObject = 99, IOP_WorldToObject3x4 = 100, IOP_WorldToObject4x3 = 101, + IOP___builtin_MatVecMul = 360, + IOP___builtin_MatVecMulAdd = 361, + IOP___builtin_OuterProductAccumulate = 362, + IOP___builtin_VectorAccumulate = 363, IOP_abort = 102, IOP_abs = 103, IOP_acos = 104, @@ -333,6 +337,8 @@ enum class IntrinsicOp { MOP_TraceRayInline = 325, MOP_WorldRayDirection = 326, MOP_WorldRayOrigin = 327, + MOP_DxHitObject_MakeNop = 358, + IOP_DxMaybeReorderThread = 359, MOP_Count = 328, MOP_FinishedCrossGroupSharing = 329, MOP_GetGroupNodeOutputRecords = 330, @@ -364,12 +370,6 @@ enum class IntrinsicOp { IOP_usign = 355, MOP_InterlockedUMax = 356, MOP_InterlockedUMin = 357, - MOP_DxHitObject_MakeNop = 358, - IOP_DxMaybeReorderThread = 359, - IOP___builtin_MatVecMul = 360, - IOP___builtin_MatVecMulAdd = 361, - IOP___builtin_OuterProductAccumulate = 362, - IOP___builtin_VectorAccumulate = 363, Num_Intrinsics = 364, }; inline bool HasUnsignedIntrinsicOpcode(IntrinsicOp opcode) { diff --git a/utils/hct/hlsl_intrinsic_opcodes.json b/utils/hct/hlsl_intrinsic_opcodes.json index 4c85069488..d82c1d8900 100644 --- a/utils/hct/hlsl_intrinsic_opcodes.json +++ b/utils/hct/hlsl_intrinsic_opcodes.json @@ -1,6 +1,6 @@ { "IntrinsicOpCodes": { - "Num_Intrinsics": 360, + "Num_Intrinsics": 364, "IOP_AcceptHitAndEndSearch": 0, "IOP_AddUint64": 1, "IOP_AllMemoryBarrier": 2, @@ -360,6 +360,10 @@ "MOP_InterlockedUMax": 356, "MOP_InterlockedUMin": 357, "MOP_DxHitObject_MakeNop": 358, - "IOP_DxMaybeReorderThread": 359 + "IOP_DxMaybeReorderThread": 359, + "IOP___builtin_MatVecMul": 360, + "IOP___builtin_MatVecMulAdd": 361, + "IOP___builtin_OuterProductAccumulate": 362, + "IOP___builtin_VectorAccumulate": 363 } } From f7fabd9ffe192d0d63e10f9def742ca3f2540463 Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 4 Apr 2025 01:27:55 -0700 Subject: [PATCH 14/93] Add validation rules for DXIL ops --- include/dxc/DXIL/DxilConstants.h | 53 +++++- .../dxc/DxilContainer/RDAT_LibraryTypes.inl | 6 +- lib/DxilValidation/DxilValidation.cpp | 179 ++++++++++++++++++ utils/hct/hctdb.py | 16 ++ 4 files changed, 245 insertions(+), 9 deletions(-) diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index dbb4c96fb4..ba7ff1f1ae 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -163,14 +163,14 @@ const unsigned kDxilMaxOloadDims = 2; enum class ComponentType : uint32_t { Invalid = 0, I1, - I16, - U16, - I32, - U32, + I16, // = 2 + U16, // = 3 + I32, // = 4 + U32, // = 5 I64, U64, - F16, - F32, + F16, // = 8 + F32, // = 9 F64, SNormF16, UNormF16, @@ -178,8 +178,16 @@ enum class ComponentType : uint32_t { UNormF32, SNormF64, UNormF64, - PackedS8x32, - PackedU8x32, + PackedS8x32, // = 17 + PackedU8x32, // = 18 + + // BEGIN NEW FOR SM 6.9 + U8, // = 19 + I8, // = 20 + F8_E4M3, // = 21 + F8_E5M2, // = 22 + // END + LastEntry }; @@ -1536,6 +1544,28 @@ const unsigned kMSStoreOutputColOpIdx = 3; const unsigned kMSStoreOutputVIdxOpIdx = 4; const unsigned kMSStoreOutputValOpIdx = 5; +// MatVec Ops +const unsigned kMatVecMulInputVectorIdx = 1; +const unsigned kMatVecMulIsInputUnsignedIdx = 2; +const unsigned kMatVecMulInputInterpretationIdx = 3; +const unsigned kMatVecMulMatrixBufferIdx = 4; +const unsigned kMatVecMulMatrixOffsetIdx = 5; +const unsigned kMatVecMulMatrixInterpretationIdx = 6; +const unsigned kMatVecMulMatrixMIdx = 7; +const unsigned kMatVecMulMatrixKIdx = 8; +const unsigned kMatVecMulMatrixLayoutIdx = 9; +const unsigned kMatVecMulMatrixTransposeIdx = 10; +const unsigned kMatVecMulMatrixStrideIdx = 11; +const unsigned kMatVecMulIsOutputUnsignedIdx = 12; + +// MatVecAdd +const unsigned kMatVecMulAddBiasInterpretation = 14; +const unsigned kMatVecMulAddIsOutputUnsignedIdx = 15; + +// Outer Product Accumulate +const unsigned kOuterProdAccMatrixInterpretation = 5; +const unsigned kOuterProdAccMatrixLayout = 6; + // TODO: add operand index for all the OpCodeClass. } // namespace OperandIndex @@ -2105,6 +2135,13 @@ extern const char *kHostLayoutTypePrefix; extern const char *kWaveOpsIncludeHelperLanesString; +enum class DXILMatrixLayout : uint32_t { + RowMajor = 0, + ColumnMajor = 1, + MulOptimal = 2, + OuterProductOptimal = 3, +}; + } // namespace DXIL } // namespace hlsl diff --git a/include/dxc/DxilContainer/RDAT_LibraryTypes.inl b/include/dxc/DxilContainer/RDAT_LibraryTypes.inl index 132d272a8e..e62c2e76f8 100644 --- a/include/dxc/DxilContainer/RDAT_LibraryTypes.inl +++ b/include/dxc/DxilContainer/RDAT_LibraryTypes.inl @@ -564,9 +564,13 @@ RDAT_DXIL_ENUM_START(hlsl::DXIL::ComponentType, uint32_t) RDAT_ENUM_VALUE_NODEF(UNormF64) RDAT_ENUM_VALUE_NODEF(PackedS8x32) RDAT_ENUM_VALUE_NODEF(PackedU8x32) + RDAT_ENUM_VALUE_NODEF(U8) + RDAT_ENUM_VALUE_NODEF(I8) + RDAT_ENUM_VALUE_NODEF(F8_E4M3) + RDAT_ENUM_VALUE_NODEF(F8_E5M2) RDAT_ENUM_VALUE_NODEF(LastEntry) #if DEF_RDAT_ENUMS == DEF_RDAT_DUMP_IMPL - static_assert((unsigned)hlsl::DXIL::ComponentType::LastEntry == 19, + static_assert((unsigned)hlsl::DXIL::ComponentType::LastEntry == 23, "otherwise, RDAT_DXIL_ENUM definition needs updating"); #endif RDAT_ENUM_END() diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index fd05495e86..581029ce6a 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -970,6 +970,175 @@ static void ValidateImmOperandForMathDxilOp(CallInst *CI, DXIL::OpCode opcode, } } +static bool CheckFromRegisterInterpretations(uint32_t Ri) { + std::set ValidSet = { + DXIL::ComponentType::I16, DXIL::ComponentType::U16, + DXIL::ComponentType::I32, DXIL::ComponentType::U32, + DXIL::ComponentType::F16, DXIL::ComponentType::F32, + DXIL::ComponentType::PackedS8x32, DXIL::ComponentType::PackedU8x32, + DXIL::ComponentType::U8, DXIL::ComponentType::I8, + DXIL::ComponentType::F8_E4M3, DXIL::ComponentType::F8_E5M2}; + + if (ValidSet.find(static_cast(Ri)) != ValidSet.end()) { + return true; + } + return false; +} + +static bool CheckInMemoryInterpretations(uint32_t Mi) { + std::set ValidSet = { + DXIL::ComponentType::I16, DXIL::ComponentType::U16, + DXIL::ComponentType::I32, DXIL::ComponentType::U32, + DXIL::ComponentType::F16, DXIL::ComponentType::F32, + DXIL::ComponentType::U8, DXIL::ComponentType::I8, + DXIL::ComponentType::F8_E4M3, DXIL::ComponentType::F8_E5M2}; + + if (ValidSet.find(static_cast(Mi)) != ValidSet.end()) { + return true; + } + return false; +} + +static bool CheckMatrixLayout(uint32_t Ml) { + std::set ValidSet = { + DXIL::DXILMatrixLayout::RowMajor, DXIL::DXILMatrixLayout::ColumnMajor, + DXIL::DXILMatrixLayout::MulOptimal, + DXIL::DXILMatrixLayout::OuterProductOptimal}; + + if (ValidSet.find(static_cast(Ml)) != + ValidSet.end()) { + return true; + } + return false; +} + +static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode opcode, + ValidationContext &ValCtx) { + + // Check Common operands + llvm::Value *InputIsUnsigned = + CI->getOperand(DXIL::OperandIndex::kMatVecMulIsInputUnsignedIdx); + llvm::Value *InputInterpretation = + CI->getOperand(DXIL::OperandIndex::kMatVecMulInputInterpretationIdx); + llvm::Value *MatrixInterpretation = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixInterpretationIdx); + llvm::Value *MatrixM = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixMIdx); + llvm::Value *MatrixK = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixKIdx); + llvm::Value *MatrixLayout = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixLayoutIdx); + llvm::Value *MatrixTranspose = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixTransposeIdx); + + if (!llvm::isa(InputIsUnsigned)) { + ValCtx.EmitInstrError(CI, + ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst); + } + + if (!llvm::isa(InputInterpretation) || + !llvm::isa(MatrixInterpretation)) { + ValCtx.EmitInstrError( + CI, ValidationRule::InstrLinalgInterpretationParamAreConst); + } + + // Check if InputInterpretation and MatrixInterpretation are valid + ConstantInt *Ii = cast(InputInterpretation); + auto IiValue = Ii->getLimitedValue(); + if (!CheckFromRegisterInterpretations(IiValue)) { + ValCtx.EmitInstrError( + CI, ValidationRule::InstrLinalgInvalidRegisterInterpValue); + } + + ConstantInt *Mi = cast(MatrixInterpretation); + auto MiValue = Mi->getLimitedValue(); + if (!CheckInMemoryInterpretations(MiValue)) { + ValCtx.EmitInstrError(CI, + ValidationRule::InstrLinalgInvalidMemoryInterpValue); + } + + if (!llvm::isa(MatrixM) || + !llvm::isa(MatrixK) || + !llvm::isa(MatrixLayout) || + !llvm::isa(MatrixTranspose)) { + ValCtx.EmitInstrError(CI, + ValidationRule::InstrLinalgMatrixShapeParamsAreConst); + } + + ConstantInt *Ml = cast(MatrixLayout); + auto MlValue = Ml->getLimitedValue(); + if (!CheckMatrixLayout(MlValue)) { + ValCtx.EmitInstrError(CI, + ValidationRule::InstrLinalgInvalidMatrixLayoutValue); + } + + switch (opcode) { + case DXIL::OpCode::MatVecMul: { + llvm::Value *OutputIsUnsigned = + CI->getOperand(DXIL::OperandIndex::kMatVecMulIsOutputUnsignedIdx); + if (!llvm::isa(OutputIsUnsigned)) { + ValCtx.EmitInstrError( + CI, ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst); + } + + } break; + case DXIL::OpCode::MatVecMulAdd: { + llvm::Value *OutputIsUnsigned = + CI->getOperand(DXIL::OperandIndex::kMatVecMulAddIsOutputUnsignedIdx); + if (!llvm::isa(OutputIsUnsigned)) { + ValCtx.EmitInstrError( + CI, ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst); + } + llvm::Value *BiasInterpretation = + CI->getOperand(DXIL::OperandIndex::kMatVecMulAddBiasInterpretation); + if (!llvm::isa(BiasInterpretation)) { + ValCtx.EmitInstrError( + CI, ValidationRule::InstrLinalgInterpretationParamAreConst); + } + ConstantInt *Bi = cast(BiasInterpretation); + auto BiValue = Bi->getLimitedValue(); + if (!CheckInMemoryInterpretations(BiValue)) { + ValCtx.EmitInstrError( + CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); + } + } break; + default: + break; + } +} + +static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, + DXIL::OpCode opcode, + ValidationContext &ValCtx) { + + llvm::Value *MatrixInterpretation = + CI->getOperand(DXIL::OperandIndex::kOuterProdAccMatrixInterpretation); + llvm::Value *MatrixLayout = + CI->getOperand(DXIL::OperandIndex::kOuterProdAccMatrixLayout); + + if (!llvm::isa(MatrixInterpretation)) { + ValCtx.EmitInstrError( + CI, ValidationRule::InstrLinalgInterpretationParamAreConst); + } + ConstantInt *Mi = cast(MatrixInterpretation); + auto MiValue = Mi->getLimitedValue(); + if (!CheckInMemoryInterpretations(MiValue)) { + ValCtx.EmitInstrError(CI, + ValidationRule::InstrLinalgInvalidMemoryInterpValue); + } + + if (!llvm::isa(MatrixLayout)) { + ValCtx.EmitInstrError(CI, + ValidationRule::InstrLinalgMatrixShapeParamsAreConst); + } + ConstantInt *Ml = cast(MatrixLayout); + auto MlValue = Ml->getLimitedValue(); + if (!CheckMatrixLayout(MlValue)) { + ValCtx.EmitInstrError(CI, + ValidationRule::InstrLinalgInvalidMatrixLayoutValue); + } +} + // Validate the type-defined mask compared to the store value mask which // indicates which parts were defined returns true if caller should continue // validation @@ -1942,6 +2111,16 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI, GetLaunchTypeStr(nodeLaunchType)}); break; + case DXIL::OpCode::MatVecMul: + case DXIL::OpCode::MatVecMulAdd: + ValidateImmOperandsForMatVecOps(CI, opcode, ValCtx); + break; + case DXIL::OpCode::OuterProductAccumulate: + ValidateImmOperandsForOuterProdAcc(CI, opcode, ValCtx); + break; + case DXIL::OpCode::VectorAccumulate: + + break; default: // TODO: make sure every opcode is checked. diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index f97f9d2995..0c63f7a5b9 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -7878,6 +7878,22 @@ def build_valrules(self): "Invalid use of completed record handle.", ) + # Linalg ops + self.add_valrule("Instr.MatVecOpIsUnsignedFlagsAreConst", "MatVec Ops Is Unsigned flag is a constant") + + self.add_valrule("Instr.LinalgInterpretationParamAreConst", "Interpretation values are constants") + + self.add_valrule("Instr.LinalgInvalidRegisterInterpValue", "From Register Interpretation value not in valid set") + + self.add_valrule("Instr.LinalgInvalidMemoryInterpValue", "In Memory Interpolation value not in valid set") + + self.add_valrule("Instr.LinalgMatrixShapeParamsAreConst", "Matrix Layout, Dimensions and isTranspose are immediate constants") + + self.add_valrule("Instr.LinalgInvalidMatrixLayoutValue", "Matrix Layout for Linalg ops not in valid set") + + + + # Some legacy rules: # - space is only supported for shader targets 5.1 and higher # - multiple rules regarding derivatives, which isn't a supported feature for DXIL From 50155c12af2248b7f9dd50befdb05f13ad6e58d9 Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 4 Apr 2025 13:45:51 -0700 Subject: [PATCH 15/93] Unit test 1: Check linalg builtins for different shader stages: ps, vs, cs, ns, gs --- .../linalg_builtins/checkshaderstages.hlsl | 297 ++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl new file mode 100644 index 0000000000..35eb2135f3 --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl @@ -0,0 +1,297 @@ +// RUN: %dxc -T lib_6_9 %s | FileCheck %s + +ByteAddressBuffer matrix_buffer; +ByteAddressBuffer bias_buffer; +RWByteAddressBuffer rw_matrix_buffer; + +// CHECK: define void @ps_main() +// CHECK: call <4 x float> @dx.op.matVecMul +// CHECK: call <4 x float> @dx.op.matVecMulAdd +// CHECK: call void @dx.op.outerProductAccumulate +// CHECK: call void @dx.op.vectorAccumulate + +[Shader("pixel")] +void ps_main() +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); } + +// CHECK: define void @cs_main() +// CHECK: call <4 x float> @dx.op.matVecMul +// CHECK: call <4 x float> @dx.op.matVecMulAdd +// CHECK: call void @dx.op.outerProductAccumulate +// CHECK: call void @dx.op.vectorAccumulate + +[Shader("compute")] +[NumThreads(1,1,1)] +void cs_main() +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); +} + +// CHECK: define void @vs_main() +// CHECK: call <4 x float> @dx.op.matVecMul +// CHECK: call <4 x float> @dx.op.matVecMulAdd +// CHECK: call void @dx.op.outerProductAccumulate +// CHECK: call void @dx.op.vectorAccumulate + +[Shader("vertex")] +void vs_main() +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); } + +struct MyRecord{ + uint a; +}; + +// CHECK: define void @ns_main() +// CHECK: call <4 x float> @dx.op.matVecMul +// CHECK: call <4 x float> @dx.op.matVecMulAdd +// CHECK: call void @dx.op.outerProductAccumulate +// CHECK: call void @dx.op.vectorAccumulate + +[Shader("node")] +[NodeLaunch("thread")] +void ns_main(ThreadNodeInputRecord input) +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); +} + +// Vertex shader output structure +struct VS_OUT { + float3 Color : COLOR0; +}; + +// Geometry shader output structure +struct GS_OUT { + float3 Color : COLOR0; + float2 TexCoord : TEXCOORD0; +}; + +// CHECK: define void @gs_main() +// CHECK: call <4 x float> @dx.op.matVecMul +// CHECK: call <4 x float> @dx.op.matVecMulAdd +// CHECK: call void @dx.op.outerProductAccumulate +// CHECK: call void @dx.op.vectorAccumulate + +[shader("geometry")] +[maxvertexcount(3)] +void gs_main(point VS_OUT input[1], + inout TriangleStream OutputStream) +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); +} From 9383c47999faa26a0f874c992327f53dc3971630 Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 4 Apr 2025 14:25:18 -0700 Subject: [PATCH 16/93] Replace std::set with linear search --- lib/DxilValidation/DxilValidation.cpp | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 581029ce6a..ae946e2c20 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -970,8 +970,8 @@ static void ValidateImmOperandForMathDxilOp(CallInst *CI, DXIL::OpCode opcode, } } -static bool CheckFromRegisterInterpretations(uint32_t Ri) { - std::set ValidSet = { +static bool CheckFromRegisterInterpretations(uint32_t input) { + DXIL::ComponentType ValidSet[] = { DXIL::ComponentType::I16, DXIL::ComponentType::U16, DXIL::ComponentType::I32, DXIL::ComponentType::U32, DXIL::ComponentType::F16, DXIL::ComponentType::F32, @@ -979,35 +979,38 @@ static bool CheckFromRegisterInterpretations(uint32_t Ri) { DXIL::ComponentType::U8, DXIL::ComponentType::I8, DXIL::ComponentType::F8_E4M3, DXIL::ComponentType::F8_E5M2}; - if (ValidSet.find(static_cast(Ri)) != ValidSet.end()) { - return true; + for (auto Val : ValidSet) { + if (Val == static_cast(input)) + return true; } return false; } -static bool CheckInMemoryInterpretations(uint32_t Mi) { - std::set ValidSet = { +static bool CheckInMemoryInterpretations(uint32_t input) { + DXIL::ComponentType ValidSet[] = { DXIL::ComponentType::I16, DXIL::ComponentType::U16, DXIL::ComponentType::I32, DXIL::ComponentType::U32, DXIL::ComponentType::F16, DXIL::ComponentType::F32, DXIL::ComponentType::U8, DXIL::ComponentType::I8, DXIL::ComponentType::F8_E4M3, DXIL::ComponentType::F8_E5M2}; - if (ValidSet.find(static_cast(Mi)) != ValidSet.end()) { - return true; + for (auto Val : ValidSet) { + if (Val == static_cast(input)) + return true; } return false; } -static bool CheckMatrixLayout(uint32_t Ml) { - std::set ValidSet = { +static bool CheckMatrixLayout(unsigned input) { + + DXIL::DXILMatrixLayout ValidSet[] = { DXIL::DXILMatrixLayout::RowMajor, DXIL::DXILMatrixLayout::ColumnMajor, DXIL::DXILMatrixLayout::MulOptimal, DXIL::DXILMatrixLayout::OuterProductOptimal}; - if (ValidSet.find(static_cast(Ml)) != - ValidSet.end()) { - return true; + for (auto Val : ValidSet) { + if (Val == static_cast(input)) + return true; } return false; } From 8df9520152f9a7af376b5186d622fc09ad5a8b7b Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 4 Apr 2025 16:14:11 -0700 Subject: [PATCH 17/93] Unit test: Check Intrinsic not enabled pre SM6.9 --- include/dxc/DXIL/DxilConstants.h | 34 ++++++----- lib/DXIL/DxilOperations.cpp | 9 ++- tools/clang/lib/Sema/SemaHLSL.cpp | 12 ++++ .../linalg_builtins/UnavailablePreSM69.hlsl | 59 +++++++++++++++++++ .../linalg_builtins/checkshaderstages.hlsl | 3 +- utils/hct/hctdb.py | 3 + 6 files changed, 102 insertions(+), 18 deletions(-) create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/UnavailablePreSM69.hlsl diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index ba7ff1f1ae..96b442bc3b 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -495,14 +495,6 @@ inline bool IsFeedbackTexture(DXIL::ResourceKind ResourceKind) { // Enumeration for operations specified by DXIL enum class OpCode : unsigned { // - MatVecMul = - 305, // Multiplies a MxK dimension matrix and a K sized input vector - MatVecMulAdd = 306, // multiplies a MxK dimension matrix and a K sized input - // vector and adds an M-sized bias vector - OuterProductAccumulate = - 307, // Computes the outer product between column vectors and an MxN - // matrix is accumulated component-wise atomically (with device - // scope) in memory RawBufferVectorLoad = 303, // reads from a raw buffer and structured buffer RawBufferVectorStore = 304, // writes to a RWByteAddressBuffer or RWStructuredBuffer @@ -560,9 +552,6 @@ enum class OpCode : unsigned { ReservedC7 = 300, // reserved ReservedC8 = 301, // reserved ReservedC9 = 302, // reserved - VectorAccumulate = 308, // Accumulates the components of a vector - // component-wise atomically (with device scope) to - // the corresponding elements of an array in memory // Amplification shader instructions DispatchMesh = 173, // Amplification shader intrinsic DispatchMesh @@ -791,6 +780,19 @@ enum class OpCode : unsigned { CreateHandleForLib = 160, // create resource handle from resource struct for library + // Linear Algebra Operations + MatVecMul = + 305, // Multiplies a MxK dimension matrix and a K sized input vector + MatVecMulAdd = 306, // multiplies a MxK dimension matrix and a K sized input + // vector and adds an M-sized bias vector + OuterProductAccumulate = + 307, // Computes the outer product between column vectors and an MxN + // matrix is accumulated component-wise atomically (with device + // scope) in memory + VectorAccumulate = 308, // Accumulates the components of a vector + // component-wise atomically (with device scope) to + // the corresponding elements of an array in memory + // Mesh shader instructions EmitIndices = 169, // emit a primitive's vertex indices in a mesh shader GetMeshPayload = @@ -1079,13 +1081,9 @@ enum class OpCode : unsigned { // Groups for DXIL operations with equivalent function templates enum class OpCodeClass : unsigned { // - MatVecMul, - MatVecMulAdd, - OuterProductAccumulate, RawBufferVectorLoad, RawBufferVectorStore, Reserved, - VectorAccumulate, // Amplification shader instructions DispatchMesh, @@ -1214,6 +1212,12 @@ enum class OpCodeClass : unsigned { // Library create handle from resource struct (like HL intrinsic) CreateHandleForLib, + // Linear Algebra Operations + MatVecMul, + MatVecMulAdd, + OuterProductAccumulate, + VectorAccumulate, + // Mesh shader instructions EmitIndices, GetMeshPayload, diff --git a/lib/DXIL/DxilOperations.cpp b/lib/DXIL/DxilOperations.cpp index ce29e11368..5207bcdce9 100644 --- a/lib/DXIL/DxilOperations.cpp +++ b/lib/DXIL/DxilOperations.cpp @@ -2649,6 +2649,8 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = { 1, {{0x4e7}}, {{0xe7}}}, // Overloads: hfwidlIsSM69Plus()) { + Diags.Report(CE->getExprLoc(), + diag::warn_hlsl_intrinsic_in_wrong_shader_model) + << FD->getNameAsString() << EntryDecl->getNameAsString() << "6.9"; + return; + } + break; default: break; diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/UnavailablePreSM69.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/UnavailablePreSM69.hlsl new file mode 100644 index 0000000000..f212ed255a --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/UnavailablePreSM69.hlsl @@ -0,0 +1,59 @@ +// RUN: %dxc -T lib_6_8 %s -verify + +ByteAddressBuffer matrix_buffer; +ByteAddressBuffer bias_buffer; +RWByteAddressBuffer rw_matrix_buffer; + +[Shader("compute")] +[Numthreads(1,1,1)] +void cs_main() +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + //expected-error@+1{{intrinsic __builtin_MatVecMul potentially used by 'cs_main' requires shader model 6.9 or greater}} + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + //expected-error@+1{{intrinsic __builtin_MatVecMulAdd potentially used by 'cs_main' requires shader model 6.9 or greater}} + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + //expected-error@+1{{intrinsic __builtin_OuterProductAccumulate potentially used by 'cs_main' requires shader model 6.9 or greater}} + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + //expected-error@+1{{intrinsic __builtin_VectorAccumulate potentially used by 'cs_main' requires shader model 6.9 or greater}} + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); +} \ No newline at end of file diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl index 35eb2135f3..485ff8dad9 100644 --- a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl @@ -56,7 +56,8 @@ void ps_main() const uint va_matrix_offset = 0; __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, - va_matrix_offset); } + va_matrix_offset); +} // CHECK: define void @cs_main() // CHECK: call <4 x float> @dx.op.matVecMul diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 0c63f7a5b9..4853e1ca45 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -855,6 +855,9 @@ def populate_categories_and_models(self): "closesthit", "miss", ) + for i in ("MatVecMul,MatVecMulAdd,OuterProductAccumulate,VectorAccumulate").split(","): + self.name_idx[i].category = "Linear Algebra Operations" + self.name_idx[i].shader_model = 6, 9 def populate_llvm_instructions(self): # Add instructions that map to LLVM instructions. From 8d44645b6a1115e85c367a353b6d1e77659f043e Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 4 Apr 2025 17:29:39 -0700 Subject: [PATCH 18/93] Unit tests: Check parameters of the Builtin calls --- ...erstages.hlsl => check-shader-stages.hlsl} | 0 .../hlsl/linalg_builtins/mat-vec-mul-add.hlsl | 36 +++++++++++++++++++ .../hlsl/linalg_builtins/mat-vec-mul.hlsl | 33 +++++++++++++++++ .../outer-product-accumulate.hlsl | 21 +++++++++++ ...PreSM69.hlsl => unavailable-pre-sm69.hlsl} | 0 .../linalg_builtins/vector-accumulate.hlsl | 16 +++++++++ 6 files changed, 106 insertions(+) rename tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/{checkshaderstages.hlsl => check-shader-stages.hlsl} (100%) create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate.hlsl rename tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/{UnavailablePreSM69.hlsl => unavailable-pre-sm69.hlsl} (100%) create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/check-shader-stages.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/checkshaderstages.hlsl rename to tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/check-shader-stages.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl new file mode 100644 index 0000000000..f756037f4c --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl @@ -0,0 +1,36 @@ +// RUN: %dxc -T cs_6_9 %s | FileCheck %s + +ByteAddressBuffer input_vector_buffer; +ByteAddressBuffer matrix_buffer; +ByteAddressBuffer bias_buffer; +RWByteAddressBuffer rw_matrix_buffer; + + +// Test use of __builtin_MatVecMulAdd in pixel shader +// CHECK: define void @main() +// CHECK: call <4 x float> @dx.op.matVecMulAdd.v4f32.v4f32(i32 {{[0-9]+}}, <4 x float> {{%[0-9]+}}, i1 false, i32 9, %dx.types.Handle {{%[0-9]+}}, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle {{%[0-9]+}}, i32 0, i32 9, i1 false) + + +[NumThreads(1,1,1)] +void main() +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector = input_vector_buffer.Load >(0); + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, + matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); +} diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl new file mode 100644 index 0000000000..dfe452aac6 --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl @@ -0,0 +1,33 @@ +// RUN: %dxc -T cs_6_9 %s | FileCheck %s + +ByteAddressBuffer input_vector_buffer; +ByteAddressBuffer matrix_buffer; +ByteAddressBuffer bias_buffer; +RWByteAddressBuffer rw_matrix_buffer; + +// Test use of __builtin_MatVecMulAdd in pixel shader +// CHECK: define void @main() +// CHECK: call <4 x float> @dx.op.matVecMul.v4f32.v4f32(i32 {{[0-9]+}}, <4 x float> {{%[0-9]+}}, i1 false, i32 9, %dx.types.Handle {{%[0-9]+}}, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, i1 false) + + +[NumThreads(1,1,1)] +void main() +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector = input_vector_buffer.Load >(0); + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, + matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); +} diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate.hlsl new file mode 100644 index 0000000000..b1b9bd7993 --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate.hlsl @@ -0,0 +1,21 @@ +// RUN: %dxc -T cs_6_9 %s | FileCheck %s + +RWByteAddressBuffer matrix_buffer; + +// CHECK: define void @main() +// CHECK: call void @dx.op.outerProductAccumulate.v2i32.v2i32(i32 {{[0-9]+}}, <2 x i32> , <2 x i32> , %dx.types.Handle {{%[0-9]+}}, i32 0, i32 5, i32 0, i32 64) + +[Numthreads(1,1,1)] +void main() +{ + vector input_vector1 = 1; + vector input_vector2 = 2; + + const uint matrix_offset = 0; + const uint matrix_interpretation = 5; /*U32*/ + const uint matrix_layout = 0; + const uint matrix_stride = 64; + + __builtin_OuterProductAccumulate(input_vector1, input_vector2, matrix_buffer, matrix_offset, matrix_interpretation, matrix_layout, matrix_stride); + +} diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/UnavailablePreSM69.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/unavailable-pre-sm69.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/UnavailablePreSM69.hlsl rename to tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/unavailable-pre-sm69.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl new file mode 100644 index 0000000000..1372dcb818 --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl @@ -0,0 +1,16 @@ +// RUN: %dxc -T cs_6_9 %s | FileCheck %s + +RWByteAddressBuffer matrix_buffer; + +// Test use of __builtin_VectorAccumulate in pixel shader +// CHECK: define void @main() +// CHECK: call void @dx.op.vectorAccumulate.v2i32(i32 {{[0-9]+}}, <2 x i32> , %dx.types.Handle {{%[0-9]+}}, i32 0) + +[NumThreads(1,1,1)] +void main() +{ + vector input_vector1 = 5; + const uint matrix_offset = 0; + + __builtin_VectorAccumulate(input_vector1, matrix_buffer, matrix_offset); +} From e70c1408b692febef944025c6b709c3b85559a9c Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 4 Apr 2025 17:35:28 -0700 Subject: [PATCH 19/93] Unit test: Outer Product Accumulate Multidimensional overload --- ...uter-product-accumulate-multioverload.hlsl | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate-multioverload.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate-multioverload.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate-multioverload.hlsl new file mode 100644 index 0000000000..084e598030 --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate-multioverload.hlsl @@ -0,0 +1,21 @@ +// RUN: %dxc -T cs_6_9 %s | FileCheck %s + +RWByteAddressBuffer matrix_buffer; + +// CHECK: define void @main() +// CHECK: call void @dx.op.outerProductAccumulate.v2i32.v4i32(i32 {{[0-9]+}} + +[Numthreads(1,1,1)] +void main() +{ + vector input_vector1 = 1; + vector input_vector2 = 2; + + const uint matrix_offset = 0; + const uint matrix_interpretation = 5; /*U32*/ + const uint matrix_layout = 0; + const uint matrix_stride = 64; + + __builtin_OuterProductAccumulate(input_vector1, input_vector2, matrix_buffer, matrix_offset, matrix_interpretation, matrix_layout, matrix_stride); + +} From 6c9307163c985f985b191bf3fccc610d84988f17 Mon Sep 17 00:00:00 2001 From: anupamac Date: Sat, 5 Apr 2025 06:53:16 -0700 Subject: [PATCH 20/93] Unit test: IR->IR Dxilgen test --- .../hlsl/intrinsics/linang-builins.hlsl | 55 ++++++++ .../hlsl/intrinsics/linang-builins.ll | 127 ++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl create mode 100644 tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl new file mode 100644 index 0000000000..2a86d3caeb --- /dev/null +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl @@ -0,0 +1,55 @@ +// dxc.exe -T cs_6_9 -E cs_main %s + +ByteAddressBuffer matrix_buffer; +ByteAddressBuffer bias_buffer; +RWByteAddressBuffer rw_matrix_buffer; + +[Shader("compute")] +[NumThreads(1,1,1)] +void cs_main() +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll new file mode 100644 index 0000000000..a3bfbcaa67 --- /dev/null +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll @@ -0,0 +1,127 @@ +; RUN: %dxopt %s -hlsl-passes-resume -dxilgen -S | FileCheck %s + +target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" +target triple = "dxil-ms-dx" + +%struct.ByteAddressBuffer = type { i32 } +%struct.RWByteAddressBuffer = type { i32 } +%dx.types.Handle = type { i8* } +%dx.types.ResourceProperties = type { i32, i32 } + +@"\01?matrix_buffer@@3UByteAddressBuffer@@A" = external global %struct.ByteAddressBuffer, align 4 +@"\01?bias_buffer@@3UByteAddressBuffer@@A" = external global %struct.ByteAddressBuffer, align 4 +@"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A" = external global %struct.RWByteAddressBuffer, align 4 + +; CHECK-LABEL: define void @cs_main() +; Function Attrs: nounwind +define void @cs_main() #0 { +entry: + %output_vector = alloca <4 x float>, align 4 + %tmp = bitcast <4 x float>* %output_vector to i8*, !dbg !19 ; line:9 col:2 + call void @llvm.lifetime.start(i64 16, i8* %tmp) #0, !dbg !19 ; line:9 col:2 + %tmp1 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !23 ; line:24 col:2 + %tmp2 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp1), !dbg !23 ; line:24 col:2 + %tmp3 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp2, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !23 ; line:24 col:2 + + ;CHECK: call <4 x float> @dx.op.matVecMul.v4f32.v4f32(i32 305, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %1, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, i1 false) + + call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 360, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp3, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64), !dbg !23 ; line:24 col:2 + %tmp4 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !24 ; line:32 col:2 + %tmp5 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp4), !dbg !24 ; line:32 col:2 + %tmp6 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp5, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !24 ; line:32 col:2 + %tmp7 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !dbg !24 ; line:32 col:2 + %tmp8 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp7), !dbg !24 ; line:32 col:2 + %tmp9 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp8, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !24 ; line:32 col:2 + + ;CHECK: call <4 x float> @dx.op.matVecMulAdd.v4f32.v4f32(i32 306, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %4, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %6, i32 0, i32 9, i1 false) + + call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 361, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp6, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %tmp9, i32 0, i32 9), !dbg !24 ; line:32 col:2 + %tmp10 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !25 ; line:45 col:2 + %tmp11 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp10), !dbg !25 ; line:45 col:2 + %tmp12 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp11, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !25 ; line:45 col:2 + ;CHECK: call void @dx.op.outerProductAccumulate.v8i32.v8i32(i32 307, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %9, i32 0, i32 5, i32 3, i32 64) + call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 362, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %tmp12, i32 0, i32 5, i32 3, i32 64), !dbg !25 ; line:45 col:2 + %tmp13 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !26 ; line:51 col:3 + %tmp14 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp13), !dbg !26 ; line:51 col:3 + %tmp15 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp14, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !26 ; line:51 col:3 + + ;CHECK: call void @dx.op.vectorAccumulate.v8i32(i32 308, <8 x i32> undef, %dx.types.Handle %11, i32 0) + + call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 363, <8 x i32> undef, %dx.types.Handle %tmp15, i32 0), !dbg !26 ; line:51 col:3 + %tmp16 = bitcast <4 x float>* %output_vector to i8*, !dbg !27 ; line:53 col:1 + call void @llvm.lifetime.end(i64 16, i8* %tmp16) #0, !dbg !27 ; line:53 col:1 + ret void, !dbg !27 ; line:53 col:1 +} + +; Function Attrs: nounwind +declare void @llvm.lifetime.start(i64, i8* nocapture) #0 + +; Function Attrs: nounwind +declare void @llvm.lifetime.end(i64, i8* nocapture) #0 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32) #0 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32, %struct.ByteAddressBuffer) #1 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer) #1 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32) #0 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32) #0 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32, %struct.RWByteAddressBuffer) #1 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer) #1 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32, <8 x i32>, %dx.types.Handle, i32) #0 + +attributes #0 = { nounwind } +attributes #1 = { nounwind readnone } + +!llvm.module.flags = !{!0} +!pauseresume = !{!1} +!llvm.ident = !{!2} +!dx.version = !{!3} +!dx.valver = !{!3} +!dx.shaderModel = !{!4} +!dx.typeAnnotations = !{!5} +!dx.entryPoints = !{!9} +!dx.fnprops = !{!16} +!dx.options = !{!17, !18} + +!0 = !{i32 2, !"Debug Info Version", i32 3} +!1 = !{!"hlsl-hlemit", !"hlsl-hlensure"} +!2 = !{!"dxc(private) 1.8.0.4884 (anupamac/coop-vec-5, df2877762-dirty)"} +!3 = !{i32 1, i32 9} +!4 = !{!"cs", i32 6, i32 9} +!5 = !{i32 1, void ()* @cs_main, !6} +!6 = !{!7} +!7 = !{i32 1, !8, !8} +!8 = !{} +!9 = !{void ()* @cs_main, !"cs_main", null, !10, null} +!10 = !{!11, !14, null, null} +!11 = !{!12, !13} +!12 = !{i32 0, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !"matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} +!13 = !{i32 1, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !"bias_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} +!14 = !{!15} +!15 = !{i32 0, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !"rw_matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i1 false, i1 false, i1 false, null} +!16 = !{void ()* @cs_main, i32 5, i32 1, i32 1, i32 1} +!17 = !{i32 -2147483584} +!18 = !{i32 -1} +!19 = !DILocation(line: 9, column: 2, scope: !20) +!20 = !DISubprogram(name: "cs_main", scope: !21, file: !21, line: 7, type: !22, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, function: void ()* @cs_main) +!21 = !DIFile(filename: "D:\5Cgit\5Cgithub\5CDirectXShaderCompiler-acFork\5CDirectXShaderCompiler\5Ctools\5Cclang\5Ctest\5CCodeGenDXIL\5Chlsl\5Cintrinsics\5Clinang-builins.hlsl", directory: "") +!22 = !DISubroutineType(types: !8) +!23 = !DILocation(line: 24, column: 2, scope: !20) +!24 = !DILocation(line: 32, column: 2, scope: !20) +!25 = !DILocation(line: 45, column: 2, scope: !20) +!26 = !DILocation(line: 51, column: 3, scope: !20) +!27 = !DILocation(line: 53, column: 1, scope: !20) From ee9f3a2eaad2236449de899817bfc94bbabdb099 Mon Sep 17 00:00:00 2001 From: anupamac Date: Sat, 5 Apr 2025 07:41:05 -0700 Subject: [PATCH 21/93] Unit test ; Multidim overload for MatVecMul --- .../hlsl/linalg_builtins/mat-vec-mul-add.hlsl | 3 +- .../hlsl/linalg_builtins/mat-vec-mul.hlsl | 2 +- .../mat-vec-mul_multioverload.hlsl | 33 +++++++++++++++++++ .../linalg_builtins/vector-accumulate.hlsl | 2 +- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul_multioverload.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl index f756037f4c..6d41421521 100644 --- a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl @@ -5,8 +5,7 @@ ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; - -// Test use of __builtin_MatVecMulAdd in pixel shader +// Test use of __builtin_MatVecMulAdd in compute shader // CHECK: define void @main() // CHECK: call <4 x float> @dx.op.matVecMulAdd.v4f32.v4f32(i32 {{[0-9]+}}, <4 x float> {{%[0-9]+}}, i1 false, i32 9, %dx.types.Handle {{%[0-9]+}}, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle {{%[0-9]+}}, i32 0, i32 9, i1 false) diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl index dfe452aac6..c511665224 100644 --- a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl @@ -5,7 +5,7 @@ ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; -// Test use of __builtin_MatVecMulAdd in pixel shader +// Test use of __builtin_MatVecMulAdd in compute shader // CHECK: define void @main() // CHECK: call <4 x float> @dx.op.matVecMul.v4f32.v4f32(i32 {{[0-9]+}}, <4 x float> {{%[0-9]+}}, i1 false, i32 9, %dx.types.Handle {{%[0-9]+}}, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, i1 false) diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul_multioverload.hlsl new file mode 100644 index 0000000000..b5ae86594d --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul_multioverload.hlsl @@ -0,0 +1,33 @@ +// RUN: %dxc -T cs_6_9 %s | FileCheck %s + +ByteAddressBuffer input_vector_buffer; +ByteAddressBuffer matrix_buffer; +ByteAddressBuffer bias_buffer; +RWByteAddressBuffer rw_matrix_buffer; + +// Test use of __builtin_MatVecMulAdd in compute shader +// CHECK: define void @main() +// CHECK: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 {{[0-9]+}} + + +[NumThreads(1,1,1)] +void main() +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector = input_vector_buffer.Load >(0); + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 8; + const uint matrix_dimK = 8; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, + matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); +} diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl index 1372dcb818..6323e480f9 100644 --- a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl +++ b/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer matrix_buffer; -// Test use of __builtin_VectorAccumulate in pixel shader +// Test use of __builtin_VectorAccumulate in compute shader // CHECK: define void @main() // CHECK: call void @dx.op.vectorAccumulate.v2i32(i32 {{[0-9]+}}, <2 x i32> , %dx.types.Handle {{%[0-9]+}}, i32 0) From 5d3f8b23fd556fd28a56190d42ca44b67fce6b66 Mon Sep 17 00:00:00 2001 From: anupamac Date: Sat, 5 Apr 2025 15:20:56 -0700 Subject: [PATCH 22/93] Simplify Matrix Layout check --- lib/DxilValidation/DxilValidation.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index ae946e2c20..eda6018c7f 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1002,17 +1002,8 @@ static bool CheckInMemoryInterpretations(uint32_t input) { } static bool CheckMatrixLayout(unsigned input) { - - DXIL::DXILMatrixLayout ValidSet[] = { - DXIL::DXILMatrixLayout::RowMajor, DXIL::DXILMatrixLayout::ColumnMajor, - DXIL::DXILMatrixLayout::MulOptimal, - DXIL::DXILMatrixLayout::OuterProductOptimal}; - - for (auto Val : ValidSet) { - if (Val == static_cast(input)) - return true; - } - return false; + return (input <= + static_cast(DXIL::DXILMatrixLayout::OuterProductOptimal)); } static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode opcode, From d6c28062731d1bfe8154ef51b5beb8e1000d8d2e Mon Sep 17 00:00:00 2001 From: anupamac Date: Mon, 7 Apr 2025 04:42:31 -0700 Subject: [PATCH 23/93] Add checks to the HLSL source file linalg_builtins.hlsl --- .../test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl | 6 +++++- .../test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl index 2a86d3caeb..99d4e1f1f4 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl @@ -1,4 +1,4 @@ -// dxc.exe -T cs_6_9 -E cs_main %s +// RUN: dxc.exe -fcgl -T cs_6_9 -E cs_main %s ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; @@ -23,6 +23,7 @@ void cs_main() const bool matrix_is_transposed = false; const uint matrix_stride = 64; + // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 360, __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, @@ -31,6 +32,7 @@ void cs_main() const uint bias_offset = 0; const uint bias_interpretation = 9; /*F32*/ + // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 361, __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, @@ -44,12 +46,14 @@ void cs_main() const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ const uint opa_matrix_stride = 64; + // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 362, __builtin_OuterProductAccumulate(input_vector1, input_vector2, rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, opa_matrix_layout, opa_matrix_stride); const uint va_matrix_offset = 0; + // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 363, __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, va_matrix_offset); } \ No newline at end of file diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll index a3bfbcaa67..30b9339e70 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll @@ -39,6 +39,7 @@ entry: %tmp10 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !25 ; line:45 col:2 %tmp11 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp10), !dbg !25 ; line:45 col:2 %tmp12 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp11, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !25 ; line:45 col:2 + ;CHECK: call void @dx.op.outerProductAccumulate.v8i32.v8i32(i32 307, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %9, i32 0, i32 5, i32 3, i32 64) call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 362, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %tmp12, i32 0, i32 5, i32 3, i32 64), !dbg !25 ; line:45 col:2 %tmp13 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !26 ; line:51 col:3 From 7d74050416601f50545bf14d1c2e63f9cc980aea Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 7 Apr 2025 16:58:30 +0200 Subject: [PATCH 24/93] Updated RUN line and renamed test --- .../intrinsics/{linang-builins.hlsl => linalg-builtins.hlsl} | 2 +- .../hlsl/intrinsics/{linang-builins.ll => linalg-builtins.ll} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tools/clang/test/CodeGenDXIL/hlsl/intrinsics/{linang-builins.hlsl => linalg-builtins.hlsl} (97%) rename tools/clang/test/CodeGenDXIL/hlsl/intrinsics/{linang-builins.ll => linalg-builtins.ll} (100%) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.hlsl similarity index 97% rename from tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.hlsl index 99d4e1f1f4..e1ee8fbb60 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.hlsl @@ -1,4 +1,4 @@ -// RUN: dxc.exe -fcgl -T cs_6_9 -E cs_main %s +// RUN: %dxc -fcgl -T cs_6_9 -E cs_main %s | FileCheck %s ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.ll similarity index 100% rename from tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linang-builins.ll rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.ll From 724bebda33591dbce17e80e6286e4d767a83d9f6 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 8 Apr 2025 13:33:17 +0200 Subject: [PATCH 25/93] cleanup test --- .../hlsl/intrinsics/linalg-builtins.ll | 116 +++++++++--------- 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.ll b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.ll index 30b9339e70..95f48785f3 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.ll +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.ll @@ -17,41 +17,41 @@ target triple = "dxil-ms-dx" define void @cs_main() #0 { entry: %output_vector = alloca <4 x float>, align 4 - %tmp = bitcast <4 x float>* %output_vector to i8*, !dbg !19 ; line:9 col:2 - call void @llvm.lifetime.start(i64 16, i8* %tmp) #0, !dbg !19 ; line:9 col:2 - %tmp1 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !23 ; line:24 col:2 - %tmp2 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp1), !dbg !23 ; line:24 col:2 - %tmp3 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp2, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !23 ; line:24 col:2 + %tmp = bitcast <4 x float>* %output_vector to i8*, !dbg !18 ; line:9 col:2 + call void @llvm.lifetime.start(i64 16, i8* %tmp) #0, !dbg !18 ; line:9 col:2 + %tmp1 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !22 ; line:24 col:2 + %tmp2 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp1), !dbg !22 ; line:24 col:2 + %tmp3 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp2, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !22 ; line:24 col:2 ;CHECK: call <4 x float> @dx.op.matVecMul.v4f32.v4f32(i32 305, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %1, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, i1 false) - call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 360, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp3, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64), !dbg !23 ; line:24 col:2 - %tmp4 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !24 ; line:32 col:2 - %tmp5 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp4), !dbg !24 ; line:32 col:2 - %tmp6 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp5, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !24 ; line:32 col:2 - %tmp7 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !dbg !24 ; line:32 col:2 - %tmp8 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp7), !dbg !24 ; line:32 col:2 - %tmp9 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp8, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !24 ; line:32 col:2 + call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 360, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp3, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64), !dbg !22 ; line:24 col:2 + %tmp4 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !23 ; line:32 col:2 + %tmp5 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp4), !dbg !23 ; line:32 col:2 + %tmp6 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp5, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !23 ; line:32 col:2 + %tmp7 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !dbg !23 ; line:32 col:2 + %tmp8 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp7), !dbg !23 ; line:32 col:2 + %tmp9 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp8, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !23 ; line:32 col:2 ;CHECK: call <4 x float> @dx.op.matVecMulAdd.v4f32.v4f32(i32 306, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %4, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %6, i32 0, i32 9, i1 false) - call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 361, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp6, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %tmp9, i32 0, i32 9), !dbg !24 ; line:32 col:2 - %tmp10 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !25 ; line:45 col:2 - %tmp11 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp10), !dbg !25 ; line:45 col:2 - %tmp12 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp11, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !25 ; line:45 col:2 + call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 361, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp6, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %tmp9, i32 0, i32 9), !dbg !23 ; line:32 col:2 + %tmp10 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !24 ; line:45 col:2 + %tmp11 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp10), !dbg !24 ; line:45 col:2 + %tmp12 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp11, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !24 ; line:45 col:2 - ;CHECK: call void @dx.op.outerProductAccumulate.v8i32.v8i32(i32 307, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %9, i32 0, i32 5, i32 3, i32 64) - call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 362, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %tmp12, i32 0, i32 5, i32 3, i32 64), !dbg !25 ; line:45 col:2 - %tmp13 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !26 ; line:51 col:3 - %tmp14 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp13), !dbg !26 ; line:51 col:3 - %tmp15 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp14, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !26 ; line:51 col:3 + ; CHECK: call void @dx.op.outerProductAccumulate.v8i32.v8i32(i32 307, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 5, i32 3, i32 64) + call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 362, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %tmp12, i32 0, i32 5, i32 3, i32 64), !dbg !24 ; line:45 col:2 + %tmp13 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !25 ; line:51 col:3 + %tmp14 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp13), !dbg !25 ; line:51 col:3 + %tmp15 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp14, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !25 ; line:51 col:3 ;CHECK: call void @dx.op.vectorAccumulate.v8i32(i32 308, <8 x i32> undef, %dx.types.Handle %11, i32 0) - call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 363, <8 x i32> undef, %dx.types.Handle %tmp15, i32 0), !dbg !26 ; line:51 col:3 - %tmp16 = bitcast <4 x float>* %output_vector to i8*, !dbg !27 ; line:53 col:1 - call void @llvm.lifetime.end(i64 16, i8* %tmp16) #0, !dbg !27 ; line:53 col:1 - ret void, !dbg !27 ; line:53 col:1 + call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 363, <8 x i32> undef, %dx.types.Handle %tmp15, i32 0), !dbg !25 ; line:51 col:3 + %tmp16 = bitcast <4 x float>* %output_vector to i8*, !dbg !26 ; line:53 col:1 + call void @llvm.lifetime.end(i64 16, i8* %tmp16) #0, !dbg !26 ; line:53 col:1 + ret void, !dbg !26 ; line:53 col:1 } ; Function Attrs: nounwind @@ -89,40 +89,38 @@ attributes #1 = { nounwind readnone } !llvm.module.flags = !{!0} !pauseresume = !{!1} -!llvm.ident = !{!2} -!dx.version = !{!3} -!dx.valver = !{!3} -!dx.shaderModel = !{!4} -!dx.typeAnnotations = !{!5} -!dx.entryPoints = !{!9} -!dx.fnprops = !{!16} -!dx.options = !{!17, !18} +!dx.version = !{!2} +!dx.valver = !{!2} +!dx.shaderModel = !{!3} +!dx.typeAnnotations = !{!4} +!dx.entryPoints = !{!8} +!dx.fnprops = !{!15} +!dx.options = !{!16, !17} !0 = !{i32 2, !"Debug Info Version", i32 3} !1 = !{!"hlsl-hlemit", !"hlsl-hlensure"} -!2 = !{!"dxc(private) 1.8.0.4884 (anupamac/coop-vec-5, df2877762-dirty)"} -!3 = !{i32 1, i32 9} -!4 = !{!"cs", i32 6, i32 9} -!5 = !{i32 1, void ()* @cs_main, !6} -!6 = !{!7} -!7 = !{i32 1, !8, !8} -!8 = !{} -!9 = !{void ()* @cs_main, !"cs_main", null, !10, null} -!10 = !{!11, !14, null, null} -!11 = !{!12, !13} -!12 = !{i32 0, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !"matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} -!13 = !{i32 1, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !"bias_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} -!14 = !{!15} -!15 = !{i32 0, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !"rw_matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i1 false, i1 false, i1 false, null} -!16 = !{void ()* @cs_main, i32 5, i32 1, i32 1, i32 1} -!17 = !{i32 -2147483584} -!18 = !{i32 -1} -!19 = !DILocation(line: 9, column: 2, scope: !20) -!20 = !DISubprogram(name: "cs_main", scope: !21, file: !21, line: 7, type: !22, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, function: void ()* @cs_main) -!21 = !DIFile(filename: "D:\5Cgit\5Cgithub\5CDirectXShaderCompiler-acFork\5CDirectXShaderCompiler\5Ctools\5Cclang\5Ctest\5CCodeGenDXIL\5Chlsl\5Cintrinsics\5Clinang-builins.hlsl", directory: "") -!22 = !DISubroutineType(types: !8) -!23 = !DILocation(line: 24, column: 2, scope: !20) -!24 = !DILocation(line: 32, column: 2, scope: !20) -!25 = !DILocation(line: 45, column: 2, scope: !20) -!26 = !DILocation(line: 51, column: 3, scope: !20) -!27 = !DILocation(line: 53, column: 1, scope: !20) +!2 = !{i32 1, i32 9} +!3 = !{!"cs", i32 6, i32 9} +!4 = !{i32 1, void ()* @cs_main, !5} +!5 = !{!6} +!6 = !{i32 1, !7, !7} +!7 = !{} +!8 = !{void ()* @cs_main, !"cs_main", null, !9, null} +!9 = !{!10, !13, null, null} +!10 = !{!11, !12} +!11 = !{i32 0, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !"matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} +!12 = !{i32 1, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !"bias_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} +!13 = !{!14} +!14 = !{i32 0, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !"rw_matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i1 false, i1 false, i1 false, null} +!15 = !{void ()* @cs_main, i32 5, i32 1, i32 1, i32 1} +!16 = !{i32 -2147483584} +!17 = !{i32 -1} +!18 = !DILocation(line: 9, column: 2, scope: !19) +!19 = !DISubprogram(name: "cs_main", scope: !20, file: !20, line: 7, type: !21, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, function: void ()* @cs_main) +!20 = !DIFile(filename: "DirectXShaderCompiler\5Ctools\5Cclang\5Ctest\5CCodeGenDXIL\5Chlsl\5Cintrinsics\5Clinalg-builtins.hlsl", directory: "") +!21 = !DISubroutineType(types: !7) +!22 = !DILocation(line: 24, column: 2, scope: !19) +!23 = !DILocation(line: 32, column: 2, scope: !19) +!24 = !DILocation(line: 45, column: 2, scope: !19) +!25 = !DILocation(line: 51, column: 3, scope: !19) +!26 = !DILocation(line: 53, column: 1, scope: !19) From 615824dda332ad550ef945a19b1f3a77a4bd325e Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 8 Apr 2025 09:54:14 +0200 Subject: [PATCH 26/93] [nfc] Fix -Werror by removing braces --- lib/HLSL/HLOperationLower.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index 3288b18a13..2ec397743d 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -6488,7 +6488,7 @@ Value *TranslateVectorAccumulate(CallInst *CI, IntrinsicOp IOP, CI->getArgOperand(HLOperandIndex::kVectorAccMatrixOffsetIdx); // Get the DXIL function for the operation - Function *DxilFunc = HlslOp->GetOpFunc(OpCode, {InputVector->getType()}); + Function *DxilFunc = HlslOp->GetOpFunc(OpCode, InputVector->getType()); return Builder.CreateCall(DxilFunc, {OpArg, InputVector, MatrixBuffer, MatrixOffset}); From 5b3b7cec90e5aff08f6bfacdf2089b218c8e2eff Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 8 Apr 2025 13:33:43 +0200 Subject: [PATCH 27/93] Fix debug field names for vectors > 4 elements --- tools/clang/lib/CodeGen/CGDebugInfo.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/clang/lib/CodeGen/CGDebugInfo.cpp b/tools/clang/lib/CodeGen/CGDebugInfo.cpp index 206f7d9523..bf637c603f 100644 --- a/tools/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/tools/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1047,8 +1047,15 @@ bool CGDebugInfo::TryCollectHLSLRecordElements(const RecordType *Ty, unsigned VecSize = hlsl::GetHLSLVecSize(QualTy); unsigned ElemSizeInBits = CGM.getContext().getTypeSize(ElemQualTy); unsigned CurrentAlignedOffset = 0; + std::string FieldNameBuf; for (unsigned ElemIdx = 0; ElemIdx < VecSize; ++ElemIdx) { - StringRef FieldName = StringRef(&"xyzw"[ElemIdx], 1); + StringRef FieldName; + if (VecSize <= 4) { + FieldName = StringRef(&"xyzw"[ElemIdx], 1); + } else { + FieldNameBuf = "c" + std::to_string(ElemIdx); + FieldName = FieldNameBuf; + } CurrentAlignedOffset = llvm::RoundUpToAlignment(CurrentAlignedOffset, AlignBits); llvm::DIType *FieldType = From 453d6434042726ee7ad490c36216c59a9e96a89e Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Wed, 9 Apr 2025 07:25:15 +0200 Subject: [PATCH 28/93] [nfc] auto-format hctdb.py --- utils/hct/hctdb.py | 211 ++++++++++++++++++++++++--------------------- 1 file changed, 115 insertions(+), 96 deletions(-) diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 4853e1ca45..70da73e300 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -855,7 +855,9 @@ def populate_categories_and_models(self): "closesthit", "miss", ) - for i in ("MatVecMul,MatVecMulAdd,OuterProductAccumulate,VectorAccumulate").split(","): + for i in ( + "MatVecMul,MatVecMulAdd,OuterProductAccumulate,VectorAccumulate" + ).split(","): self.name_idx[i].category = "Linear Algebra Operations" self.name_idx[i].shader_model = 6, 9 @@ -5852,92 +5854,94 @@ def UFI(name, **mappings): next_op_idx += 1 self.add_dxil_op( - "MatVecMul", - next_op_idx, - "MatVecMul", - "Multiplies a MxK dimension matrix and a K sized input vector", - " Date: Wed, 9 Apr 2025 07:58:28 +0200 Subject: [PATCH 29/93] Move sema test to SemaHLSL test folder (spurious CodeGenHashStabilityHLSL failures if verify thests live in HLSLFileCheck) --- .../hlsl/linalg}/unavailable-pre-sm69.hlsl | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/clang/test/{HLSLFileCheck/hlsl/linalg_builtins => SemaHLSL/hlsl/linalg}/unavailable-pre-sm69.hlsl (100%) diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/unavailable-pre-sm69.hlsl b/tools/clang/test/SemaHLSL/hlsl/linalg/unavailable-pre-sm69.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/unavailable-pre-sm69.hlsl rename to tools/clang/test/SemaHLSL/hlsl/linalg/unavailable-pre-sm69.hlsl From bc1082e333d0034cf92ce9992f92e2a8db04d671 Mon Sep 17 00:00:00 2001 From: Damyan Pepper Date: Wed, 9 Apr 2025 20:45:02 -0700 Subject: [PATCH 30/93] Revert SPIRV-Tools submodule to match staging-sm6.9 and main --- external/SPIRV-Tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/SPIRV-Tools b/external/SPIRV-Tools index 393d5c7df1..4bd1536ed7 160000 --- a/external/SPIRV-Tools +++ b/external/SPIRV-Tools @@ -1 +1 @@ -Subproject commit 393d5c7df150532045c50affffea2df22e8231b0 +Subproject commit 4bd1536ed79003a5194a4bd8c9aa2fa17a84c15b From 5455e64f10c3e42bf131acf138fd82fa15c445a4 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:54:07 +0200 Subject: [PATCH 31/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index b0fa256021..00e962a3e2 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1114,9 +1114,9 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInterpretationParamAreConst); } - ConstantInt *Mi = cast(MatrixInterpretation); - auto MiValue = Mi->getLimitedValue(); - if (!CheckInMemoryInterpretations(MiValue)) { + ConstantInt *MI = cast(MatrixInterpretation); + auto MIValue = MI->getLimitedValue(); + if (!CheckInMemoryInterpretations(MIValue)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); } From c626bdbcf40fb71b7ecc904cdbbcea3e3b3e02b3 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:54:17 +0200 Subject: [PATCH 32/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 00e962a3e2..2976333257 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1125,9 +1125,9 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst); } - ConstantInt *Ml = cast(MatrixLayout); - auto MlValue = Ml->getLimitedValue(); - if (!CheckMatrixLayout(MlValue)) { + ConstantInt *ML = cast(MatrixLayout); + auto MLValue = ML->getLimitedValue(); + if (!CheckMatrixLayout(MLValue)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMatrixLayoutValue); } From da9f54930875da0b0a4271360e8f1afa5124a1de Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:54:30 +0200 Subject: [PATCH 33/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 2976333257..5f6def496b 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1102,7 +1102,6 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode opcode, } static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, - DXIL::OpCode opcode, ValidationContext &ValCtx) { llvm::Value *MatrixInterpretation = From ebdc4546497d26f4ef5cccb91151a7d59fc59c9f Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:54:51 +0200 Subject: [PATCH 34/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 5f6def496b..2c70402461 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -970,7 +970,7 @@ static void ValidateImmOperandForMathDxilOp(CallInst *CI, DXIL::OpCode Opcode, } } -static bool CheckFromRegisterInterpretations(uint32_t input) { +static bool CheckFromRegisterInterpretations(uint32_t Input) { DXIL::ComponentType ValidSet[] = { DXIL::ComponentType::I16, DXIL::ComponentType::U16, DXIL::ComponentType::I32, DXIL::ComponentType::U32, From 6bb201a5287270d68d0a957dd7357e11953d4174 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:55:17 +0200 Subject: [PATCH 35/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 2c70402461..5a88c1f4aa 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -980,7 +980,7 @@ static bool CheckFromRegisterInterpretations(uint32_t Input) { DXIL::ComponentType::F8_E4M3, DXIL::ComponentType::F8_E5M2}; for (auto Val : ValidSet) { - if (Val == static_cast(input)) + if (Val == static_cast(Input)) return true; } return false; From 3816d7c90f5d34ac68c1c8709fb6ee7b816de0e3 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:55:49 +0200 Subject: [PATCH 36/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 5a88c1f4aa..44825aae31 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -986,7 +986,7 @@ static bool CheckFromRegisterInterpretations(uint32_t Input) { return false; } -static bool CheckInMemoryInterpretations(uint32_t input) { +static bool CheckInMemoryInterpretations(uint32_t Input) { DXIL::ComponentType ValidSet[] = { DXIL::ComponentType::I16, DXIL::ComponentType::U16, DXIL::ComponentType::I32, DXIL::ComponentType::U32, From 0166d205635ba1b361c4d5a5795ae5b5bd467cd7 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:56:06 +0200 Subject: [PATCH 37/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 44825aae31..aed9cc0754 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1089,9 +1089,9 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode opcode, ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInterpretationParamAreConst); } - ConstantInt *Bi = cast(BiasInterpretation); - auto BiValue = Bi->getLimitedValue(); - if (!CheckInMemoryInterpretations(BiValue)) { + ConstantInt *BI = cast(BiasInterpretation); + auto BIValue = BI->getLimitedValue(); + if (!CheckInMemoryInterpretations(BIValue)) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); } From 3027487db42dd5bd3ea8dec9724b70bf6d19d553 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:56:31 +0200 Subject: [PATCH 38/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index aed9cc0754..72b40f658b 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1059,9 +1059,9 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode opcode, ValidationRule::InstrLinalgMatrixShapeParamsAreConst); } - ConstantInt *Ml = cast(MatrixLayout); - auto MlValue = Ml->getLimitedValue(); - if (!CheckMatrixLayout(MlValue)) { + ConstantInt *ML = cast(MatrixLayout); + auto MLValue = ML->getLimitedValue(); + if (!CheckMatrixLayout(MLValue)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMatrixLayoutValue); } From a80ab65d334cfaa3d625de1e25ba09231a0b708f Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:56:53 +0200 Subject: [PATCH 39/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 72b40f658b..04490f6673 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1044,9 +1044,9 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode opcode, CI, ValidationRule::InstrLinalgInvalidRegisterInterpValue); } - ConstantInt *Mi = cast(MatrixInterpretation); - auto MiValue = Mi->getLimitedValue(); - if (!CheckInMemoryInterpretations(MiValue)) { + ConstantInt *MI = cast(MatrixInterpretation); + auto MIValue = MI->getLimitedValue(); + if (!CheckInMemoryInterpretations(MIValue)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); } From 067bea3d9ae7eb4928507490fe398cfd0b40bea8 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:57:14 +0200 Subject: [PATCH 40/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 04490f6673..5afe707010 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1037,9 +1037,9 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode opcode, } // Check if InputInterpretation and MatrixInterpretation are valid - ConstantInt *Ii = cast(InputInterpretation); - auto IiValue = Ii->getLimitedValue(); - if (!CheckFromRegisterInterpretations(IiValue)) { + ConstantInt *II = cast(InputInterpretation); + auto IIValue = II->getLimitedValue(); + if (!CheckFromRegisterInterpretations(IIValue)) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInvalidRegisterInterpValue); } From 1dc4b2d9f736098d6fa78db6b8f8604716abf1b5 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:57:34 +0200 Subject: [PATCH 41/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 5afe707010..94772ab900 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1006,7 +1006,7 @@ static bool CheckMatrixLayout(unsigned input) { static_cast(DXIL::DXILMatrixLayout::OuterProductOptimal)); } -static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode opcode, +static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, ValidationContext &ValCtx) { // Check Common operands From 3d0612062aa88ab7c14d3e93f57863b2122145df Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:57:53 +0200 Subject: [PATCH 42/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 94772ab900..c418445b79 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1001,8 +1001,8 @@ static bool CheckInMemoryInterpretations(uint32_t Input) { return false; } -static bool CheckMatrixLayout(unsigned input) { - return (input <= +static bool CheckMatrixLayout(unsigned Input) { + return (Input <= static_cast(DXIL::DXILMatrixLayout::OuterProductOptimal)); } From cde0954e20dabd8c48598b94656bbcdc4841ab87 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:58:10 +0200 Subject: [PATCH 43/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Tex Riddell --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index c418445b79..57a5c7f447 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -995,7 +995,7 @@ static bool CheckInMemoryInterpretations(uint32_t Input) { DXIL::ComponentType::F8_E4M3, DXIL::ComponentType::F8_E5M2}; for (auto Val : ValidSet) { - if (Val == static_cast(input)) + if (Val == static_cast(Input)) return true; } return false; From 372c43116489d48eae609a6bdfbd743f4dc59b38 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 09:08:07 +0200 Subject: [PATCH 44/93] [nfc] Coding Standards changes --- lib/DxilValidation/DxilValidation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 57a5c7f447..645a5d4a88 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1066,7 +1066,7 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, ValidationRule::InstrLinalgInvalidMatrixLayoutValue); } - switch (opcode) { + switch (OpCode) { case DXIL::OpCode::MatVecMul: { llvm::Value *OutputIsUnsigned = CI->getOperand(DXIL::OperandIndex::kMatVecMulIsOutputUnsignedIdx); @@ -2122,7 +2122,7 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI, ValidateImmOperandsForMatVecOps(CI, Opcode, ValCtx); break; case DXIL::OpCode::OuterProductAccumulate: - ValidateImmOperandsForOuterProdAcc(CI, Opcode, ValCtx); + ValidateImmOperandsForOuterProdAcc(CI, ValCtx); break; case DXIL::OpCode::VectorAccumulate: From 7633d12ede0993b0ab329c1072e1183345d6b582 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:33:02 +0200 Subject: [PATCH 45/93] Renamed params to isInput|OutputUnsigned and fixed description --- include/dxc/DXIL/DxilInstructions.h | 24 ++++++++++++------------ utils/hct/hctdb.py | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/dxc/DXIL/DxilInstructions.h b/include/dxc/DXIL/DxilInstructions.h index 867c93d824..6f9ecf6fac 100644 --- a/include/dxc/DXIL/DxilInstructions.h +++ b/include/dxc/DXIL/DxilInstructions.h @@ -9038,7 +9038,7 @@ struct DxilInst_MatVecMul { // Operand indexes enum OperandIdx { arg_inputVector = 1, - arg_inputIsUnsigned = 2, + arg_isInputUnsigned = 2, arg_inputInterpretation = 3, arg_matrixBuffer = 4, arg_matrixOffset = 5, @@ -9048,13 +9048,13 @@ struct DxilInst_MatVecMul { arg_matrixLayout = 9, arg_matrixTranspose = 10, arg_matrixStride = 11, - arg_outputIsUnsigned = 12, + arg_isOutputUnsigned = 12, }; // Accessors llvm::Value *get_inputVector() const { return Instr->getOperand(1); } void set_inputVector(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_inputIsUnsigned() const { return Instr->getOperand(2); } - void set_inputIsUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_isInputUnsigned() const { return Instr->getOperand(2); } + void set_isInputUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_inputInterpretation() const { return Instr->getOperand(3); } void set_inputInterpretation(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_matrixBuffer() const { return Instr->getOperand(4); } @@ -9073,8 +9073,8 @@ struct DxilInst_MatVecMul { void set_matrixTranspose(llvm::Value *val) { Instr->setOperand(10, val); } llvm::Value *get_matrixStride() const { return Instr->getOperand(11); } void set_matrixStride(llvm::Value *val) { Instr->setOperand(11, val); } - llvm::Value *get_outputIsUnsigned() const { return Instr->getOperand(12); } - void set_outputIsUnsigned(llvm::Value *val) { Instr->setOperand(12, val); } + llvm::Value *get_isOutputUnsigned() const { return Instr->getOperand(12); } + void set_isOutputUnsigned(llvm::Value *val) { Instr->setOperand(12, val); } }; /// This instruction multiplies a MxK dimension matrix and a K sized input @@ -9099,7 +9099,7 @@ struct DxilInst_MatVecMulAdd { // Operand indexes enum OperandIdx { arg_inputVector = 1, - arg_inputIsUnsigned = 2, + arg_isInputUnsigned = 2, arg_inputInterpretation = 3, arg_matrixBuffer = 4, arg_matrixOffset = 5, @@ -9112,13 +9112,13 @@ struct DxilInst_MatVecMulAdd { arg_biasBuffer = 12, arg_biasOffset = 13, arg_biasIntepretation = 14, - arg_outputIsUnsigned = 15, + arg_isOutputUnsigned = 15, }; // Accessors llvm::Value *get_inputVector() const { return Instr->getOperand(1); } void set_inputVector(llvm::Value *val) { Instr->setOperand(1, val); } - llvm::Value *get_inputIsUnsigned() const { return Instr->getOperand(2); } - void set_inputIsUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } + llvm::Value *get_isInputUnsigned() const { return Instr->getOperand(2); } + void set_isInputUnsigned(llvm::Value *val) { Instr->setOperand(2, val); } llvm::Value *get_inputInterpretation() const { return Instr->getOperand(3); } void set_inputInterpretation(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_matrixBuffer() const { return Instr->getOperand(4); } @@ -9143,8 +9143,8 @@ struct DxilInst_MatVecMulAdd { void set_biasOffset(llvm::Value *val) { Instr->setOperand(13, val); } llvm::Value *get_biasIntepretation() const { return Instr->getOperand(14); } void set_biasIntepretation(llvm::Value *val) { Instr->setOperand(14, val); } - llvm::Value *get_outputIsUnsigned() const { return Instr->getOperand(15); } - void set_outputIsUnsigned(llvm::Value *val) { Instr->setOperand(15, val); } + llvm::Value *get_isOutputUnsigned() const { return Instr->getOperand(15); } + void set_isOutputUnsigned(llvm::Value *val) { Instr->setOperand(15, val); } }; /// This instruction Computes the outer product between column vectors and an diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 6e110c718f..c6a43ba0a3 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -5865,7 +5865,7 @@ def UFI(name, **mappings): [ db_dxil_param(0, "$x0", "outputVector", "output vector"), db_dxil_param(2, "$x1", "inputVector", "input vector"), - db_dxil_param(3, "i1", "inputIsUnsigned", "input signed op kind"), + db_dxil_param(3, "i1", "isInputUnsigned", "is input unsigned"), db_dxil_param(4, "i32", "inputInterpretation", "input interpretation"), db_dxil_param(5, "res", "matrixBuffer", "matrix resource"), db_dxil_param(6, "i32", "matrixOffset", "matrix offset"), @@ -5875,7 +5875,7 @@ def UFI(name, **mappings): db_dxil_param(10, "i32", "matrixLayout", "matrix layout"), db_dxil_param(11, "i1", "matrixTranspose", "matrix transpose"), db_dxil_param(12, "i32", "matrixStride", "matrix stride"), - db_dxil_param(13, "i1", "outputIsUnsigned", "output signed op kind"), + db_dxil_param(13, "i1", "isOutputUnsigned", "is output unsigned"), ], ) next_op_idx += 1 @@ -5890,7 +5890,7 @@ def UFI(name, **mappings): [ db_dxil_param(0, "$x0", "outputVector", "output vector"), db_dxil_param(2, "$x1", "inputVector", "input vector"), - db_dxil_param(3, "i1", "inputIsUnsigned", "input signed op kind"), + db_dxil_param(3, "i1", "isInputUnsigned", "is input unsigned"), db_dxil_param(4, "i32", "inputInterpretation", "input interpretation"), db_dxil_param(5, "res", "matrixBuffer", "matrix resource"), db_dxil_param(6, "i32", "matrixOffset", "matrix offset"), @@ -5905,7 +5905,7 @@ def UFI(name, **mappings): db_dxil_param( 15, "i32", "biasIntepretation", "bias vector intepretation" ), - db_dxil_param(16, "i1", "outputIsUnsigned", "output signed op kind"), + db_dxil_param(16, "i1", "isOutputUnsigned", "is output unsigned"), ], ) next_op_idx += 1 From 9aa5df72b174c19aff8977d8830fe1b3078dff4e Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 07:50:38 +0200 Subject: [PATCH 46/93] Explicitly assign numbers to ComponentType enum --- include/dxc/DXIL/DxilConstants.h | 44 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index 711db0d63f..be34eaeb90 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -162,30 +162,30 @@ const unsigned kDxilMaxOloadDims = 2; enum class ComponentType : uint32_t { Invalid = 0, - I1, - I16, // = 2 - U16, // = 3 - I32, // = 4 - U32, // = 5 - I64, - U64, - F16, // = 8 - F32, // = 9 - F64, - SNormF16, - UNormF16, - SNormF32, - UNormF32, - SNormF64, - UNormF64, - PackedS8x32, // = 17 - PackedU8x32, // = 18 + I1 = 1, + I16 = 2, + U16 = 3, + I32 = 4, + U32 = 5, + I64 = 6, + U64 = 7, + F16 = 8, + F32 = 9, + F64 = 10, + SNormF16 = 11, + UNormF16 = 12, + SNormF32 = 13, + UNormF32 = 14, + SNormF64 = 15, + UNormF64 = 16, + PackedS8x32 = 17, + PackedU8x32 = 18, // BEGIN NEW FOR SM 6.9 - U8, // = 19 - I8, // = 20 - F8_E4M3, // = 21 - F8_E5M2, // = 22 + U8 = 19, + I8 = 20, + F8_E4M3 = 21, + F8_E5M2 = 22, // END LastEntry From d2cbc3b8ccedc178842ec04b261f6148f3908644 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 10:44:27 +0200 Subject: [PATCH 47/93] Move debug info fix into separate PR #7332 --- tools/clang/lib/CodeGen/CGDebugInfo.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/clang/lib/CodeGen/CGDebugInfo.cpp b/tools/clang/lib/CodeGen/CGDebugInfo.cpp index bf637c603f..206f7d9523 100644 --- a/tools/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/tools/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1047,15 +1047,8 @@ bool CGDebugInfo::TryCollectHLSLRecordElements(const RecordType *Ty, unsigned VecSize = hlsl::GetHLSLVecSize(QualTy); unsigned ElemSizeInBits = CGM.getContext().getTypeSize(ElemQualTy); unsigned CurrentAlignedOffset = 0; - std::string FieldNameBuf; for (unsigned ElemIdx = 0; ElemIdx < VecSize; ++ElemIdx) { - StringRef FieldName; - if (VecSize <= 4) { - FieldName = StringRef(&"xyzw"[ElemIdx], 1); - } else { - FieldNameBuf = "c" + std::to_string(ElemIdx); - FieldName = FieldNameBuf; - } + StringRef FieldName = StringRef(&"xyzw"[ElemIdx], 1); CurrentAlignedOffset = llvm::RoundUpToAlignment(CurrentAlignedOffset, AlignBits); llvm::DIType *FieldType = From df67c9faebc731a7241b43332556910f395f9ac6 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 11:13:02 +0200 Subject: [PATCH 48/93] move all tests to CodeGenDXIL/hlsl/intrinsics/linalg_builtin and make folder require dxil-1-9 --- .../hlsl/intrinsics}/linalg_builtins/check-shader-stages.hlsl | 0 .../hlsl/intrinsics/{ => linalg_builtins}/linalg-builtins.hlsl | 0 .../hlsl/intrinsics/{ => linalg_builtins}/linalg-builtins.ll | 0 .../CodeGenDXIL/hlsl/intrinsics/linalg_builtins/lit.local.cfg | 1 + .../hlsl/intrinsics}/linalg_builtins/mat-vec-mul-add.hlsl | 0 .../hlsl/intrinsics}/linalg_builtins/mat-vec-mul.hlsl | 0 .../intrinsics}/linalg_builtins/mat-vec-mul_multioverload.hlsl | 0 .../linalg_builtins/outer-product-accumulate-multioverload.hlsl | 0 .../intrinsics}/linalg_builtins/outer-product-accumulate.hlsl | 0 .../hlsl/intrinsics}/linalg_builtins/vector-accumulate.hlsl | 0 10 files changed, 1 insertion(+) rename tools/clang/test/{HLSLFileCheck/hlsl => CodeGenDXIL/hlsl/intrinsics}/linalg_builtins/check-shader-stages.hlsl (100%) rename tools/clang/test/CodeGenDXIL/hlsl/intrinsics/{ => linalg_builtins}/linalg-builtins.hlsl (100%) rename tools/clang/test/CodeGenDXIL/hlsl/intrinsics/{ => linalg_builtins}/linalg-builtins.ll (100%) create mode 100644 tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/lit.local.cfg rename tools/clang/test/{HLSLFileCheck/hlsl => CodeGenDXIL/hlsl/intrinsics}/linalg_builtins/mat-vec-mul-add.hlsl (100%) rename tools/clang/test/{HLSLFileCheck/hlsl => CodeGenDXIL/hlsl/intrinsics}/linalg_builtins/mat-vec-mul.hlsl (100%) rename tools/clang/test/{HLSLFileCheck/hlsl => CodeGenDXIL/hlsl/intrinsics}/linalg_builtins/mat-vec-mul_multioverload.hlsl (100%) rename tools/clang/test/{HLSLFileCheck/hlsl => CodeGenDXIL/hlsl/intrinsics}/linalg_builtins/outer-product-accumulate-multioverload.hlsl (100%) rename tools/clang/test/{HLSLFileCheck/hlsl => CodeGenDXIL/hlsl/intrinsics}/linalg_builtins/outer-product-accumulate.hlsl (100%) rename tools/clang/test/{HLSLFileCheck/hlsl => CodeGenDXIL/hlsl/intrinsics}/linalg_builtins/vector-accumulate.hlsl (100%) diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/check-shader-stages.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/check-shader-stages.hlsl rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl similarity index 100% rename from tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.hlsl rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.ll b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.ll similarity index 100% rename from tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg-builtins.ll rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.ll diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/lit.local.cfg b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/lit.local.cfg new file mode 100644 index 0000000000..c2417a9e43 --- /dev/null +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/lit.local.cfg @@ -0,0 +1 @@ +config.unsupported = 'dxil-1-9' not in config.available_features \ No newline at end of file diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul-add.hlsl rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul.hlsl rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/mat-vec-mul_multioverload.hlsl rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate-multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate-multioverload.hlsl rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/outer-product-accumulate.hlsl rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl diff --git a/tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/vector-accumulate.hlsl similarity index 100% rename from tools/clang/test/HLSLFileCheck/hlsl/linalg_builtins/vector-accumulate.hlsl rename to tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/vector-accumulate.hlsl From e15eacb3dd2ed7d6921ad1e155145a84c126d049 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 11:21:20 +0200 Subject: [PATCH 49/93] Move linalg-builtins.ll test to DXC/Passes/DxilGen --- .../linalg_builtins => DXC/Passes/DxilGen}/linalg-builtins.ll | 1 + 1 file changed, 1 insertion(+) rename tools/clang/test/{CodeGenDXIL/hlsl/intrinsics/linalg_builtins => DXC/Passes/DxilGen}/linalg-builtins.ll (99%) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.ll b/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll similarity index 99% rename from tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.ll rename to tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll index 1631d6190d..2687631f39 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.ll +++ b/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll @@ -1,4 +1,5 @@ ; RUN: %dxopt %s -hlsl-passes-resume -dxilgen -S | FileCheck %s +; REQUIRES: dxil-1-9 target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" target triple = "dxil-ms-dx" From 9fcf8c758941704fbb13b6cd3cec0176ce12d3e6 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 11:29:53 +0200 Subject: [PATCH 50/93] Factored common code into function in check-shader-stages.hlsl --- .../linalg_builtins/check-shader-stages.hlsl | 207 ++---------------- 1 file changed, 20 insertions(+), 187 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl index 485ff8dad9..e80d27e498 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl @@ -4,15 +4,7 @@ ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; -// CHECK: define void @ps_main() -// CHECK: call <4 x float> @dx.op.matVecMul -// CHECK: call <4 x float> @dx.op.matVecMulAdd -// CHECK: call void @dx.op.outerProductAccumulate -// CHECK: call void @dx.op.vectorAccumulate - -[Shader("pixel")] -void ps_main() -{ +void UseCoopVec() { vector output_vector; static const uint is_output_unsigned = 0; @@ -59,6 +51,18 @@ void ps_main() va_matrix_offset); } +// CHECK: define void @ps_main() +// CHECK: call <4 x float> @dx.op.matVecMul +// CHECK: call <4 x float> @dx.op.matVecMulAdd +// CHECK: call void @dx.op.outerProductAccumulate +// CHECK: call void @dx.op.vectorAccumulate + +[Shader("pixel")] +void ps_main() +{ + UseCoopVec(); +} + // CHECK: define void @cs_main() // CHECK: call <4 x float> @dx.op.matVecMul // CHECK: call <4 x float> @dx.op.matVecMulAdd @@ -69,50 +73,7 @@ void ps_main() [NumThreads(1,1,1)] void cs_main() { - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector; - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride); - - const uint bias_offset = 0; - const uint bias_interpretation = 9; /*F32*/ - - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, - bias_interpretation); - - vector input_vector1; - vector input_vector2; - const uint opa_matrix_offset = 0; - const uint opa_matrix_interpretation = 5; /*U32*/ - const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ - const uint opa_matrix_stride = 64; - - __builtin_OuterProductAccumulate(input_vector1, input_vector2, - rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, - opa_matrix_layout, opa_matrix_stride); - - const uint va_matrix_offset = 0; - - __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, - va_matrix_offset); + UseCoopVec(); } // CHECK: define void @vs_main() @@ -123,51 +84,9 @@ void cs_main() [Shader("vertex")] void vs_main() -{ - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector; - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride); - - const uint bias_offset = 0; - const uint bias_interpretation = 9; /*F32*/ - - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, - bias_interpretation); - - vector input_vector1; - vector input_vector2; - const uint opa_matrix_offset = 0; - const uint opa_matrix_interpretation = 5; /*U32*/ - const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ - const uint opa_matrix_stride = 64; - - __builtin_OuterProductAccumulate(input_vector1, input_vector2, - rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, - opa_matrix_layout, opa_matrix_stride); - - const uint va_matrix_offset = 0; - - __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, - va_matrix_offset); } +{ + UseCoopVec(); +} struct MyRecord{ uint a; @@ -183,50 +102,7 @@ struct MyRecord{ [NodeLaunch("thread")] void ns_main(ThreadNodeInputRecord input) { - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector; - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride); - - const uint bias_offset = 0; - const uint bias_interpretation = 9; /*F32*/ - - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, - bias_interpretation); - - vector input_vector1; - vector input_vector2; - const uint opa_matrix_offset = 0; - const uint opa_matrix_interpretation = 5; /*U32*/ - const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ - const uint opa_matrix_stride = 64; - - __builtin_OuterProductAccumulate(input_vector1, input_vector2, - rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, - opa_matrix_layout, opa_matrix_stride); - - const uint va_matrix_offset = 0; - - __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, - va_matrix_offset); + UseCoopVec(); } // Vertex shader output structure @@ -250,49 +126,6 @@ struct GS_OUT { [maxvertexcount(3)] void gs_main(point VS_OUT input[1], inout TriangleStream OutputStream) -{ - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector; - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride); - - const uint bias_offset = 0; - const uint bias_interpretation = 9; /*F32*/ - - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, - bias_interpretation); - - vector input_vector1; - vector input_vector2; - const uint opa_matrix_offset = 0; - const uint opa_matrix_interpretation = 5; /*U32*/ - const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ - const uint opa_matrix_stride = 64; - - __builtin_OuterProductAccumulate(input_vector1, input_vector2, - rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, - opa_matrix_layout, opa_matrix_stride); - - const uint va_matrix_offset = 0; - - __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, - va_matrix_offset); +{ + UseCoopVec(); } From 6eb36e4f86b6381f17f303157058538ef3d2b005 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 12:04:05 +0200 Subject: [PATCH 51/93] Add test variations for different matVecMul parameter settings --- .../mat-vec-mul_multioverload.hlsl | 75 ++++++++++++++++--- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl index b5ae86594d..ae7bc23dc7 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl @@ -1,31 +1,82 @@ -// RUN: %dxc -T cs_6_9 %s | FileCheck %s +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-0 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 | FileCheck %s --check-prefixes DXIL,DXIL-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 | FileCheck %s --check-prefixes DXIL,DXIL-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-4 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-5 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 | FileCheck %s --check-prefixes DXIL,DXIL-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-7 + +// Test minimum support set of combinations for matVecMul +// DXIL: define void @main() +// DXIL-0: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// DXIL-1: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// DXIL-2: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// DXIL-3: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// DXIL-4: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 305, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) + +// Test unsigned variations +// DXIL-5: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 305, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, i1 true) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// DXIL-6: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// DXIL-7: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) + ByteAddressBuffer input_vector_buffer; ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; -// Test use of __builtin_MatVecMulAdd in compute shader -// CHECK: define void @main() -// CHECK: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 {{[0-9]+}} +enum CompType { + Invalid = 0, + I1 = 1, + I16 = 2, + U16 = 3, + I32 = 4, + U32 = 5, + I64 = 6, + U64 = 7, + F16 = 8, + F32 = 9, + F64 = 10, + SNormF16 = 11, + UNormF16 = 12, + SNormF32 = 13, + UNormF32 = 14, + SNormF64 = 15, + UNormF64 = 16, + PackedS8x32 = 17, + PackedU8x32 = 18, + + // BEGIN NEW FOR SM 6.9 + U8 = 19, + I8 = 20, + F8_E4M3 = 21, + F8_E5M2 = 22, +}; +enum MatLayout { + RowMajor = 0, + ColumnMajor = 1, + MulOptimal = 2, + OuterProductOptimal = 3, +}; [NumThreads(1,1,1)] void main() { - vector output_vector; - static const uint is_output_unsigned = 0; + vector output_vector; + static const uint is_output_unsigned = OU; - vector input_vector = input_vector_buffer.Load >(0); - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ + vector input_vector = input_vector_buffer.Load >(0); + const uint is_input_unsigned = IU; + const uint input_interpretation = II; const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_interpretation = MI; const uint matrix_dimM = 8; const uint matrix_dimK = 8; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; + const uint matrix_layout = ML; + const bool matrix_is_transposed = (bool) MT; const uint matrix_stride = 64; __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, From e310fd62ffac3fc81c224831575e9ca4cded9769 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 14:00:36 +0200 Subject: [PATCH 52/93] Add test with variations for matVecMulAdd --- .../mat-vec-mul-add_multioverload.hlsl | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl new file mode 100644 index 0000000000..c6bb739f71 --- /dev/null +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl @@ -0,0 +1,87 @@ +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes DXIL,DXIL-0 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 -DBI=F16 | FileCheck %s --check-prefixes DXIL,DXIL-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes DXIL,DXIL-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 | FileCheck %s --check-prefixes DXIL,DXIL-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 | FileCheck %s --check-prefixes DXIL,DXIL-4 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes DXIL,DXIL-5 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 -DBI=I8 | FileCheck %s --check-prefixes DXIL,DXIL-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes DXIL,DXIL-7 + +// Test minimum support set of combinations for matVecMul +// DXIL: define void @main() +// DXIL-0: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// DXIL-1: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// DXIL-2: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// DXIL-3: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// DXIL-4: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8f32(i32 306, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) + +// Test unsigned variations +// DXIL-5: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8f32(i32 306, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 true) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// DXIL-6: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// DXIL-7: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) + + +ByteAddressBuffer input_vector_buffer; +ByteAddressBuffer matrix_buffer; +ByteAddressBuffer bias_buffer; +RWByteAddressBuffer rw_matrix_buffer; + +enum CompType { + Invalid = 0, + I1 = 1, + I16 = 2, + U16 = 3, + I32 = 4, + U32 = 5, + I64 = 6, + U64 = 7, + F16 = 8, + F32 = 9, + F64 = 10, + SNormF16 = 11, + UNormF16 = 12, + SNormF32 = 13, + UNormF32 = 14, + SNormF64 = 15, + UNormF64 = 16, + PackedS8x32 = 17, + PackedU8x32 = 18, + + // BEGIN NEW FOR SM 6.9 + U8 = 19, + I8 = 20, + F8_E4M3 = 21, + F8_E5M2 = 22, +}; + +enum MatLayout { + RowMajor = 0, + ColumnMajor = 1, + MulOptimal = 2, + OuterProductOptimal = 3, +}; + +[NumThreads(1,1,1)] +void main() +{ + vector output_vector; + static const uint is_output_unsigned = OU; + + vector input_vector = input_vector_buffer.Load >(0); + const uint is_input_unsigned = IU; + const uint input_interpretation = II; + + const uint matrix_offset = 0; + const uint matrix_interpretation = MI; + const uint matrix_dimM = 8; + const uint matrix_dimK = 8; + const uint matrix_layout = ML; + const bool matrix_is_transposed = (bool) MT; + const uint matrix_stride = 64; + + const uint bias_offset = 0; + const uint bias_interpretation = BI; + + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, + matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); +} From dff8fba0d57fa714ff8325e327a0d3280ffa5c7a Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 14:13:07 +0200 Subject: [PATCH 53/93] Add HLSL -> HL checks for matVecMul --- .../mat-vec-mul_multioverload.hlsl | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl index ae7bc23dc7..aaba6c086c 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl @@ -1,23 +1,41 @@ -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 | FileCheck %s --check-prefixes DXIL,DXIL-1 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-2 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 | FileCheck %s --check-prefixes DXIL,DXIL-3 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-4 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-5 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 | FileCheck %s --check-prefixes DXIL,DXIL-6 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes DXIL,DXIL-7 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-0 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-4 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-5 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-7 + +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-0 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-4 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-5 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-7 + +// COMMON: define void @main() // Test minimum support set of combinations for matVecMul -// DXIL: define void @main() +// HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-0: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64) // DXIL-1: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64) // DXIL-2: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64) // DXIL-3: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-4: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 305, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) // Test unsigned variations +// HLOP-5: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 true, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-5: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 305, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, i1 true) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64) // DXIL-6: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64) // DXIL-7: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) From 8c924bae5b024cead08233fb5a9c799acaa18a89 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 14:23:28 +0200 Subject: [PATCH 54/93] Add HLSL -> HL checks for matVecMulAdd --- .../mat-vec-mul-add_multioverload.hlsl | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl index c6bb739f71..0437b8f8be 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl @@ -1,23 +1,42 @@ -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes DXIL,DXIL-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 -DBI=F16 | FileCheck %s --check-prefixes DXIL,DXIL-1 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes DXIL,DXIL-2 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 | FileCheck %s --check-prefixes DXIL,DXIL-3 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 | FileCheck %s --check-prefixes DXIL,DXIL-4 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes DXIL,DXIL-5 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 -DBI=I8 | FileCheck %s --check-prefixes DXIL,DXIL-6 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes DXIL,DXIL-7 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-0 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 | FileCheck %s --check-prefixes COMMON,DXIL-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 | FileCheck %s --check-prefixes COMMON,DXIL-4 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-5 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-7 + +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-0 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-4 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-5 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-7 + + +// COMMON: define void @main() // Test minimum support set of combinations for matVecMul -// DXIL: define void @main() +// HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-0: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-1: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-2: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) // DXIL-3: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) // DXIL-4: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8f32(i32 306, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) // Test unsigned variations +// HLOP-5: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 true, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) // DXIL-5: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8f32(i32 306, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 true) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) // DXIL-6: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) // DXIL-7: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) From 55d8fc7c5a84022023e98ec46d54f411eb442771 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 14:54:45 +0200 Subject: [PATCH 55/93] update tests to not transpose RowMajor/ColumnMajor --- .../mat-vec-mul-add_multioverload.hlsl | 32 +++++++++---------- .../mat-vec-mul_multioverload.hlsl | 32 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl index 0437b8f8be..47b7cf20c9 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl @@ -1,20 +1,20 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-1 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-2 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 | FileCheck %s --check-prefixes COMMON,DXIL-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 | FileCheck %s --check-prefixes COMMON,DXIL-4 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-5 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-6 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-7 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=1 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-7 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-4 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-5 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-6 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-7 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=0 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=1 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-7 // COMMON: define void @main() @@ -22,10 +22,10 @@ // Test minimum support set of combinations for matVecMul // HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-0: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) -// DXIL-1: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) -// DXIL-2: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) +// DXIL-1: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) +// DXIL-2: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) // HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) // DXIL-3: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) // HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) @@ -34,10 +34,10 @@ // Test unsigned variations // HLOP-5: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 true, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) // DXIL-5: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8f32(i32 306, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 true) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) -// DXIL-6: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) -// DXIL-7: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) +// DXIL-6: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) +// DXIL-7: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) ByteAddressBuffer input_vector_buffer; diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl index aaba6c086c..b39f9bb81f 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl @@ -1,30 +1,30 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-1 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-2 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-4 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-5 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-6 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-7 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-7 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-4 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-5 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-6 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-7 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-6 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-7 // COMMON: define void @main() // Test minimum support set of combinations for matVecMul // HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-0: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64) -// DXIL-1: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64) -// DXIL-2: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 false, i32 64) +// DXIL-1: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64) +// DXIL-2: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) // HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64) // DXIL-3: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) // HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64) @@ -33,10 +33,10 @@ // Test unsigned variations // HLOP-5: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 true, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-5: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 305, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, i1 true) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64) -// DXIL-6: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64) -// DXIL-7: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64) +// DXIL-6: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64) +// DXIL-7: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) ByteAddressBuffer input_vector_buffer; From 5c61273c9de061ac09dc2e08235177d04d1a3bf9 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Apr 2025 15:49:55 +0200 Subject: [PATCH 56/93] Diagnose unsigned<>type mismatches and transpose<>layout mismatch --- lib/DxilValidation/DxilValidation.cpp | 110 ++++++++++++++++++++------ utils/hct/hctdb.py | 10 +++ 2 files changed, 94 insertions(+), 26 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 645a5d4a88..cde7610905 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1006,11 +1006,44 @@ static bool CheckMatrixLayout(unsigned Input) { static_cast(DXIL::DXILMatrixLayout::OuterProductOptimal)); } +static bool CheckTransposeForMatrixLayout(DXIL::DXILMatrixLayout Layout, + bool Transposed) { + switch (Layout) { + case DXIL::DXILMatrixLayout::RowMajor: + case DXIL::DXILMatrixLayout::ColumnMajor: + return !Transposed; + + default: + return true; + } +} + +static bool CheckUnsignedFlag(Type *VecTy, bool IsUnsigned) { + Type *ElemTy = VecTy->getScalarType(); + if (ElemTy->isFloatingPointTy()) + return !IsUnsigned; + + return true; +} + +static Value *getMatVecOpIsOutputUnsigned(CallInst *CI, DXIL::OpCode OpCode) { + switch (OpCode) { + case DXIL::OpCode::MatVecMul: + return CI->getOperand(DXIL::OperandIndex::kMatVecMulIsOutputUnsignedIdx); + case DXIL::OpCode::MatVecMulAdd: + return CI->getOperand(DXIL::OperandIndex::kMatVecMulAddIsOutputUnsignedIdx); + + default: + DXASSERT_NOMSG(false); + return nullptr; + } +} + static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, ValidationContext &ValCtx) { // Check Common operands - llvm::Value *InputIsUnsigned = + llvm::Value *IsInputUnsigned = CI->getOperand(DXIL::OperandIndex::kMatVecMulIsInputUnsignedIdx); llvm::Value *InputInterpretation = CI->getOperand(DXIL::OperandIndex::kMatVecMulInputInterpretationIdx); @@ -1024,76 +1057,101 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixLayoutIdx); llvm::Value *MatrixTranspose = CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixTransposeIdx); + llvm::Value *IsOutputUnsigned = getMatVecOpIsOutputUnsigned(CI, OpCode); - if (!llvm::isa(InputIsUnsigned)) { + ConstantInt *IsInputUnsignedConst = + dyn_cast(IsInputUnsigned); + if (!IsInputUnsignedConst) { ValCtx.EmitInstrError(CI, ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst); + return; } - if (!llvm::isa(InputInterpretation) || - !llvm::isa(MatrixInterpretation)) { + ConstantInt *IsOutputUnsignedConst = + dyn_cast(IsOutputUnsigned); + if (!IsOutputUnsignedConst) { + ValCtx.EmitInstrError(CI, + ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst); + return; + } + + ConstantInt *II = dyn_cast(InputInterpretation); + ConstantInt *MI = dyn_cast(MatrixInterpretation); + if (!II || !MI) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInterpretationParamAreConst); + return; } // Check if InputInterpretation and MatrixInterpretation are valid - ConstantInt *II = cast(InputInterpretation); auto IIValue = II->getLimitedValue(); if (!CheckFromRegisterInterpretations(IIValue)) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInvalidRegisterInterpValue); + return; } - ConstantInt *MI = cast(MatrixInterpretation); auto MIValue = MI->getLimitedValue(); if (!CheckInMemoryInterpretations(MIValue)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); + return; } + ConstantInt *MatrixTransposeConst = dyn_cast(MatrixTranspose); + ConstantInt *MatrixLayoutConst = dyn_cast(MatrixLayout); if (!llvm::isa(MatrixM) || - !llvm::isa(MatrixK) || - !llvm::isa(MatrixLayout) || - !llvm::isa(MatrixTranspose)) { + !llvm::isa(MatrixK) || !MatrixLayoutConst || + !MatrixTransposeConst) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst); + return; } - ConstantInt *ML = cast(MatrixLayout); - auto MLValue = ML->getLimitedValue(); + auto MLValue = MatrixLayoutConst->getLimitedValue(); if (!CheckMatrixLayout(MLValue)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMatrixLayoutValue); + return; } - switch (OpCode) { - case DXIL::OpCode::MatVecMul: { - llvm::Value *OutputIsUnsigned = - CI->getOperand(DXIL::OperandIndex::kMatVecMulIsOutputUnsignedIdx); - if (!llvm::isa(OutputIsUnsigned)) { - ValCtx.EmitInstrError( - CI, ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst); - } + if (!CheckTransposeForMatrixLayout( + static_cast(MLValue), + MatrixTransposeConst->getLimitedValue())) { + ValCtx.EmitInstrError( + CI, ValidationRule::InstrLinalgMatrixLayoutNotTransposable); + return; + } - } break; + llvm::Value *InputVector = + CI->getOperand(DXIL::OperandIndex::kMatVecMulInputVectorIdx); + if (!CheckUnsignedFlag(InputVector->getType(), + IsInputUnsignedConst->getLimitedValue())) { + ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgNotAnUnsignedType); + return; + } + + if (!CheckUnsignedFlag(CI->getType(), + IsOutputUnsignedConst->getLimitedValue())) { + ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgNotAnUnsignedType); + return; + } + + switch (OpCode) { case DXIL::OpCode::MatVecMulAdd: { - llvm::Value *OutputIsUnsigned = - CI->getOperand(DXIL::OperandIndex::kMatVecMulAddIsOutputUnsignedIdx); - if (!llvm::isa(OutputIsUnsigned)) { - ValCtx.EmitInstrError( - CI, ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst); - } llvm::Value *BiasInterpretation = CI->getOperand(DXIL::OperandIndex::kMatVecMulAddBiasInterpretation); if (!llvm::isa(BiasInterpretation)) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInterpretationParamAreConst); + return; } ConstantInt *BI = cast(BiasInterpretation); auto BIValue = BI->getLimitedValue(); if (!CheckInMemoryInterpretations(BIValue)) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); + return; } } break; default: diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index c6a43ba0a3..ed25e8e86b 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -7928,6 +7928,16 @@ def build_valrules(self): "Matrix Layout for Linalg ops not in valid set", ) + self.add_valrule( + "Instr.LinalgMatrixLayoutNotTransposable", + "Matrix Layout not transposable", + ) + + self.add_valrule( + "Instr.LinalgNotAnUnsignedType", + "Unsigned flag set for signed type", + ) + # Some legacy rules: # - space is only supported for shader targets 5.1 and higher # - multiple rules regarding derivatives, which isn't a supported feature for DXIL From 5b190f0adbe03ab6c6ea798cf5b6f828d49f1bd5 Mon Sep 17 00:00:00 2001 From: Tex Riddell Date: Thu, 10 Apr 2025 12:19:18 -0700 Subject: [PATCH 57/93] Fix merge resolution for DXIL 1.9 opcode cap. --- utils/hct/hctdb.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index ed25e8e86b..9b12b0dabe 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -5946,11 +5946,13 @@ def UFI(name, **mappings): ) next_op_idx += 1 - self.set_op_count_for_version(1, 9, next_op_idx) - assert next_op_idx == 309, ( - "309 is expected next operation index but encountered %d and thus opcodes are broken" - % next_op_idx - ) + # End of DXIL 1.9 opcodes. + # NOTE!! Update and uncomment when DXIL 1.9 opcodes are finalized: + # self.set_op_count_for_version(1, 9, next_op_idx) + # assert next_op_idx == NNN, ( + # "NNN is expected next operation index but encountered %d and thus opcodes are broken" + # % next_op_idx + # ) # Set interesting properties. self.build_indices() From b0bcab87e73e123163e23b537a4e5542cdab6397 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 07:59:34 +0200 Subject: [PATCH 58/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index cde7610905..3a40ecb8b3 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1084,7 +1084,7 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, } // Check if InputInterpretation and MatrixInterpretation are valid - auto IIValue = II->getLimitedValue(); + uint64_t IIValue = II->getLimitedValue(); if (!CheckFromRegisterInterpretations(IIValue)) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInvalidRegisterInterpValue); From 61607e754e69bdbc6af8a38e585eaf1f1bbe9cbc Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 07:59:44 +0200 Subject: [PATCH 59/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 3a40ecb8b3..897e8ea445 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1147,7 +1147,7 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, return; } ConstantInt *BI = cast(BiasInterpretation); - auto BIValue = BI->getLimitedValue(); + uint64_t BIValue = BI->getLimitedValue(); if (!CheckInMemoryInterpretations(BIValue)) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); From 78a39c666d529f3b5b2a9fa0905c21dac7712603 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 07:59:53 +0200 Subject: [PATCH 60/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 897e8ea445..4df58ed13f 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1108,7 +1108,7 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, return; } - auto MLValue = MatrixLayoutConst->getLimitedValue(); + uint64_t MLValue = MatrixLayoutConst->getLimitedValue(); if (!CheckMatrixLayout(MLValue)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMatrixLayoutValue); From a54d4d0f16824773bd87385dee07ec4d0615a486 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 08:00:03 +0200 Subject: [PATCH 61/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 4df58ed13f..9e664ecaf5 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1178,10 +1178,9 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); } - if (!llvm::isa(MatrixLayout)) { + if (!llvm::isa(MatrixLayout)) ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst); - } ConstantInt *ML = cast(MatrixLayout); auto MLValue = ML->getLimitedValue(); if (!CheckMatrixLayout(MLValue)) { From 5e72dbf678d4389e68fa659ae1d0e3a3d0482bc7 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 08:00:14 +0200 Subject: [PATCH 62/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 9e664ecaf5..4114b3b31d 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1183,10 +1183,9 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst); ConstantInt *ML = cast(MatrixLayout); auto MLValue = ML->getLimitedValue(); - if (!CheckMatrixLayout(MLValue)) { + if (!CheckMatrixLayout(MLValue)) ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMatrixLayoutValue); - } } // Validate the type-defined mask compared to the store value mask which From 50e0b73e51f2922a366174a001b97878793a7d0b Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 08:00:24 +0200 Subject: [PATCH 63/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 4114b3b31d..7966903493 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1182,7 +1182,7 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst); ConstantInt *ML = cast(MatrixLayout); - auto MLValue = ML->getLimitedValue(); + uint64_t MLValue = ML->getLimitedValue(); if (!CheckMatrixLayout(MLValue)) ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMatrixLayoutValue); From 441c4a47db739c104e19e2c040c861c5e13eddf7 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 08:00:32 +0200 Subject: [PATCH 64/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 7966903493..1be6e4f3d0 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1172,7 +1172,7 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, CI, ValidationRule::InstrLinalgInterpretationParamAreConst); } ConstantInt *MI = cast(MatrixInterpretation); - auto MIValue = MI->getLimitedValue(); + uint64_t MIValue = MI->getLimitedValue(); if (!CheckInMemoryInterpretations(MIValue)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); From 083f258f1f9228f0d10bf4d799f9a252e8787b67 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 08:00:44 +0200 Subject: [PATCH 65/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 1be6e4f3d0..7e85e080b7 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1091,7 +1091,7 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, return; } - auto MIValue = MI->getLimitedValue(); + uint64_t MIValue = MI->getLimitedValue(); if (!CheckInMemoryInterpretations(MIValue)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); From ede7bdb9f1c5184a3cffca3f578848cdd92a037c Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 08:00:57 +0200 Subject: [PATCH 66/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 7e85e080b7..b322f3dc87 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1167,10 +1167,9 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, llvm::Value *MatrixLayout = CI->getOperand(DXIL::OperandIndex::kOuterProdAccMatrixLayout); - if (!llvm::isa(MatrixInterpretation)) { + if (!llvm::isa(MatrixInterpretation)) ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInterpretationParamAreConst); - } ConstantInt *MI = cast(MatrixInterpretation); uint64_t MIValue = MI->getLimitedValue(); if (!CheckInMemoryInterpretations(MIValue)) { From 8675c40ce2678aedc5a99a165c513cd6d8c067cb Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 08:01:09 +0200 Subject: [PATCH 67/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index b322f3dc87..5b377dcfc2 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1172,10 +1172,9 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, CI, ValidationRule::InstrLinalgInterpretationParamAreConst); ConstantInt *MI = cast(MatrixInterpretation); uint64_t MIValue = MI->getLimitedValue(); - if (!CheckInMemoryInterpretations(MIValue)) { + if (!CheckInMemoryInterpretations(MIValue)) ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); - } if (!llvm::isa(MatrixLayout)) ValCtx.EmitInstrError(CI, From 82ee147e7bb7e0262897c1e9b5f645cd7a4d707c Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 08:01:24 +0200 Subject: [PATCH 68/93] Update lib/DxilValidation/DxilValidation.cpp Co-authored-by: Chris B --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 5b377dcfc2..41dc25ab28 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1026,7 +1026,7 @@ static bool CheckUnsignedFlag(Type *VecTy, bool IsUnsigned) { return true; } -static Value *getMatVecOpIsOutputUnsigned(CallInst *CI, DXIL::OpCode OpCode) { +static Value *GetMatVecOpIsOutputUnsigned(CallInst *CI, DXIL::OpCode OpCode) { switch (OpCode) { case DXIL::OpCode::MatVecMul: return CI->getOperand(DXIL::OperandIndex::kMatVecMulIsOutputUnsignedIdx); From 623f7528123ccde458858beda846c98816b776de Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 08:02:28 +0200 Subject: [PATCH 69/93] nfc: fix call after callee name change --- lib/DxilValidation/DxilValidation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 41dc25ab28..05238e9eff 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1057,7 +1057,7 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixLayoutIdx); llvm::Value *MatrixTranspose = CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixTransposeIdx); - llvm::Value *IsOutputUnsigned = getMatVecOpIsOutputUnsigned(CI, OpCode); + llvm::Value *IsOutputUnsigned = GetMatVecOpIsOutputUnsigned(CI, OpCode); ConstantInt *IsInputUnsignedConst = dyn_cast(IsInputUnsigned); From 5d4af661e28048065252a0fb7672df4a2ade0134 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 09:05:36 +0200 Subject: [PATCH 70/93] remove opcode marker --- include/dxc/DXIL/DxilConstants.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index be34eaeb90..d8253dd54b 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -1067,7 +1067,6 @@ enum class OpCode : unsigned { NumOpCodes_Dxil_1_6 = 222, NumOpCodes_Dxil_1_7 = 226, NumOpCodes_Dxil_1_8 = 258, - NumOpCodes_Dxil_1_9 = 309, NumOpCodes = 309 // exclusive last value of enumeration }; @@ -1388,7 +1387,6 @@ enum class OpCodeClass : unsigned { NumOpClasses_Dxil_1_6 = 149, NumOpClasses_Dxil_1_7 = 153, NumOpClasses_Dxil_1_8 = 174, - NumOpClasses_Dxil_1_9 = 183, NumOpClasses = 183 // exclusive last value of enumeration }; From 595162121ad1e9b4a12d450bc817fbf3324489b3 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 09:19:36 +0200 Subject: [PATCH 71/93] nfc: s/\t/ /g + strip trailing wspace --- .../linalg_builtins/check-shader-stages.hlsl | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl index e80d27e498..c72fe0d67c 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl @@ -5,50 +5,50 @@ ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; void UseCoopVec() { - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector; - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride); - - const uint bias_offset = 0; - const uint bias_interpretation = 9; /*F32*/ - - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, - bias_interpretation); - - vector input_vector1; - vector input_vector2; - const uint opa_matrix_offset = 0; - const uint opa_matrix_interpretation = 5; /*U32*/ - const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ - const uint opa_matrix_stride = 64; - - __builtin_OuterProductAccumulate(input_vector1, input_vector2, - rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, - opa_matrix_layout, opa_matrix_stride); - - const uint va_matrix_offset = 0; - - __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, - va_matrix_offset); + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); } // CHECK: define void @ps_main() @@ -59,7 +59,7 @@ void UseCoopVec() { [Shader("pixel")] void ps_main() -{ +{ UseCoopVec(); } @@ -72,8 +72,8 @@ void ps_main() [Shader("compute")] [NumThreads(1,1,1)] void cs_main() -{ - UseCoopVec(); +{ + UseCoopVec(); } // CHECK: define void @vs_main() @@ -85,11 +85,11 @@ void cs_main() [Shader("vertex")] void vs_main() { - UseCoopVec(); + UseCoopVec(); } struct MyRecord{ - uint a; + uint a; }; // CHECK: define void @ns_main() @@ -101,8 +101,8 @@ struct MyRecord{ [Shader("node")] [NodeLaunch("thread")] void ns_main(ThreadNodeInputRecord input) -{ - UseCoopVec(); +{ + UseCoopVec(); } // Vertex shader output structure @@ -125,7 +125,7 @@ struct GS_OUT { [shader("geometry")] [maxvertexcount(3)] void gs_main(point VS_OUT input[1], - inout TriangleStream OutputStream) + inout TriangleStream OutputStream) { UseCoopVec(); } From 70cdd1351cfa6cc3776b5ff23994c942450d4251 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 20:43:33 +0200 Subject: [PATCH 72/93] some more s/\t/ /g --- .../linalg_builtins/linalg-builtins.hlsl | 98 +++++++++---------- .../linalg_builtins/mat-vec-mul-add.hlsl | 38 +++---- .../mat-vec-mul-add_multioverload.hlsl | 38 +++---- .../linalg_builtins/mat-vec-mul.hlsl | 34 +++---- .../mat-vec-mul_multioverload.hlsl | 34 +++---- ...uter-product-accumulate-multioverload.hlsl | 14 +-- .../outer-product-accumulate.hlsl | 14 +-- .../linalg_builtins/vector-accumulate.hlsl | 6 +- .../hlsl/linalg/unavailable-pre-sm69.hlsl | 98 +++++++++---------- 9 files changed, 187 insertions(+), 187 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl index 920540a2c2..4177a0df4f 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl @@ -7,53 +7,53 @@ RWByteAddressBuffer rw_matrix_buffer; [Shader("compute")] [NumThreads(1,1,1)] void cs_main() -{ - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector; - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - - // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride); - - const uint bias_offset = 0; - const uint bias_interpretation = 9; /*F32*/ - - // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, - bias_interpretation); - - vector input_vector1; - vector input_vector2; - const uint opa_matrix_offset = 0; - const uint opa_matrix_interpretation = 5; /*U32*/ - const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ - const uint opa_matrix_stride = 64; - - // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, - __builtin_OuterProductAccumulate(input_vector1, input_vector2, - rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, - opa_matrix_layout, opa_matrix_stride); - - const uint va_matrix_offset = 0; - - // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 366, - __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, - va_matrix_offset); +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 366, + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); } \ No newline at end of file diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl index 6d41421521..dd38fd6040 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl @@ -12,24 +12,24 @@ RWByteAddressBuffer rw_matrix_buffer; [NumThreads(1,1,1)] void main() -{ - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector = input_vector_buffer.Load >(0); - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - const uint bias_offset = 0; - const uint bias_interpretation = 9; /*F32*/ +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector = input_vector_buffer.Load >(0); + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, - matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, + matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl index 47b7cf20c9..a76a92c13a 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl @@ -82,25 +82,25 @@ enum MatLayout { [NumThreads(1,1,1)] void main() -{ - vector output_vector; - static const uint is_output_unsigned = OU; - - vector input_vector = input_vector_buffer.Load >(0); - const uint is_input_unsigned = IU; - const uint input_interpretation = II; - - const uint matrix_offset = 0; - const uint matrix_interpretation = MI; - const uint matrix_dimM = 8; - const uint matrix_dimK = 8; - const uint matrix_layout = ML; - const bool matrix_is_transposed = (bool) MT; - const uint matrix_stride = 64; +{ + vector output_vector; + static const uint is_output_unsigned = OU; + + vector input_vector = input_vector_buffer.Load >(0); + const uint is_input_unsigned = IU; + const uint input_interpretation = II; + + const uint matrix_offset = 0; + const uint matrix_interpretation = MI; + const uint matrix_dimM = 8; + const uint matrix_dimK = 8; + const uint matrix_layout = ML; + const bool matrix_is_transposed = (bool) MT; + const uint matrix_stride = 64; - const uint bias_offset = 0; - const uint bias_interpretation = BI; + const uint bias_offset = 0; + const uint bias_interpretation = BI; - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, - matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, + matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl index c511665224..a193f2eb87 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl @@ -12,22 +12,22 @@ RWByteAddressBuffer rw_matrix_buffer; [NumThreads(1,1,1)] void main() -{ - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector = input_vector_buffer.Load >(0); - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector = input_vector_buffer.Load >(0); + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, - matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, + matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl index b39f9bb81f..adfa86c627 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl @@ -81,22 +81,22 @@ enum MatLayout { [NumThreads(1,1,1)] void main() -{ - vector output_vector; - static const uint is_output_unsigned = OU; - - vector input_vector = input_vector_buffer.Load >(0); - const uint is_input_unsigned = IU; - const uint input_interpretation = II; - - const uint matrix_offset = 0; - const uint matrix_interpretation = MI; - const uint matrix_dimM = 8; - const uint matrix_dimK = 8; - const uint matrix_layout = ML; - const bool matrix_is_transposed = (bool) MT; - const uint matrix_stride = 64; +{ + vector output_vector; + static const uint is_output_unsigned = OU; + + vector input_vector = input_vector_buffer.Load >(0); + const uint is_input_unsigned = IU; + const uint input_interpretation = II; + + const uint matrix_offset = 0; + const uint matrix_interpretation = MI; + const uint matrix_dimM = 8; + const uint matrix_dimK = 8; + const uint matrix_layout = ML; + const bool matrix_is_transposed = (bool) MT; + const uint matrix_stride = 64; - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, - matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, + matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl index 084e598030..d8664a702c 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl @@ -8,14 +8,14 @@ RWByteAddressBuffer matrix_buffer; [Numthreads(1,1,1)] void main() { - vector input_vector1 = 1; - vector input_vector2 = 2; + vector input_vector1 = 1; + vector input_vector2 = 2; - const uint matrix_offset = 0; - const uint matrix_interpretation = 5; /*U32*/ - const uint matrix_layout = 0; - const uint matrix_stride = 64; + const uint matrix_offset = 0; + const uint matrix_interpretation = 5; /*U32*/ + const uint matrix_layout = 0; + const uint matrix_stride = 64; - __builtin_OuterProductAccumulate(input_vector1, input_vector2, matrix_buffer, matrix_offset, matrix_interpretation, matrix_layout, matrix_stride); + __builtin_OuterProductAccumulate(input_vector1, input_vector2, matrix_buffer, matrix_offset, matrix_interpretation, matrix_layout, matrix_stride); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl index b1b9bd7993..3f35edc0d2 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl @@ -8,14 +8,14 @@ RWByteAddressBuffer matrix_buffer; [Numthreads(1,1,1)] void main() { - vector input_vector1 = 1; - vector input_vector2 = 2; + vector input_vector1 = 1; + vector input_vector2 = 2; - const uint matrix_offset = 0; - const uint matrix_interpretation = 5; /*U32*/ - const uint matrix_layout = 0; - const uint matrix_stride = 64; + const uint matrix_offset = 0; + const uint matrix_interpretation = 5; /*U32*/ + const uint matrix_layout = 0; + const uint matrix_stride = 64; - __builtin_OuterProductAccumulate(input_vector1, input_vector2, matrix_buffer, matrix_offset, matrix_interpretation, matrix_layout, matrix_stride); + __builtin_OuterProductAccumulate(input_vector1, input_vector2, matrix_buffer, matrix_offset, matrix_interpretation, matrix_layout, matrix_stride); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/vector-accumulate.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/vector-accumulate.hlsl index 6323e480f9..dc1bb6c563 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/vector-accumulate.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/vector-accumulate.hlsl @@ -9,8 +9,8 @@ RWByteAddressBuffer matrix_buffer; [NumThreads(1,1,1)] void main() { - vector input_vector1 = 5; - const uint matrix_offset = 0; + vector input_vector1 = 5; + const uint matrix_offset = 0; - __builtin_VectorAccumulate(input_vector1, matrix_buffer, matrix_offset); + __builtin_VectorAccumulate(input_vector1, matrix_buffer, matrix_offset); } diff --git a/tools/clang/test/SemaHLSL/hlsl/linalg/unavailable-pre-sm69.hlsl b/tools/clang/test/SemaHLSL/hlsl/linalg/unavailable-pre-sm69.hlsl index f212ed255a..d5e251ae8b 100644 --- a/tools/clang/test/SemaHLSL/hlsl/linalg/unavailable-pre-sm69.hlsl +++ b/tools/clang/test/SemaHLSL/hlsl/linalg/unavailable-pre-sm69.hlsl @@ -7,53 +7,53 @@ RWByteAddressBuffer rw_matrix_buffer; [Shader("compute")] [Numthreads(1,1,1)] void cs_main() -{ - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector; - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - - //expected-error@+1{{intrinsic __builtin_MatVecMul potentially used by 'cs_main' requires shader model 6.9 or greater}} - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride); - - const uint bias_offset = 0; - const uint bias_interpretation = 9; /*F32*/ - - //expected-error@+1{{intrinsic __builtin_MatVecMulAdd potentially used by 'cs_main' requires shader model 6.9 or greater}} - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, - is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, - matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, - matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, - bias_interpretation); - - vector input_vector1; - vector input_vector2; - const uint opa_matrix_offset = 0; - const uint opa_matrix_interpretation = 5; /*U32*/ - const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ - const uint opa_matrix_stride = 64; - - //expected-error@+1{{intrinsic __builtin_OuterProductAccumulate potentially used by 'cs_main' requires shader model 6.9 or greater}} - __builtin_OuterProductAccumulate(input_vector1, input_vector2, - rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, - opa_matrix_layout, opa_matrix_stride); - - const uint va_matrix_offset = 0; - - //expected-error@+1{{intrinsic __builtin_VectorAccumulate potentially used by 'cs_main' requires shader model 6.9 or greater}} - __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, - va_matrix_offset); +{ + vector output_vector; + static const uint is_output_unsigned = 0; + + vector input_vector; + const uint is_input_unsigned = 0; + const uint input_interpretation = 9; /*F32*/ + + const uint matrix_offset = 0; + const uint matrix_interpretation = 9; /*F32*/ + const uint matrix_dimM = 4; + const uint matrix_dimK = 4; + const uint matrix_layout = 0; /*RowMajor*/ + const bool matrix_is_transposed = false; + const uint matrix_stride = 64; + + //expected-error@+1{{intrinsic __builtin_MatVecMul potentially used by 'cs_main' requires shader model 6.9 or greater}} + __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride); + + const uint bias_offset = 0; + const uint bias_interpretation = 9; /*F32*/ + + //expected-error@+1{{intrinsic __builtin_MatVecMulAdd potentially used by 'cs_main' requires shader model 6.9 or greater}} + __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, + is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, + matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, + matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, + bias_interpretation); + + vector input_vector1; + vector input_vector2; + const uint opa_matrix_offset = 0; + const uint opa_matrix_interpretation = 5; /*U32*/ + const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ + const uint opa_matrix_stride = 64; + + //expected-error@+1{{intrinsic __builtin_OuterProductAccumulate potentially used by 'cs_main' requires shader model 6.9 or greater}} + __builtin_OuterProductAccumulate(input_vector1, input_vector2, + rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, + opa_matrix_layout, opa_matrix_stride); + + const uint va_matrix_offset = 0; + + //expected-error@+1{{intrinsic __builtin_VectorAccumulate potentially used by 'cs_main' requires shader model 6.9 or greater}} + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); } \ No newline at end of file From 4d97b84f8b59da9cb9400717aa06abf0997c07b4 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Mon, 14 Apr 2025 21:17:42 +0200 Subject: [PATCH 73/93] Add all params to test --- .../linalg_builtins/linalg-builtins.hlsl | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl index 4177a0df4f..1119d52bd7 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl @@ -23,7 +23,10 @@ void cs_main() const bool matrix_is_transposed = false; const uint matrix_stride = 64; - // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, + // CHECK: %[[MLD0:[^ ]+]] = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A" + // CHECK: %[[MCH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %[[MLD0]]) + // CHECK: %[[MAH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH0]], %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer undef) + // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x float>* %{{[^ ]+}}, i1 false, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH0]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64) __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, @@ -32,7 +35,13 @@ void cs_main() const uint bias_offset = 0; const uint bias_interpretation = 9; /*F32*/ - // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, + // CHECK: %[[MLD1:[^ ]+]] = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A" + // CHECK: %[[MCH1:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %[[MLD1]]) + // CHECK: %[[MAH1:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH1]], %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer undef) + // CHECK-NEXT: %[[BLD1:[^ ]+]] = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A" + // CHECK-NEXT: %[[BCH1:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %[[BLD1]]) + // CHECK-NEXT: %[[BAH1:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %[[BCH1]], %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer undef) + // CHECK-NEXT: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x float>* %{{[^ ]+}}, i1 false, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH1]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %[[BAH1]], i32 0, i32 9) __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, @@ -46,14 +55,20 @@ void cs_main() const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ const uint opa_matrix_stride = 64; - // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, + // CHECK: %[[MLD2:[^ ]+]] = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A" + // CHECK: %[[MCH2:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %[[MLD2]]) + // CHECK: %[[MAH2:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH2]], %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef) + // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, <8 x i32> %{{[^ ]+}}, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %[[MAH2]], i32 0, i32 5, i32 3, i32 64) __builtin_OuterProductAccumulate(input_vector1, input_vector2, rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, opa_matrix_layout, opa_matrix_stride); const uint va_matrix_offset = 0; - // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 366, - __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, - va_matrix_offset); + // CHECK: %[[MLD3:[^ ]+]] = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A" + // CHECK: %[[MCH3:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %[[MLD3]]) + // CHECK: %[[MAH3:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH3]], %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef) + // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 366, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %[[MAH3]], i32 0) + __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, + va_matrix_offset); } \ No newline at end of file From c636e6f72b62b44d890ea6301baf700efe620003 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 09:20:48 +0200 Subject: [PATCH 74/93] Update include/dxc/DXIL/DxilConstants.h Co-authored-by: Tex Riddell --- include/dxc/DXIL/DxilConstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index 046853e3fd..7fa4875070 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -2176,7 +2176,7 @@ extern const char *kHostLayoutTypePrefix; extern const char *kWaveOpsIncludeHelperLanesString; -enum class DXILMatrixLayout : uint32_t { +enum class LinalgMatrixLayout : uint32_t { RowMajor = 0, ColumnMajor = 1, MulOptimal = 2, From 70a83af255ce4c16448f05198162987f13aaf2bd Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 09:22:12 +0200 Subject: [PATCH 75/93] Update utils/hct/hctdb.py Co-authored-by: Tex Riddell --- utils/hct/hctdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index cf05e36472..3a688ca554 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -6351,7 +6351,7 @@ def UFI(name, **mappings): "MatVecMul", "Multiplies a MxK dimension matrix and a K sized input vector", " Date: Tue, 15 Apr 2025 09:23:08 +0200 Subject: [PATCH 76/93] Update utils/hct/hctdb.py Co-authored-by: Tex Riddell --- utils/hct/hctdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 3a688ca554..f35f5558fc 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -6376,7 +6376,7 @@ def UFI(name, **mappings): "MatVecMulAdd", "multiplies a MxK dimension matrix and a K sized input vector and adds an M-sized bias vector", " Date: Tue, 15 Apr 2025 09:25:46 +0200 Subject: [PATCH 77/93] Repair after DXILMatrixLayout -> LinalgMatrixLayout name change --- lib/DxilValidation/DxilValidation.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 328f8510da..81388ad5e2 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -1003,14 +1003,14 @@ static bool CheckInMemoryInterpretations(uint32_t Input) { static bool CheckMatrixLayout(unsigned Input) { return (Input <= - static_cast(DXIL::DXILMatrixLayout::OuterProductOptimal)); + static_cast(DXIL::LinalgMatrixLayout::OuterProductOptimal)); } -static bool CheckTransposeForMatrixLayout(DXIL::DXILMatrixLayout Layout, +static bool CheckTransposeForMatrixLayout(DXIL::LinalgMatrixLayout Layout, bool Transposed) { switch (Layout) { - case DXIL::DXILMatrixLayout::RowMajor: - case DXIL::DXILMatrixLayout::ColumnMajor: + case DXIL::LinalgMatrixLayout::RowMajor: + case DXIL::LinalgMatrixLayout::ColumnMajor: return !Transposed; default: @@ -1116,7 +1116,7 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, } if (!CheckTransposeForMatrixLayout( - static_cast(MLValue), + static_cast(MLValue), MatrixTransposeConst->getLimitedValue())) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgMatrixLayoutNotTransposable); From 797d89c3de288979ee434407417132f06dae1f20 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 09:26:08 +0200 Subject: [PATCH 78/93] Regen after attr change from 'None' -> 'ReadOnly' --- lib/DXIL/DxilOperations.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/DXIL/DxilOperations.cpp b/lib/DXIL/DxilOperations.cpp index 476aa36bdd..95e8dfaeba 100644 --- a/lib/DXIL/DxilOperations.cpp +++ b/lib/DXIL/DxilOperations.cpp @@ -2658,7 +2658,7 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = { "MatVecMul", OCC::MatVecMul, "matVecMul", - Attribute::None, + Attribute::ReadOnly, 2, {{0x400}, {0x400}}, {{0x63}, {0x63}}}, // Overloads: Date: Tue, 15 Apr 2025 09:36:19 +0200 Subject: [PATCH 79/93] nfc: store output vector in tests to keep coopvec dxil ops alive --- .../intrinsics/linalg_builtins/check-shader-stages.hlsl | 6 +++++- .../hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl | 6 +++++- .../hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl | 3 +++ .../linalg_builtins/mat-vec-mul-add_multioverload.hlsl | 2 ++ .../hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl | 4 +++- .../linalg_builtins/mat-vec-mul_multioverload.hlsl | 2 ++ 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl index c72fe0d67c..74cb51260c 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/check-shader-stages.hlsl @@ -3,12 +3,14 @@ ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; +ByteAddressBuffer input_vector_buffer; +RWByteAddressBuffer output_vector_buffer; void UseCoopVec() { vector output_vector; static const uint is_output_unsigned = 0; - vector input_vector; + vector input_vector = input_vector_buffer.Load >(0); const uint is_input_unsigned = 0; const uint input_interpretation = 9; /*F32*/ @@ -24,6 +26,7 @@ void UseCoopVec() { is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); + output_vector_buffer.Store(0, output_vector); const uint bias_offset = 0; const uint bias_interpretation = 9; /*F32*/ @@ -33,6 +36,7 @@ void UseCoopVec() { matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); + output_vector_buffer.Store(1024, output_vector); vector input_vector1; vector input_vector2; diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl index 1119d52bd7..bddd2be005 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl @@ -1,8 +1,10 @@ // RUN: %dxc -fcgl -T cs_6_9 -E cs_main %s | FileCheck %s +ByteAddressBuffer input_vector_buffer; ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; +RWByteAddressBuffer output_vector_buffer; [Shader("compute")] [NumThreads(1,1,1)] @@ -11,7 +13,7 @@ void cs_main() vector output_vector; static const uint is_output_unsigned = 0; - vector input_vector; + vector input_vector = input_vector_buffer.Load >(0); const uint is_input_unsigned = 0; const uint input_interpretation = 9; /*F32*/ @@ -31,6 +33,7 @@ void cs_main() is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); + output_vector_buffer.Store(0, output_vector); const uint bias_offset = 0; const uint bias_interpretation = 9; /*F32*/ @@ -47,6 +50,7 @@ void cs_main() matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); + output_vector_buffer.Store(1024, output_vector); vector input_vector1; vector input_vector2; diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl index dd38fd6040..daaf78ba5e 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl @@ -4,6 +4,7 @@ ByteAddressBuffer input_vector_buffer; ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; +RWByteAddressBuffer output_vector_buffer; // Test use of __builtin_MatVecMulAdd in compute shader // CHECK: define void @main() @@ -32,4 +33,6 @@ void main() __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); + + output_vector_buffer.Store(0, output_vector); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl index a76a92c13a..672b0552ed 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl @@ -44,6 +44,7 @@ ByteAddressBuffer input_vector_buffer; ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; +RWByteAddressBuffer output_vector_buffer; enum CompType { Invalid = 0, @@ -103,4 +104,5 @@ void main() __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); + output_vector_buffer.Store(0, output_vector); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl index a193f2eb87..df9abe46af 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl @@ -3,7 +3,7 @@ ByteAddressBuffer input_vector_buffer; ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; -RWByteAddressBuffer rw_matrix_buffer; +RWByteAddressBuffer output_vector_buffer; // Test use of __builtin_MatVecMulAdd in compute shader // CHECK: define void @main() @@ -30,4 +30,6 @@ void main() __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); + + output_vector_buffer.Store(0, output_vector); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl index adfa86c627..7a1013e931 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl @@ -43,6 +43,7 @@ ByteAddressBuffer input_vector_buffer; ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; +RWByteAddressBuffer output_vector_buffer; enum CompType { Invalid = 0, @@ -99,4 +100,5 @@ void main() __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); + output_vector_buffer.Store(0, output_vector); } From 47c4f3fdc7fa947ff25e4f9e9efc59dcdbd9dcd4 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 09:46:24 +0200 Subject: [PATCH 80/93] Remove redundant tests (subsumed by multioverload versions) --- .../linalg_builtins/mat-vec-mul-add.hlsl | 38 ------------------- .../linalg_builtins/mat-vec-mul.hlsl | 35 ----------------- 2 files changed, 73 deletions(-) delete mode 100644 tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl delete mode 100644 tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl deleted file mode 100644 index daaf78ba5e..0000000000 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add.hlsl +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %dxc -T cs_6_9 %s | FileCheck %s - -ByteAddressBuffer input_vector_buffer; -ByteAddressBuffer matrix_buffer; -ByteAddressBuffer bias_buffer; -RWByteAddressBuffer rw_matrix_buffer; -RWByteAddressBuffer output_vector_buffer; - -// Test use of __builtin_MatVecMulAdd in compute shader -// CHECK: define void @main() -// CHECK: call <4 x float> @dx.op.matVecMulAdd.v4f32.v4f32(i32 {{[0-9]+}}, <4 x float> {{%[0-9]+}}, i1 false, i32 9, %dx.types.Handle {{%[0-9]+}}, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle {{%[0-9]+}}, i32 0, i32 9, i1 false) - - -[NumThreads(1,1,1)] -void main() -{ - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector = input_vector_buffer.Load >(0); - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - const uint bias_offset = 0; - const uint bias_interpretation = 9; /*F32*/ - - __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, - matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride, bias_buffer, bias_offset, bias_interpretation); - - output_vector_buffer.Store(0, output_vector); -} diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl deleted file mode 100644 index df9abe46af..0000000000 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul.hlsl +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: %dxc -T cs_6_9 %s | FileCheck %s - -ByteAddressBuffer input_vector_buffer; -ByteAddressBuffer matrix_buffer; -ByteAddressBuffer bias_buffer; -RWByteAddressBuffer output_vector_buffer; - -// Test use of __builtin_MatVecMulAdd in compute shader -// CHECK: define void @main() -// CHECK: call <4 x float> @dx.op.matVecMul.v4f32.v4f32(i32 {{[0-9]+}}, <4 x float> {{%[0-9]+}}, i1 false, i32 9, %dx.types.Handle {{%[0-9]+}}, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, i1 false) - - -[NumThreads(1,1,1)] -void main() -{ - vector output_vector; - static const uint is_output_unsigned = 0; - - vector input_vector = input_vector_buffer.Load >(0); - const uint is_input_unsigned = 0; - const uint input_interpretation = 9; /*F32*/ - - const uint matrix_offset = 0; - const uint matrix_interpretation = 9; /*F32*/ - const uint matrix_dimM = 4; - const uint matrix_dimK = 4; - const uint matrix_layout = 0; /*RowMajor*/ - const bool matrix_is_transposed = false; - const uint matrix_stride = 64; - - __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, - matrix_dimM, matrix_dimK, matrix_layout, matrix_is_transposed, matrix_stride); - - output_vector_buffer.Store(0, output_vector); -} From cc6cc270f8f4b2de4e03d80ef8b8dd38f379e5e1 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 09:47:02 +0200 Subject: [PATCH 81/93] CheckLinalgInterpretation for InMemory and InRegister type validation --- lib/DxilValidation/DxilValidation.cpp | 59 ++++++++++++--------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index 81388ad5e2..a1426f8756 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -970,40 +970,31 @@ static void ValidateImmOperandForMathDxilOp(CallInst *CI, DXIL::OpCode Opcode, } } -static bool CheckFromRegisterInterpretations(uint32_t Input) { - DXIL::ComponentType ValidSet[] = { - DXIL::ComponentType::I16, DXIL::ComponentType::U16, - DXIL::ComponentType::I32, DXIL::ComponentType::U32, - DXIL::ComponentType::F16, DXIL::ComponentType::F32, - DXIL::ComponentType::PackedS8x32, DXIL::ComponentType::PackedU8x32, - DXIL::ComponentType::U8, DXIL::ComponentType::I8, - DXIL::ComponentType::F8_E4M3, DXIL::ComponentType::F8_E5M2}; - - for (auto Val : ValidSet) { - if (Val == static_cast(Input)) - return true; - } - return false; -} - -static bool CheckInMemoryInterpretations(uint32_t Input) { - DXIL::ComponentType ValidSet[] = { - DXIL::ComponentType::I16, DXIL::ComponentType::U16, - DXIL::ComponentType::I32, DXIL::ComponentType::U32, - DXIL::ComponentType::F16, DXIL::ComponentType::F32, - DXIL::ComponentType::U8, DXIL::ComponentType::I8, - DXIL::ComponentType::F8_E4M3, DXIL::ComponentType::F8_E5M2}; - - for (auto Val : ValidSet) { - if (Val == static_cast(Input)) - return true; +static bool CheckLinalgInterpretation(uint32_t Input, bool InRegister) { + using CT = DXIL::ComponentType; + switch (static_cast(Input)) { + case CT::I16: + case CT::U16: + case CT::I32: + case CT::U32: + case CT::F16: + case CT::F32: + case CT::U8: + case CT::I8: + case CT::F8_E4M3: + case CT::F8_E5M2: + return true; + case CT::PackedS8x32: + case CT::PackedU8x32: + return InRegister; + default: + return false; } - return false; } static bool CheckMatrixLayout(unsigned Input) { - return (Input <= - static_cast(DXIL::LinalgMatrixLayout::OuterProductOptimal)); + return Input <= + static_cast(DXIL::LinalgMatrixLayout::OuterProductOptimal); } static bool CheckTransposeForMatrixLayout(DXIL::LinalgMatrixLayout Layout, @@ -1085,14 +1076,14 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, // Check if InputInterpretation and MatrixInterpretation are valid uint64_t IIValue = II->getLimitedValue(); - if (!CheckFromRegisterInterpretations(IIValue)) { + if (!CheckLinalgInterpretation(IIValue, true)) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInvalidRegisterInterpValue); return; } uint64_t MIValue = MI->getLimitedValue(); - if (!CheckInMemoryInterpretations(MIValue)) { + if (!CheckLinalgInterpretation(MIValue, false)) { ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); return; @@ -1148,7 +1139,7 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, } ConstantInt *BI = cast(BiasInterpretation); uint64_t BIValue = BI->getLimitedValue(); - if (!CheckInMemoryInterpretations(BIValue)) { + if (!CheckLinalgInterpretation(BIValue, false)) { ValCtx.EmitInstrError( CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); return; @@ -1172,7 +1163,7 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, CI, ValidationRule::InstrLinalgInterpretationParamAreConst); ConstantInt *MI = cast(MatrixInterpretation); uint64_t MIValue = MI->getLimitedValue(); - if (!CheckInMemoryInterpretations(MIValue)) + if (!CheckLinalgInterpretation(MIValue, false)) ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); From d344e73176129ecce6f7d45493ce9e0a5f33a105 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 09:54:16 +0200 Subject: [PATCH 82/93] Align test with spec: "Note: Only Optimal layouts can be used with for Float8(E4M3 and E5M2) MatrixInterpretation." --- .../linalg_builtins/mat-vec-mul-add_multioverload.hlsl | 8 ++++---- .../linalg_builtins/mat-vec-mul_multioverload.hlsl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl index 672b0552ed..669feb5514 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl @@ -1,5 +1,5 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=MulOptimal -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-1 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-2 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 | FileCheck %s --check-prefixes COMMON,DXIL-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 | FileCheck %s --check-prefixes COMMON,DXIL-4 @@ -8,7 +8,7 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=1 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-7 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=MulOptimal -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-4 @@ -22,8 +22,8 @@ // Test minimum support set of combinations for matVecMul // HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-0: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) -// DXIL-1: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) +// DXIL-1: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) // HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-2: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) // HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl index 7a1013e931..2bd7db223f 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl @@ -1,5 +1,5 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-1 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-2 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-4 @@ -8,7 +8,7 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=U8 -DMI=U8 -DML=MulOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-7 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-0 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=ColumnMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=MulOptimal -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-4 @@ -21,8 +21,8 @@ // Test minimum support set of combinations for matVecMul // HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-0: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 false, i32 64) -// DXIL-1: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 1, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64) +// DXIL-1: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) // HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64) // DXIL-2: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) // HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64) From faa8f8fa80ddfcd6cb7b453c77f298f04a5fbf53 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 10:12:38 +0200 Subject: [PATCH 83/93] Align test with spec: "Packed" type conversions are bitcasts to a smaller type. The declared input type must be 32-bit unsigned integer. --- .../linalg_builtins/mat-vec-mul-add_multioverload.hlsl | 8 ++++---- .../linalg_builtins/mat-vec-mul_multioverload.hlsl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl index 669feb5514..1e5c3ca3eb 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl @@ -1,7 +1,7 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-0 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=MulOptimal -DMT=0 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-1 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 -DBI=F16 | FileCheck %s --check-prefixes COMMON,DXIL-2 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 | FileCheck %s --check-prefixes COMMON,DXIL-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=uint -DII=PackedS8x32 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 | FileCheck %s --check-prefixes COMMON,DXIL-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 | FileCheck %s --check-prefixes COMMON,DXIL-4 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-5 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=0 -DBI=I8 | FileCheck %s --check-prefixes COMMON,DXIL-6 @@ -10,7 +10,7 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-0 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=MulOptimal -DMT=0 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 -DBI=F16 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=uint -DII=PackedS8x32 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -DBI=I32 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -DBI=I32 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-4 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-5 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=0 -DBI=I8 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-6 @@ -26,8 +26,8 @@ // DXIL-1: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) // HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-2: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) -// DXIL-3: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) +// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 17, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) +// DXIL-3: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 17, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) // HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) // DXIL-4: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8f32(i32 306, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl index 2bd7db223f..fb6d4093b4 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl @@ -1,7 +1,7 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-0 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=MulOptimal -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-1 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-2 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=uint -DII=PackedS8x32 -DMI=I8 -DML=OuterProductOptimal -DMT=1 | FileCheck %s --check-prefixes COMMON,DXIL-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-4 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-5 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=0 | FileCheck %s --check-prefixes COMMON,DXIL-6 @@ -10,7 +10,7 @@ // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F16 -DMI=F16 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-0 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E4M3 -DMI=F8_E4M3 -DML=MulOptimal -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=float16_t -DIU=0 -DITY=float16_t -DII=F8_E5M2 -DMI=F8_E5M2 -DML=MulOptimal -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 -// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=int -DII=I8 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=uint -DII=PackedS8x32 -DMI=I8 -DML=OuterProductOptimal -DMT=1 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-3 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=0 -DITY=float -DII=I8 -DMI=I8 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-4 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=1 -DOTY=uint -DIU=0 -DITY=float -DII=I8 -DMI=F16 -DML=RowMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-5 // RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DOU=0 -DOTY=int -DIU=1 -DITY=uint -DII=U8 -DMI=I8 -DML=ColumnMajor -DMT=0 -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-6 @@ -25,8 +25,8 @@ // DXIL-1: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) // HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64) // DXIL-2: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64) -// DXIL-3: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) +// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 17, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64) +// DXIL-3: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 17, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) // HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-4: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 305, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) From 41217f33b9f9b09be5e3ffb3ad67863449934ccd Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 10:46:13 +0200 Subject: [PATCH 84/93] Fix DXIL OuterProductAccmulate param ordering (minterp, mlayout, mstride) --- include/dxc/DXIL/DxilInstructions.h | 36 +++++++++++++++++++++-------- utils/hct/hctdb.py | 6 ++--- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/include/dxc/DXIL/DxilInstructions.h b/include/dxc/DXIL/DxilInstructions.h index ded084223f..9a4030fd8e 100644 --- a/include/dxc/DXIL/DxilInstructions.h +++ b/include/dxc/DXIL/DxilInstructions.h @@ -10075,9 +10075,9 @@ struct DxilInst_OuterProductAccumulate { arg_inputVector2 = 2, arg_matrixBuffer = 3, arg_matrixOffset = 4, - arg_matrixStride = 5, - arg_matrixIntepretation = 6, - arg_matrixLayout = 7, + arg_matrixIntepretation = 5, + arg_matrixLayout = 6, + arg_matrixStride = 7, }; // Accessors llvm::Value *get_inputVector1() const { return Instr->getOperand(1); } @@ -10088,12 +10088,30 @@ struct DxilInst_OuterProductAccumulate { void set_matrixBuffer(llvm::Value *val) { Instr->setOperand(3, val); } llvm::Value *get_matrixOffset() const { return Instr->getOperand(4); } void set_matrixOffset(llvm::Value *val) { Instr->setOperand(4, val); } - llvm::Value *get_matrixStride() const { return Instr->getOperand(5); } - void set_matrixStride(llvm::Value *val) { Instr->setOperand(5, val); } - llvm::Value *get_matrixIntepretation() const { return Instr->getOperand(6); } - void set_matrixIntepretation(llvm::Value *val) { Instr->setOperand(6, val); } - llvm::Value *get_matrixLayout() const { return Instr->getOperand(7); } - void set_matrixLayout(llvm::Value *val) { Instr->setOperand(7, val); } + llvm::Value *get_matrixIntepretation() const { return Instr->getOperand(5); } + void set_matrixIntepretation(llvm::Value *val) { Instr->setOperand(5, val); } + int32_t get_matrixIntepretation_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(5)) + ->getZExtValue()); + } + void set_matrixIntepretation_val(int32_t val) { + Instr->setOperand(5, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } + llvm::Value *get_matrixLayout() const { return Instr->getOperand(6); } + void set_matrixLayout(llvm::Value *val) { Instr->setOperand(6, val); } + int32_t get_matrixLayout_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(6)) + ->getZExtValue()); + } + void set_matrixLayout_val(int32_t val) { + Instr->setOperand(6, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } + llvm::Value *get_matrixStride() const { return Instr->getOperand(7); } + void set_matrixStride(llvm::Value *val) { Instr->setOperand(7, val); } }; /// This instruction Accumulates the components of a vector component-wise diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index f35f5558fc..3f3b94816d 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -6413,9 +6413,9 @@ def UFI(name, **mappings): db_dxil_param(3, "$x1", "inputVector2", "input vector 2"), db_dxil_param(4, "res", "matrixBuffer", "matrix resource"), db_dxil_param(5, "i32", "matrixOffset", "matrix offset"), - db_dxil_param(6, "i32", "matrixStride", "matrix stride"), - db_dxil_param(7, "i32", "matrixIntepretation", "matrix intepretation"), - db_dxil_param(8, "i32", "matrixLayout", "matrix layout"), + db_dxil_param(6, "i32", "matrixIntepretation", "matrix intepretation", is_const=True), + db_dxil_param(7, "i32", "matrixLayout", "matrix layout", is_const=True), + db_dxil_param(8, "i32", "matrixStride", "matrix stride"), ], ) next_op_idx += 1 From 1b23b26684c1629cc80c89a9180af98548777241 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 10:51:49 +0200 Subject: [PATCH 85/93] Multioverload OuterProductAccmuluate test (and remove redundant non-overload test) --- ...uter-product-accumulate-multioverload.hlsl | 63 ++++++++++++++++--- .../outer-product-accumulate.hlsl | 21 ------- 2 files changed, 56 insertions(+), 28 deletions(-) delete mode 100644 tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl index d8664a702c..53907676c1 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl @@ -1,19 +1,68 @@ -// RUN: %dxc -T cs_6_9 %s | FileCheck %s +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DITY=float16_t -DMI=F16 -DML=RowMajor | FileCheck %s --check-prefixes COMMON,DXIL-0 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DITY=float16_t -DMI=F8_E4M3 -DML=OuterProductOptimal | FileCheck %s --check-prefixes COMMON,DXIL-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DITY=uint -DMI=U8 -DML=OuterProductOptimal | FileCheck %s --check-prefixes COMMON,DXIL-2 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DITY=float16_t -DMI=F16 -DML=RowMajor -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-0 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DITY=float16_t -DMI=F8_E4M3 -DML=OuterProductOptimal -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-1 +// RUN: %dxc -T cs_6_9 %s -enable-16bit-types -DITY=uint -DMI=U8 -DML=OuterProductOptimal -fcgl | FileCheck %s --check-prefixes COMMON,HLOP-2 + +ByteAddressBuffer input_vector_buffer; +ByteAddressBuffer input_vector_buffer2; RWByteAddressBuffer matrix_buffer; -// CHECK: define void @main() -// CHECK: call void @dx.op.outerProductAccumulate.v2i32.v4i32(i32 {{[0-9]+}} +// COMMON: define void @main() +// DXIL-0: call void @dx.op.outerProductAccumulate.v8f16.v8f16(i32 307, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 0, i32 64) ; OuterProductAccumulate(inputVector1,inputVector2,matrixBuffer,matrixOffset,matrixIntepretation,matrixLayout,matrixStride) +// HLOP-0: call void @"dx.hl.op..void (i32, <8 x half>, <8 x half>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 0, i32 64) +// DXIL-1: call void @dx.op.outerProductAccumulate.v8f16.v8f16(i32 307, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 3, i32 64) ; OuterProductAccumulate(inputVector1,inputVector2,matrixBuffer,matrixOffset,matrixIntepretation,matrixLayout,matrixStride) +// HLOP-1: call void @"dx.hl.op..void (i32, <8 x half>, <8 x half>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 3, i32 64) +// DXIL-2: call void @dx.op.outerProductAccumulate.v8i32.v8i32(i32 307, <8 x i32> %{{[^ ]+}}, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 3, i32 64) ; OuterProductAccumulate(inputVector1,inputVector2,matrixBuffer,matrixOffset,matrixIntepretation,matrixLayout,matrixStride) +// HLOP-2: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, <8 x i32> %{{[^ ]+}}, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 3, i32 64) + +enum CompType { + Invalid = 0, + I1 = 1, + I16 = 2, + U16 = 3, + I32 = 4, + U32 = 5, + I64 = 6, + U64 = 7, + F16 = 8, + F32 = 9, + F64 = 10, + SNormF16 = 11, + UNormF16 = 12, + SNormF32 = 13, + UNormF32 = 14, + SNormF64 = 15, + UNormF64 = 16, + PackedS8x32 = 17, + PackedU8x32 = 18, + + // BEGIN NEW FOR SM 6.9 + U8 = 19, + I8 = 20, + F8_E4M3 = 21, + F8_E5M2 = 22, +}; + +enum MatLayout { + RowMajor = 0, + ColumnMajor = 1, + MulOptimal = 2, + OuterProductOptimal = 3, +}; + [Numthreads(1,1,1)] void main() { - vector input_vector1 = 1; - vector input_vector2 = 2; + vector input_vector1 = input_vector_buffer.Load >(0); + vector input_vector2 = input_vector_buffer2.Load >(0); + const uint matrix_interpretation = MI; + const uint matrix_layout = ML; const uint matrix_offset = 0; - const uint matrix_interpretation = 5; /*U32*/ - const uint matrix_layout = 0; const uint matrix_stride = 64; __builtin_OuterProductAccumulate(input_vector1, input_vector2, matrix_buffer, matrix_offset, matrix_interpretation, matrix_layout, matrix_stride); diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl deleted file mode 100644 index 3f35edc0d2..0000000000 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate.hlsl +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %dxc -T cs_6_9 %s | FileCheck %s - -RWByteAddressBuffer matrix_buffer; - -// CHECK: define void @main() -// CHECK: call void @dx.op.outerProductAccumulate.v2i32.v2i32(i32 {{[0-9]+}}, <2 x i32> , <2 x i32> , %dx.types.Handle {{%[0-9]+}}, i32 0, i32 5, i32 0, i32 64) - -[Numthreads(1,1,1)] -void main() -{ - vector input_vector1 = 1; - vector input_vector2 = 2; - - const uint matrix_offset = 0; - const uint matrix_interpretation = 5; /*U32*/ - const uint matrix_layout = 0; - const uint matrix_stride = 64; - - __builtin_OuterProductAccumulate(input_vector1, input_vector2, matrix_buffer, matrix_offset, matrix_interpretation, matrix_layout, matrix_stride); - -} From a3f76ef7a059b46766fa7ba0dfb06e38f316e1b0 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Tue, 15 Apr 2025 11:07:27 +0200 Subject: [PATCH 86/93] nfc: autoformat --- lib/DxilValidation/DxilValidation.cpp | 2 +- utils/hct/hctdb.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index a1426f8756..a9deb66c4e 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -994,7 +994,7 @@ static bool CheckLinalgInterpretation(uint32_t Input, bool InRegister) { static bool CheckMatrixLayout(unsigned Input) { return Input <= - static_cast(DXIL::LinalgMatrixLayout::OuterProductOptimal); + static_cast(DXIL::LinalgMatrixLayout::OuterProductOptimal); } static bool CheckTransposeForMatrixLayout(DXIL::LinalgMatrixLayout Layout, diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 3f3b94816d..d924431aef 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -6413,7 +6413,13 @@ def UFI(name, **mappings): db_dxil_param(3, "$x1", "inputVector2", "input vector 2"), db_dxil_param(4, "res", "matrixBuffer", "matrix resource"), db_dxil_param(5, "i32", "matrixOffset", "matrix offset"), - db_dxil_param(6, "i32", "matrixIntepretation", "matrix intepretation", is_const=True), + db_dxil_param( + 6, + "i32", + "matrixIntepretation", + "matrix intepretation", + is_const=True, + ), db_dxil_param(7, "i32", "matrixLayout", "matrix layout", is_const=True), db_dxil_param(8, "i32", "matrixStride", "matrix stride"), ], From 791dff3de0805e6b5fa61374ea3f1ff73126a02e Mon Sep 17 00:00:00 2001 From: Tex Riddell Date: Tue, 15 Apr 2025 20:32:20 -0700 Subject: [PATCH 87/93] Update tests with new hl opcodes --- .../linalg_builtins/linalg-builtins.hlsl | 8 ++++---- .../mat-vec-mul-add_multioverload.hlsl | 16 ++++++++-------- .../mat-vec-mul_multioverload.hlsl | 16 ++++++++-------- .../outer-product-accumulate-multioverload.hlsl | 6 +++--- .../test/DXC/Passes/DxilGen/linalg-builtins.ll | 8 ++++---- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl index bddd2be005..5e98e563f7 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl @@ -28,7 +28,7 @@ void cs_main() // CHECK: %[[MLD0:[^ ]+]] = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A" // CHECK: %[[MCH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %[[MLD0]]) // CHECK: %[[MAH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH0]], %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer undef) - // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x float>* %{{[^ ]+}}, i1 false, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH0]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64) + // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x float>* %{{[^ ]+}}, i1 false, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH0]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64) __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, @@ -44,7 +44,7 @@ void cs_main() // CHECK-NEXT: %[[BLD1:[^ ]+]] = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A" // CHECK-NEXT: %[[BCH1:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %[[BLD1]]) // CHECK-NEXT: %[[BAH1:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %[[BCH1]], %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer undef) - // CHECK-NEXT: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x float>* %{{[^ ]+}}, i1 false, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH1]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %[[BAH1]], i32 0, i32 9) + // CHECK-NEXT: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x float>* %{{[^ ]+}}, i1 false, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH1]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %[[BAH1]], i32 0, i32 9) __builtin_MatVecMulAdd(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, matrix_interpretation, matrix_dimM, matrix_dimK, matrix_layout, @@ -62,7 +62,7 @@ void cs_main() // CHECK: %[[MLD2:[^ ]+]] = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A" // CHECK: %[[MCH2:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %[[MLD2]]) // CHECK: %[[MAH2:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH2]], %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef) - // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, <8 x i32> %{{[^ ]+}}, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %[[MAH2]], i32 0, i32 5, i32 3, i32 64) + // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 392, <8 x i32> %{{[^ ]+}}, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %[[MAH2]], i32 0, i32 5, i32 3, i32 64) __builtin_OuterProductAccumulate(input_vector1, input_vector2, rw_matrix_buffer, opa_matrix_offset, opa_matrix_interpretation, opa_matrix_layout, opa_matrix_stride); @@ -72,7 +72,7 @@ void cs_main() // CHECK: %[[MLD3:[^ ]+]] = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A" // CHECK: %[[MCH3:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %[[MLD3]]) // CHECK: %[[MAH3:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH3]], %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef) - // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 366, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %[[MAH3]], i32 0) + // CHECK: call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 393, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %[[MAH3]], i32 0) __builtin_VectorAccumulate(input_vector1, rw_matrix_buffer, va_matrix_offset); } \ No newline at end of file diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl index 1e5c3ca3eb..98a568fa22 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul-add_multioverload.hlsl @@ -20,23 +20,23 @@ // COMMON: define void @main() // Test minimum support set of combinations for matVecMul -// HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) +// HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-0: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) +// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-1: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) +// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8) // DXIL-2: call <4 x half> @dx.op.matVecMulAdd.v4f16.v8f16(i32 306, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 17, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) +// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 17, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) // DXIL-3: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 17, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) +// HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 4) // DXIL-4: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8f32(i32 306, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 4, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) // Test unsigned variations -// HLOP-5: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 true, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) +// HLOP-5: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x i32>* %output_vector, i1 true, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) // DXIL-5: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8f32(i32 306, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 true) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) +// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) // DXIL-6: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) -// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) +// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20) // DXIL-7: call <4 x i32> @dx.op.matVecMulAdd.v4i32.v8i32(i32 306, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i1 false) ; MatVecMulAdd(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,biasBuffer,biasOffset,biasIntepretation,isOutputUnsigned) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl index fb6d4093b4..2ca2648503 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/mat-vec-mul_multioverload.hlsl @@ -19,23 +19,23 @@ // COMMON: define void @main() // Test minimum support set of combinations for matVecMul -// HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64) +// HLOP-0: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 8, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-0: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 8, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64) +// HLOP-1: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 21, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64) // DXIL-1: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 21, %dx.types.Handle {{[^ ]+}}, i32 0, i32 21, i32 8, i32 8, i32 2, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64) +// HLOP-2: call void @"dx.hl.op..void (i32, <4 x half>*, i1, <8 x half>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x half>* %output_vector, i1 false, <8 x half> %{{[^ ]+}}, i1 false, i32 22, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64) // DXIL-2: call <4 x half> @dx.op.matVecMul.v4f16.v8f16(i32 305, <8 x half> {{[^ ]+}}, i1 false, i32 22, %dx.types.Handle {{[^ ]+}}, i32 0, i32 22, i32 8, i32 8, i32 2, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 17, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64) +// HLOP-3: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 17, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64) // DXIL-3: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 17, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 3, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64) +// HLOP-4: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x i32>* %output_vector, i1 false, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-4: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 305, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 0, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) // Test unsigned variations -// HLOP-5: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 true, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64) +// HLOP-5: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x i32>* %output_vector, i1 true, <8 x float> %{{[^ ]+}}, i1 false, i32 20, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64) // DXIL-5: call <4 x i32> @dx.op.matVecMul.v4i32.v8f32(i32 305, <8 x float> {{[^ ]+}}, i1 false, i32 20, %dx.types.Handle {{[^ ]+}}, i32 0, i32 8, i32 8, i32 8, i32 0, i1 false, i32 64, i1 true) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64) +// HLOP-6: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 true, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64) // DXIL-6: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 true, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 20, i32 8, i32 8, i32 1, i1 false, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) -// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64) +// HLOP-7: call void @"dx.hl.op..void (i32, <4 x i32>*, i1, <8 x i32>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x i32>* %output_vector, i1 false, <8 x i32> %{{[^ ]+}}, i1 false, i32 19, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64) // DXIL-7: call <4 x i32> @dx.op.matVecMul.v4i32.v8i32(i32 305, <8 x i32> {{[^ ]+}}, i1 false, i32 19, %dx.types.Handle {{[^ ]+}}, i32 0, i32 19, i32 8, i32 8, i32 2, i1 true, i32 64, i1 false) ; MatVecMul(inputVector,isInputUnsigned,inputInterpretation,matrixBuffer,matrixOffset,matrixIntepretation,matrixM,matrixK,matrixLayout,matrixTranspose,matrixStride,isOutputUnsigned) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl index 53907676c1..40bbe62284 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/outer-product-accumulate-multioverload.hlsl @@ -12,11 +12,11 @@ RWByteAddressBuffer matrix_buffer; // COMMON: define void @main() // DXIL-0: call void @dx.op.outerProductAccumulate.v8f16.v8f16(i32 307, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 0, i32 64) ; OuterProductAccumulate(inputVector1,inputVector2,matrixBuffer,matrixOffset,matrixIntepretation,matrixLayout,matrixStride) -// HLOP-0: call void @"dx.hl.op..void (i32, <8 x half>, <8 x half>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 0, i32 64) +// HLOP-0: call void @"dx.hl.op..void (i32, <8 x half>, <8 x half>, %dx.types.Handle, i32, i32, i32, i32)"(i32 392, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 8, i32 0, i32 64) // DXIL-1: call void @dx.op.outerProductAccumulate.v8f16.v8f16(i32 307, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 3, i32 64) ; OuterProductAccumulate(inputVector1,inputVector2,matrixBuffer,matrixOffset,matrixIntepretation,matrixLayout,matrixStride) -// HLOP-1: call void @"dx.hl.op..void (i32, <8 x half>, <8 x half>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 3, i32 64) +// HLOP-1: call void @"dx.hl.op..void (i32, <8 x half>, <8 x half>, %dx.types.Handle, i32, i32, i32, i32)"(i32 392, <8 x half> %{{[^ ]+}}, <8 x half> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 21, i32 3, i32 64) // DXIL-2: call void @dx.op.outerProductAccumulate.v8i32.v8i32(i32 307, <8 x i32> %{{[^ ]+}}, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 3, i32 64) ; OuterProductAccumulate(inputVector1,inputVector2,matrixBuffer,matrixOffset,matrixIntepretation,matrixLayout,matrixStride) -// HLOP-2: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, <8 x i32> %{{[^ ]+}}, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 3, i32 64) +// HLOP-2: call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 392, <8 x i32> %{{[^ ]+}}, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 19, i32 3, i32 64) enum CompType { Invalid = 0, diff --git a/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll b/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll index 2687631f39..7df90ee726 100644 --- a/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll +++ b/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll @@ -26,7 +26,7 @@ entry: ;CHECK: call <4 x float> @dx.op.matVecMul.v4f32.v4f32(i32 305, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %1, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, i1 false) - call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 363, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp3, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64), !dbg !22 ; line:24 col:2 + call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp3, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64), !dbg !22 ; line:24 col:2 %tmp4 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !23 ; line:32 col:2 %tmp5 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp4), !dbg !23 ; line:32 col:2 %tmp6 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp5, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !23 ; line:32 col:2 @@ -36,20 +36,20 @@ entry: ;CHECK: call <4 x float> @dx.op.matVecMulAdd.v4f32.v4f32(i32 306, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %4, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %6, i32 0, i32 9, i1 false) - call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 364, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp6, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %tmp9, i32 0, i32 9), !dbg !23 ; line:32 col:2 + call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp6, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %tmp9, i32 0, i32 9), !dbg !23 ; line:32 col:2 %tmp10 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !24 ; line:45 col:2 %tmp11 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp10), !dbg !24 ; line:45 col:2 %tmp12 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp11, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !24 ; line:45 col:2 ; CHECK: call void @dx.op.outerProductAccumulate.v8i32.v8i32(i32 307, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 5, i32 3, i32 64) - call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 365, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %tmp12, i32 0, i32 5, i32 3, i32 64), !dbg !24 ; line:45 col:2 + call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 392, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %tmp12, i32 0, i32 5, i32 3, i32 64), !dbg !24 ; line:45 col:2 %tmp13 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !25 ; line:51 col:3 %tmp14 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp13), !dbg !25 ; line:51 col:3 %tmp15 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp14, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !25 ; line:51 col:3 ;CHECK: call void @dx.op.vectorAccumulate.v8i32(i32 308, <8 x i32> undef, %dx.types.Handle %11, i32 0) - call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 366, <8 x i32> undef, %dx.types.Handle %tmp15, i32 0), !dbg !25 ; line:51 col:3 + call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 393, <8 x i32> undef, %dx.types.Handle %tmp15, i32 0), !dbg !25 ; line:51 col:3 %tmp16 = bitcast <4 x float>* %output_vector to i8*, !dbg !26 ; line:53 col:1 call void @llvm.lifetime.end(i64 16, i8* %tmp16) #0, !dbg !26 ; line:53 col:1 ret void, !dbg !26 ; line:53 col:1 From d5f03f2dc09b9ada0d2bd86559824dbc9e39dcc4 Mon Sep 17 00:00:00 2001 From: anupamac Date: Thu, 17 Apr 2025 23:09:20 -0700 Subject: [PATCH 88/93] Remvoved MatrixLayout check for OuterProductAccumulate, updated DXIL validation errors per review feedback, some cleanup --- docs/DXIL.rst | 16 +- lib/DxilValidation/DxilValidation.cpp | 202 ++++++++++++++++---------- utils/hct/hctdb.py | 42 +++--- 3 files changed, 161 insertions(+), 99 deletions(-) diff --git a/docs/DXIL.rst b/docs/DXIL.rst index ab41ef808c..c77dfa184a 100644 --- a/docs/DXIL.rst +++ b/docs/DXIL.rst @@ -3138,14 +3138,14 @@ INSTR.ILLEGALDXILOPCODE DXILOpCode must be [0..%0] 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.LINALGINTERPRETATIONPARAMARECONST Interpretation values are constants -INSTR.LINALGINVALIDMATRIXLAYOUTVALUE Matrix Layout for Linalg ops not in valid set -INSTR.LINALGINVALIDMEMORYINTERPVALUE In Memory Interpolation value not in valid set -INSTR.LINALGINVALIDREGISTERINTERPVALUE From Register Interpretation value not in valid set -INSTR.LINALGMATRIXLAYOUTNOTTRANSPOSABLE Matrix Layout not transposable -INSTR.LINALGMATRIXSHAPEPARAMSARECONST Matrix Layout, Dimensions and isTranspose are immediate constants -INSTR.LINALGNOTANUNSIGNEDTYPE Unsigned flag set for signed type -INSTR.MATVECOPISUNSIGNEDFLAGSARECONST MatVec Ops Is Unsigned flag is a constant +INSTR.LINALGINTERPRETATIONPARAMARECONST In Linalg operations, Interpretation value is a constant. +INSTR.LINALGINVALIDMATRIXLAYOUTVALUEFORMATVECOPS Matrix Layout for Linalg Mul/MulAdd operation must be valid. +INSTR.LINALGINVALIDMEMORYINTERPVALUE In Memory Interpolation value must be valid. +INSTR.LINALGINVALIDREGISTERINTERPVALUE From Register Interpretation value must be valid. +INSTR.LINALGMATRIXLAYOUTNOTTRANSPOSABLE Row Major and Column Major matrix layouts are not transposable. +INSTR.LINALGMATRIXSHAPEPARAMSARECONST Matrix Layout, Dimensions and isTranspose are constants +INSTR.LINALGNOTANUNSIGNEDTYPE Unsigned flag set for a float signed type +INSTR.MATVECOPISUNSIGNEDFLAGSARECONST In Linalg Mul/MulAdd functions, IsUnsigned flag is a constant. 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. diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp index a9deb66c4e..0b2ccf5f95 100644 --- a/lib/DxilValidation/DxilValidation.cpp +++ b/lib/DxilValidation/DxilValidation.cpp @@ -992,14 +992,29 @@ static bool CheckLinalgInterpretation(uint32_t Input, bool InRegister) { } } -static bool CheckMatrixLayout(unsigned Input) { - return Input <= +static bool CheckMatrixLayoutForMatVecMulOps(unsigned Layout) { + return Layout <= static_cast(DXIL::LinalgMatrixLayout::OuterProductOptimal); } -static bool CheckTransposeForMatrixLayout(DXIL::LinalgMatrixLayout Layout, - bool Transposed) { - switch (Layout) { +std::string GetMatrixLayoutStr(unsigned Layout) { + switch (static_cast(Layout)) { + case DXIL::LinalgMatrixLayout::RowMajor: + return "RowMajor"; + case DXIL::LinalgMatrixLayout::ColumnMajor: + return "ColumnMajor"; + case DXIL::LinalgMatrixLayout::MulOptimal: + return "MulOptimal"; + case DXIL::LinalgMatrixLayout::OuterProductOptimal: + return "OuterProductOptimal"; + default: + DXASSERT_NOMSG(false); + return "Invalid"; + } +} + +static bool CheckTransposeForMatrixLayout(unsigned Layout, bool Transposed) { + switch (static_cast(Layout)) { case DXIL::LinalgMatrixLayout::RowMajor: case DXIL::LinalgMatrixLayout::ColumnMajor: return !Transposed; @@ -1033,84 +1048,116 @@ static Value *GetMatVecOpIsOutputUnsigned(CallInst *CI, DXIL::OpCode OpCode) { static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, ValidationContext &ValCtx) { - // Check Common operands llvm::Value *IsInputUnsigned = CI->getOperand(DXIL::OperandIndex::kMatVecMulIsInputUnsignedIdx); - llvm::Value *InputInterpretation = - CI->getOperand(DXIL::OperandIndex::kMatVecMulInputInterpretationIdx); - llvm::Value *MatrixInterpretation = - CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixInterpretationIdx); - llvm::Value *MatrixM = - CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixMIdx); - llvm::Value *MatrixK = - CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixKIdx); - llvm::Value *MatrixLayout = - CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixLayoutIdx); - llvm::Value *MatrixTranspose = - CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixTransposeIdx); - llvm::Value *IsOutputUnsigned = GetMatVecOpIsOutputUnsigned(CI, OpCode); - ConstantInt *IsInputUnsignedConst = dyn_cast(IsInputUnsigned); if (!IsInputUnsignedConst) { - ValCtx.EmitInstrError(CI, - ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst); + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst, + {"IsInputUnsigned"}); return; } + llvm::Value *IsOutputUnsigned = GetMatVecOpIsOutputUnsigned(CI, OpCode); ConstantInt *IsOutputUnsignedConst = dyn_cast(IsOutputUnsigned); if (!IsOutputUnsignedConst) { - ValCtx.EmitInstrError(CI, - ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst); + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrMatVecOpIsUnsignedFlagsAreConst, + {"IsOutputUnsigned"}); return; } + llvm::Value *InputInterpretation = + CI->getOperand(DXIL::OperandIndex::kMatVecMulInputInterpretationIdx); ConstantInt *II = dyn_cast(InputInterpretation); - ConstantInt *MI = dyn_cast(MatrixInterpretation); - if (!II || !MI) { - ValCtx.EmitInstrError( - CI, ValidationRule::InstrLinalgInterpretationParamAreConst); + if (!II) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgInterpretationParamAreConst, + {"InputInterpretation"}); return; } - - // Check if InputInterpretation and MatrixInterpretation are valid uint64_t IIValue = II->getLimitedValue(); if (!CheckLinalgInterpretation(IIValue, true)) { - ValCtx.EmitInstrError( - CI, ValidationRule::InstrLinalgInvalidRegisterInterpValue); + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgInvalidRegisterInterpValue, + {std::to_string(IIValue), "Input"}); return; } + llvm::Value *MatrixInterpretation = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixInterpretationIdx); + ConstantInt *MI = dyn_cast(MatrixInterpretation); + if (!MI) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgInterpretationParamAreConst, + {"MatrixInterpretation"}); + return; + } uint64_t MIValue = MI->getLimitedValue(); if (!CheckLinalgInterpretation(MIValue, false)) { - ValCtx.EmitInstrError(CI, - ValidationRule::InstrLinalgInvalidMemoryInterpValue); + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue, + {std::to_string(MIValue), "Matrix"}); return; } - ConstantInt *MatrixTransposeConst = dyn_cast(MatrixTranspose); - ConstantInt *MatrixLayoutConst = dyn_cast(MatrixLayout); - if (!llvm::isa(MatrixM) || - !llvm::isa(MatrixK) || !MatrixLayoutConst || - !MatrixTransposeConst) { - ValCtx.EmitInstrError(CI, - ValidationRule::InstrLinalgMatrixShapeParamsAreConst); + llvm::Value *MatrixM = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixMIdx); + if (!llvm::isa(MatrixM)) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst, + {"Matrix M dimension"}); + return; + } + + llvm::Value *MatrixK = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixKIdx); + if (!llvm::isa(MatrixK)) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst, + {"Matrix K dimension"}); return; } + llvm::Value *MatrixLayout = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixLayoutIdx); + + ConstantInt *MatrixLayoutConst = dyn_cast(MatrixLayout); + if (!MatrixLayoutConst) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst, + {"Matrix Layout"}); + return; + } uint64_t MLValue = MatrixLayoutConst->getLimitedValue(); - if (!CheckMatrixLayout(MLValue)) { - ValCtx.EmitInstrError(CI, - ValidationRule::InstrLinalgInvalidMatrixLayoutValue); + if (!CheckMatrixLayoutForMatVecMulOps(MLValue)) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgInvalidMatrixLayoutValueForMatVecOps, + {std::to_string(MLValue), + std::to_string( + static_cast(DXIL::LinalgMatrixLayout::RowMajor)), + std::to_string(static_cast( + DXIL::LinalgMatrixLayout::OuterProductOptimal))}); + return; + } + + llvm::Value *MatrixTranspose = + CI->getOperand(DXIL::OperandIndex::kMatVecMulMatrixTransposeIdx); + ConstantInt *MatrixTransposeConst = dyn_cast(MatrixTranspose); + if (!MatrixTransposeConst) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst, + {"MatrixTranspose"}); return; } - if (!CheckTransposeForMatrixLayout( - static_cast(MLValue), - MatrixTransposeConst->getLimitedValue())) { - ValCtx.EmitInstrError( - CI, ValidationRule::InstrLinalgMatrixLayoutNotTransposable); + if (!CheckTransposeForMatrixLayout(MLValue, + MatrixTransposeConst->getLimitedValue())) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgMatrixLayoutNotTransposable, + {GetMatrixLayoutStr(MLValue)}); return; } @@ -1118,13 +1165,15 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, CI->getOperand(DXIL::OperandIndex::kMatVecMulInputVectorIdx); if (!CheckUnsignedFlag(InputVector->getType(), IsInputUnsignedConst->getLimitedValue())) { - ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgNotAnUnsignedType); + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgNotAnUnsignedType, {"Input"}); return; } if (!CheckUnsignedFlag(CI->getType(), IsOutputUnsignedConst->getLimitedValue())) { - ValCtx.EmitInstrError(CI, ValidationRule::InstrLinalgNotAnUnsignedType); + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgNotAnUnsignedType, {"Output"}); return; } @@ -1132,16 +1181,18 @@ static void ValidateImmOperandsForMatVecOps(CallInst *CI, DXIL::OpCode OpCode, case DXIL::OpCode::MatVecMulAdd: { llvm::Value *BiasInterpretation = CI->getOperand(DXIL::OperandIndex::kMatVecMulAddBiasInterpretation); - if (!llvm::isa(BiasInterpretation)) { - ValCtx.EmitInstrError( - CI, ValidationRule::InstrLinalgInterpretationParamAreConst); + ConstantInt *BI = cast(BiasInterpretation); + if (!BI) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgInterpretationParamAreConst, + {"BiasInterpretation"}); return; } - ConstantInt *BI = cast(BiasInterpretation); uint64_t BIValue = BI->getLimitedValue(); if (!CheckLinalgInterpretation(BIValue, false)) { - ValCtx.EmitInstrError( - CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue); + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue, + {std::to_string(BIValue), "Bias vector"}); return; } } break; @@ -1155,26 +1206,29 @@ static void ValidateImmOperandsForOuterProdAcc(CallInst *CI, llvm::Value *MatrixInterpretation = CI->getOperand(DXIL::OperandIndex::kOuterProdAccMatrixInterpretation); - llvm::Value *MatrixLayout = - CI->getOperand(DXIL::OperandIndex::kOuterProdAccMatrixLayout); - - if (!llvm::isa(MatrixInterpretation)) - ValCtx.EmitInstrError( - CI, ValidationRule::InstrLinalgInterpretationParamAreConst); ConstantInt *MI = cast(MatrixInterpretation); + if (!MI) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgInterpretationParamAreConst, + {"MatrixInterpretation"}); + return; + } uint64_t MIValue = MI->getLimitedValue(); - if (!CheckLinalgInterpretation(MIValue, false)) - ValCtx.EmitInstrError(CI, - ValidationRule::InstrLinalgInvalidMemoryInterpValue); + if (!CheckLinalgInterpretation(MIValue, false)) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgInvalidMemoryInterpValue, + {std::to_string(MIValue), "Matrix"}); + return; + } - if (!llvm::isa(MatrixLayout)) - ValCtx.EmitInstrError(CI, - ValidationRule::InstrLinalgMatrixShapeParamsAreConst); - ConstantInt *ML = cast(MatrixLayout); - uint64_t MLValue = ML->getLimitedValue(); - if (!CheckMatrixLayout(MLValue)) - ValCtx.EmitInstrError(CI, - ValidationRule::InstrLinalgInvalidMatrixLayoutValue); + llvm::Value *MatrixLayout = + CI->getOperand(DXIL::OperandIndex::kOuterProdAccMatrixLayout); + if (!llvm::isa(MatrixLayout)) { + ValCtx.EmitInstrFormatError( + CI, ValidationRule::InstrLinalgMatrixShapeParamsAreConst, + {"MatrixLayout"}); + return; + } } // Validate the type-defined mask compared to the store value mask which diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 2c91c52bf3..6e833983fe 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -8406,44 +8406,52 @@ def build_valrules(self): ) # Linalg ops - self.add_valrule( + self.add_valrule_msg( "Instr.MatVecOpIsUnsignedFlagsAreConst", - "MatVec Ops Is Unsigned flag is a constant", + "In Linalg Mul/MulAdd functions, IsUnsigned flag is a constant.", + "'%1' is not a constant value.", ) - self.add_valrule( + self.add_valrule_msg( "Instr.LinalgInterpretationParamAreConst", - "Interpretation values are constants", + "In Linalg operations, Interpretation value is a constant.", + "'%1' is not a constant value.", ) - self.add_valrule( + self.add_valrule_msg( "Instr.LinalgInvalidRegisterInterpValue", - "From Register Interpretation value not in valid set", + "From Register Interpretation value must be valid.", + "'%0' is not a valid %1 interpretation value.", ) - self.add_valrule( + self.add_valrule_msg( "Instr.LinalgInvalidMemoryInterpValue", - "In Memory Interpolation value not in valid set", + "In Memory Interpolation value must be valid.", + "'%0' is not a valid %1 interpretation value." ) - self.add_valrule( + self.add_valrule_msg( "Instr.LinalgMatrixShapeParamsAreConst", - "Matrix Layout, Dimensions and isTranspose are immediate constants", + "Matrix Layout, Dimensions and isTranspose are constants", + "'%0' is not a constant value.", ) - self.add_valrule( - "Instr.LinalgInvalidMatrixLayoutValue", - "Matrix Layout for Linalg ops not in valid set", + self.add_valrule_msg( + "Instr.LinalgInvalidMatrixLayoutValueForMatVecOps", + "Matrix Layout for Linalg Mul/MulAdd operation must be valid.", + "Matrix Layout value '%0' is not valid. Must be between [%1 - %2].", ) - self.add_valrule( + self.add_valrule_msg( "Instr.LinalgMatrixLayoutNotTransposable", - "Matrix Layout not transposable", + "Row Major and Column Major matrix layouts are not transposable.", + "'%0' matrix layout is not transposable.", ) - self.add_valrule( + self.add_valrule_msg( "Instr.LinalgNotAnUnsignedType", - "Unsigned flag set for signed type", + "Unsigned flag set for a float signed type", + "IsUnsigned flag set to true for a float type '%0' vector", ) # Some legacy rules: From f5a1a516fc40323d2d881c6acda5086cd1ff2f43 Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 18 Apr 2025 08:44:54 -0700 Subject: [PATCH 89/93] Update linalg_builtin.hlsl to intialize input vectors for outerproductaccumulate and vector accumulate functions --- .../hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl index 5e98e563f7..573c2273cd 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl @@ -1,6 +1,7 @@ // RUN: %dxc -fcgl -T cs_6_9 -E cs_main %s | FileCheck %s ByteAddressBuffer input_vector_buffer; +ByteAddressBuffer opa_input_buffer; ByteAddressBuffer matrix_buffer; ByteAddressBuffer bias_buffer; RWByteAddressBuffer rw_matrix_buffer; @@ -27,7 +28,7 @@ void cs_main() // CHECK: %[[MLD0:[^ ]+]] = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A" // CHECK: %[[MCH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %[[MLD0]]) - // CHECK: %[[MAH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH0]], %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer undef) + // CHECK: %[[MAH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH0]] %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer undef) // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x float>* %{{[^ ]+}}, i1 false, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH0]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64) __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset, @@ -52,8 +53,8 @@ void cs_main() bias_interpretation); output_vector_buffer.Store(1024, output_vector); - vector input_vector1; - vector input_vector2; + vector input_vector1 = opa_input_buffer.Load >(0); + vector input_vector2 = opa_input_buffer.Load >(128); const uint opa_matrix_offset = 0; const uint opa_matrix_interpretation = 5; /*U32*/ const uint opa_matrix_layout = 3; /*OuterProductOptimal*/ From 153845377fe85a9f2dbb21473e7ed7996189ef96 Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 18 Apr 2025 09:56:42 -0700 Subject: [PATCH 90/93] Removed undefs and added named checks for resource handles in the linalg ops --- .../DXC/Passes/DxilGen/linalg-builtins.ll | 192 ++++++++++++------ 1 file changed, 127 insertions(+), 65 deletions(-) diff --git a/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll b/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll index 7df90ee726..6623f63031 100644 --- a/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll +++ b/tools/clang/test/DXC/Passes/DxilGen/linalg-builtins.ll @@ -9,50 +9,89 @@ target triple = "dxil-ms-dx" %dx.types.Handle = type { i8* } %dx.types.ResourceProperties = type { i32, i32 } +@"\01?input_vector_buffer@@3UByteAddressBuffer@@A" = external global %struct.ByteAddressBuffer, align 4 +@"\01?opa_input_buffer@@3UByteAddressBuffer@@A" = external global %struct.ByteAddressBuffer, align 4 @"\01?matrix_buffer@@3UByteAddressBuffer@@A" = external global %struct.ByteAddressBuffer, align 4 @"\01?bias_buffer@@3UByteAddressBuffer@@A" = external global %struct.ByteAddressBuffer, align 4 @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A" = external global %struct.RWByteAddressBuffer, align 4 +@"\01?output_vector_buffer@@3URWByteAddressBuffer@@A" = external global %struct.RWByteAddressBuffer, align 4 -; CHECK-LABEL: define void @cs_main() ; Function Attrs: nounwind define void @cs_main() #0 { entry: + ;CHECK-DAG: %[[MLD:[^ ]+]] = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A" + ;CHECK-DAG: %[[BLD:[^ ]+]] = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A" + ;CHECK-DAG: %[[RWMLD0:[^ ]+]] = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A" %output_vector = alloca <4 x float>, align 4 - %tmp = bitcast <4 x float>* %output_vector to i8*, !dbg !18 ; line:9 col:2 - call void @llvm.lifetime.start(i64 16, i8* %tmp) #0, !dbg !18 ; line:9 col:2 - %tmp1 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !22 ; line:24 col:2 - %tmp2 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp1), !dbg !22 ; line:24 col:2 - %tmp3 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp2, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !22 ; line:24 col:2 - - ;CHECK: call <4 x float> @dx.op.matVecMul.v4f32.v4f32(i32 305, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %1, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, i1 false) - - call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp3, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64), !dbg !22 ; line:24 col:2 - %tmp4 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !23 ; line:32 col:2 - %tmp5 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp4), !dbg !23 ; line:32 col:2 - %tmp6 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp5, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !23 ; line:32 col:2 - %tmp7 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !dbg !23 ; line:32 col:2 - %tmp8 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp7), !dbg !23 ; line:32 col:2 - %tmp9 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp8, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !23 ; line:32 col:2 - - ;CHECK: call <4 x float> @dx.op.matVecMulAdd.v4f32.v4f32(i32 306, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %4, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %6, i32 0, i32 9, i1 false) - - call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x float>* %output_vector, i1 false, <4 x float> undef, i1 false, i32 9, %dx.types.Handle %tmp6, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %tmp9, i32 0, i32 9), !dbg !23 ; line:32 col:2 - %tmp10 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !24 ; line:45 col:2 - %tmp11 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp10), !dbg !24 ; line:45 col:2 - %tmp12 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp11, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !24 ; line:45 col:2 - - ; CHECK: call void @dx.op.outerProductAccumulate.v8i32.v8i32(i32 307, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %{{[^ ]+}}, i32 0, i32 5, i32 3, i32 64) - call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 392, <8 x i32> undef, <8 x i32> undef, %dx.types.Handle %tmp12, i32 0, i32 5, i32 3, i32 64), !dbg !24 ; line:45 col:2 - %tmp13 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !25 ; line:51 col:3 - %tmp14 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp13), !dbg !25 ; line:51 col:3 - %tmp15 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp14, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !25 ; line:51 col:3 - - ;CHECK: call void @dx.op.vectorAccumulate.v8i32(i32 308, <8 x i32> undef, %dx.types.Handle %11, i32 0) - - call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 393, <8 x i32> undef, %dx.types.Handle %tmp15, i32 0), !dbg !25 ; line:51 col:3 - %tmp16 = bitcast <4 x float>* %output_vector to i8*, !dbg !26 ; line:53 col:1 - call void @llvm.lifetime.end(i64 16, i8* %tmp16) #0, !dbg !26 ; line:53 col:1 - ret void, !dbg !26 ; line:53 col:1 + %tmp = bitcast <4 x float>* %output_vector to i8*, !dbg !21 ; line:14 col:5 + call void @llvm.lifetime.start(i64 16, i8* %tmp) #0, !dbg !21 ; line:14 col:5 + %tmp1 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?input_vector_buffer@@3UByteAddressBuffer@@A", !dbg !25 ; line:17 col:37 + %tmp2 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp1), !dbg !25 ; line:17 col:37 + %tmp3 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp2, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !25 ; line:17 col:37 + %tmp4 = call <4 x float> @"dx.hl.op.ro.<4 x float> (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %tmp3, i32 0), !dbg !25 ; line:17 col:37 + %tmp5 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !26 ; line:33 col:5 + %tmp6 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp5), !dbg !26 ; line:33 col:5 + %tmp7 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp6, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !26 ; line:33 col:5 + + ;CHECK: %[[MCH0:[^ ]+]] = call %dx.types.Handle @dx.op.createHandleForLib.struct.ByteAddressBuffer(i32 160, %struct.ByteAddressBuffer %[[MLD]] + ;CHECK: %[[MAH0:[^ ]+]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %[[MCH0]] + ;CHECK: call <4 x float> @dx.op.matVecMul.v4f32.v4f32(i32 305, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH0]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, i1 false) + call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x float>* %output_vector, i1 false, <4 x float> %tmp4, i1 false, i32 9, %dx.types.Handle %tmp7, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64), !dbg !26 ; line:33 col:5 + + %tmp8 = load <4 x float>, <4 x float>* %output_vector, align 4, !dbg !27, !tbaa !28 ; line:37 col:35 + %tmp9 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?output_vector_buffer@@3URWByteAddressBuffer@@A", !dbg !31 ; line:37 col:5 + %tmp10 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp9), !dbg !31 ; line:37 col:5 + %tmp11 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp10, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !31 ; line:37 col:5 + call void @"dx.hl.op..void (i32, %dx.types.Handle, i32, <4 x float>)"(i32 277, %dx.types.Handle %tmp11, i32 0, <4 x float> %tmp8), !dbg !31 ; line:37 col:5 + %tmp12 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !dbg !32 ; line:49 col:5 + %tmp13 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp12), !dbg !32 ; line:49 col:5 + %tmp14 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp13, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !32 ; line:49 col:5 + %tmp15 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !dbg !32 ; line:49 col:5 + %tmp16 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp15), !dbg !32 ; line:49 col:5 + %tmp17 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp16, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !32 ; line:49 col:5 + + ;CHECK: %[[MCH1:[^ ]+]] = call %dx.types.Handle @dx.op.createHandleForLib.struct.ByteAddressBuffer(i32 160, %struct.ByteAddressBuffer %[[MLD]] + ;CHECK: %[[MAH1:[^ ]+]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %[[MCH1]] + ;CHECK: %[[BCH1:[^ ]+]] = call %dx.types.Handle @dx.op.createHandleForLib.struct.ByteAddressBuffer(i32 160, %struct.ByteAddressBuffer %[[BLD]] + ;CHECK: %[[BAH1:[^ ]+]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %[[BCH1]] + ;CHECK: call <4 x float> @dx.op.matVecMulAdd.v4f32.v4f32(i32 306, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH1]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %[[BAH1]], i32 0, i32 9, i1 false) + call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32 391, <4 x float>* %output_vector, i1 false, <4 x float> %tmp4, i1 false, i32 9, %dx.types.Handle %tmp14, i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64, %dx.types.Handle %tmp17, i32 0, i32 9), !dbg !32 ; line:49 col:5 + + %tmp18 = load <4 x float>, <4 x float>* %output_vector, align 4, !dbg !33, !tbaa !28 ; line:54 col:38 + %tmp19 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?output_vector_buffer@@3URWByteAddressBuffer@@A", !dbg !34 ; line:54 col:5 + %tmp20 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp19), !dbg !34 ; line:54 col:5 + %tmp21 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp20, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !34 ; line:54 col:5 + call void @"dx.hl.op..void (i32, %dx.types.Handle, i32, <4 x float>)"(i32 277, %dx.types.Handle %tmp21, i32 1024, <4 x float> %tmp18), !dbg !34 ; line:54 col:5 + %tmp22 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?opa_input_buffer@@3UByteAddressBuffer@@A", !dbg !35 ; line:56 col:37 + %tmp23 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp22), !dbg !35 ; line:56 col:37 + %tmp24 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp23, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !35 ; line:56 col:37 + %tmp25 = call <8 x i32> @"dx.hl.op.ro.<8 x i32> (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %tmp24, i32 0), !dbg !35 ; line:56 col:37 + %tmp26 = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?opa_input_buffer@@3UByteAddressBuffer@@A", !dbg !36 ; line:57 col:37 + %tmp27 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %tmp26), !dbg !36 ; line:57 col:37 + %tmp28 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp27, %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer zeroinitializer), !dbg !36 ; line:57 col:37 + %tmp29 = call <8 x i32> @"dx.hl.op.ro.<8 x i32> (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %tmp28, i32 128), !dbg !36 ; line:57 col:37 + %tmp30 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !37 ; line:67 col:5 + %tmp31 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp30), !dbg !37 ; line:67 col:5 + %tmp32 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp31, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !37 ; line:67 col:5 + + ;CHECK: %[[RWMCH0:[^ ]+]] = call %dx.types.Handle @dx.op.createHandleForLib.struct.RWByteAddressBuffer(i32 160, %struct.RWByteAddressBuffer %[[RWMLD0]] + ;CHECK: %[[RWMAH0:[^ ]+]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %[[RWMCH0]] + ;CHECK: call void @dx.op.outerProductAccumulate.v8i32.v8i32(i32 307, <8 x i32> %{{[^ ]+}}, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %[[RWMAH0]], i32 0, i32 5, i32 3, i32 64) + call void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32 392, <8 x i32> %tmp25, <8 x i32> %tmp29, %dx.types.Handle %tmp32, i32 0, i32 5, i32 3, i32 64), !dbg !37 ; line:67 col:5 + + + %tmp33 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !dbg !38 ; line:77 col:5 + %tmp34 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %tmp33), !dbg !38 ; line:77 col:5 + %tmp35 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %tmp34, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer zeroinitializer), !dbg !38 ; line:77 col:5 + + ;CHECK: %[[RWMCH1:[^ ]+]] = call %dx.types.Handle @dx.op.createHandleForLib.struct.RWByteAddressBuffer(i32 160, %struct.RWByteAddressBuffer %[[RWMLD0]] + ;CHECK: %[[RWMAH1:[^ ]+]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %[[RWMCH1]] + ;CHECK: call void @dx.op.vectorAccumulate.v8i32(i32 308, <8 x i32> %{{[^ ]+}}, %dx.types.Handle %[[RWMAH1]], i32 0) + call void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32 393, <8 x i32> %tmp25, %dx.types.Handle %tmp35, i32 0), !dbg !38 ; line:77 col:5 + + %tmp36 = bitcast <4 x float>* %output_vector to i8*, !dbg !39 ; line:79 col:1 + call void @llvm.lifetime.end(i64 16, i8* %tmp36) #0, !dbg !39 ; line:79 col:1 + ret void, !dbg !39 ; line:79 col:1 } ; Function Attrs: nounwind @@ -61,32 +100,42 @@ declare void @llvm.lifetime.start(i64, i8* nocapture) #0 ; Function Attrs: nounwind declare void @llvm.lifetime.end(i64, i8* nocapture) #0 -; Function Attrs: nounwind -declare void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32) #0 +; Function Attrs: nounwind readonly +declare <4 x float> @"dx.hl.op.ro.<4 x float> (i32, %dx.types.Handle, i32)"(i32, %dx.types.Handle, i32) #1 ; Function Attrs: nounwind readnone -declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32, %struct.ByteAddressBuffer) #1 +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32, %struct.ByteAddressBuffer) #2 ; Function Attrs: nounwind readnone -declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer) #1 +declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer) #2 ; Function Attrs: nounwind -declare void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32) #0 +declare void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32) #0 ; Function Attrs: nounwind -declare void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32) #0 +declare void @"dx.hl.op..void (i32, %dx.types.Handle, i32, <4 x float>)"(i32, %dx.types.Handle, i32, <4 x float>) #0 ; Function Attrs: nounwind readnone -declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32, %struct.RWByteAddressBuffer) #1 +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32, %struct.RWByteAddressBuffer) #2 ; Function Attrs: nounwind readnone -declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer) #1 +declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer) #2 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32)"(i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32, %dx.types.Handle, i32, i32) #0 + +; Function Attrs: nounwind readonly +declare <8 x i32> @"dx.hl.op.ro.<8 x i32> (i32, %dx.types.Handle, i32)"(i32, %dx.types.Handle, i32) #1 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32)"(i32, <8 x i32>, <8 x i32>, %dx.types.Handle, i32, i32, i32, i32) #0 ; Function Attrs: nounwind declare void @"dx.hl.op..void (i32, <8 x i32>, %dx.types.Handle, i32)"(i32, <8 x i32>, %dx.types.Handle, i32) #0 attributes #0 = { nounwind } -attributes #1 = { nounwind readnone } +attributes #1 = { nounwind readonly } +attributes #2 = { nounwind readnone } !llvm.module.flags = !{!0} !pauseresume = !{!1} @@ -95,8 +144,8 @@ attributes #1 = { nounwind readnone } !dx.shaderModel = !{!3} !dx.typeAnnotations = !{!4} !dx.entryPoints = !{!8} -!dx.fnprops = !{!15} -!dx.options = !{!16, !17} +!dx.fnprops = !{!18} +!dx.options = !{!19, !20} !0 = !{i32 2, !"Debug Info Version", i32 3} !1 = !{!"hlsl-hlemit", !"hlsl-hlensure"} @@ -107,21 +156,34 @@ attributes #1 = { nounwind readnone } !6 = !{i32 1, !7, !7} !7 = !{} !8 = !{void ()* @cs_main, !"cs_main", null, !9, null} -!9 = !{!10, !13, null, null} -!10 = !{!11, !12} -!11 = !{i32 0, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !"matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} -!12 = !{i32 1, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !"bias_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} -!13 = !{!14} -!14 = !{i32 0, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !"rw_matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i1 false, i1 false, i1 false, null} -!15 = !{void ()* @cs_main, i32 5, i32 1, i32 1, i32 1} -!16 = !{i32 -2147483584} -!17 = !{i32 -1} -!18 = !DILocation(line: 9, column: 2, scope: !19) -!19 = !DISubprogram(name: "cs_main", scope: !20, file: !20, line: 7, type: !21, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, function: void ()* @cs_main) -!20 = !DIFile(filename: "DirectXShaderCompiler\5Ctools\5Cclang\5Ctest\5CCodeGenDXIL\5Chlsl\5Cintrinsics\5Clinalg-builtins.hlsl", directory: "") -!21 = !DISubroutineType(types: !7) -!22 = !DILocation(line: 24, column: 2, scope: !19) -!23 = !DILocation(line: 32, column: 2, scope: !19) -!24 = !DILocation(line: 45, column: 2, scope: !19) -!25 = !DILocation(line: 51, column: 3, scope: !19) -!26 = !DILocation(line: 53, column: 1, scope: !19) +!9 = !{!10, !15, null, null} +!10 = !{!11, !12, !13, !14} +!11 = !{i32 0, %struct.ByteAddressBuffer* @"\01?input_vector_buffer@@3UByteAddressBuffer@@A", !"input_vector_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} +!12 = !{i32 1, %struct.ByteAddressBuffer* @"\01?opa_input_buffer@@3UByteAddressBuffer@@A", !"opa_input_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} +!13 = !{i32 2, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A", !"matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} +!14 = !{i32 3, %struct.ByteAddressBuffer* @"\01?bias_buffer@@3UByteAddressBuffer@@A", !"bias_buffer", i32 -1, i32 -1, i32 1, i32 11, i32 0, null} +!15 = !{!16, !17} +!16 = !{i32 0, %struct.RWByteAddressBuffer* @"\01?rw_matrix_buffer@@3URWByteAddressBuffer@@A", !"rw_matrix_buffer", i32 -1, i32 -1, i32 1, i32 11, i1 false, i1 false, i1 false, null} +!17 = !{i32 1, %struct.RWByteAddressBuffer* @"\01?output_vector_buffer@@3URWByteAddressBuffer@@A", !"output_vector_buffer", i32 -1, i32 -1, i32 1, i32 11, i1 false, i1 false, i1 false, null} +!18 = !{void ()* @cs_main, i32 5, i32 1, i32 1, i32 1} +!19 = !{i32 -2147483584} +!20 = !{i32 -1} +!21 = !DILocation(line: 14, column: 5, scope: !22) +!22 = !DISubprogram(name: "cs_main", scope: !23, file: !23, line: 12, type: !24, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: false, function: void ()* @cs_main) +!23 = !DIFile(filename: "DirectXShaderCompiler\5Ctools\5Cclang\5Ctest\5CCodeGenDXIL\5Chlsl\5Cintrinsics\5Clinalg_builtins\5Clinalg-builtins.hlsl", directory: "") +!24 = !DISubroutineType(types: !7) +!25 = !DILocation(line: 17, column: 37, scope: !22) +!26 = !DILocation(line: 33, column: 5, scope: !22) +!27 = !DILocation(line: 37, column: 35, scope: !22) +!28 = !{!29, !29, i64 0} +!29 = !{!"omnipotent char", !30, i64 0} +!30 = !{!"Simple C/C++ TBAA"} +!31 = !DILocation(line: 37, column: 5, scope: !22) +!32 = !DILocation(line: 49, column: 5, scope: !22) +!33 = !DILocation(line: 54, column: 38, scope: !22) +!34 = !DILocation(line: 54, column: 5, scope: !22) +!35 = !DILocation(line: 56, column: 37, scope: !22) +!36 = !DILocation(line: 57, column: 37, scope: !22) +!37 = !DILocation(line: 67, column: 5, scope: !22) +!38 = !DILocation(line: 77, column: 5, scope: !22) +!39 = !DILocation(line: 79, column: 1, scope: !22) From 7cbe979d89667bb0826de05734ee2966da6530c0 Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 18 Apr 2025 11:29:51 -0700 Subject: [PATCH 91/93] Update diagnostics per llvm coding guidelines --- utils/hct/hctdb.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 6e833983fe..d2c2b7cc33 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -8409,43 +8409,43 @@ def build_valrules(self): self.add_valrule_msg( "Instr.MatVecOpIsUnsignedFlagsAreConst", "In Linalg Mul/MulAdd functions, IsUnsigned flag is a constant.", - "'%1' is not a constant value.", + "'%1' is not a constant value", ) self.add_valrule_msg( "Instr.LinalgInterpretationParamAreConst", "In Linalg operations, Interpretation value is a constant.", - "'%1' is not a constant value.", + "'%1' is not a constant value", ) self.add_valrule_msg( "Instr.LinalgInvalidRegisterInterpValue", "From Register Interpretation value must be valid.", - "'%0' is not a valid %1 interpretation value.", + "'%0' is not a valid %1 interpretation value", ) self.add_valrule_msg( "Instr.LinalgInvalidMemoryInterpValue", "In Memory Interpolation value must be valid.", - "'%0' is not a valid %1 interpretation value." + "'%0' is not a valid %1 interpretation value" ) self.add_valrule_msg( "Instr.LinalgMatrixShapeParamsAreConst", "Matrix Layout, Dimensions and isTranspose are constants", - "'%0' is not a constant value.", + "'%0' is not a constant value", ) self.add_valrule_msg( "Instr.LinalgInvalidMatrixLayoutValueForMatVecOps", "Matrix Layout for Linalg Mul/MulAdd operation must be valid.", - "Matrix Layout value '%0' is not valid. Must be between [%1 - %2].", + "matrix layout value '%0' is not valid. Must be between [%1 - %2]", ) self.add_valrule_msg( "Instr.LinalgMatrixLayoutNotTransposable", "Row Major and Column Major matrix layouts are not transposable.", - "'%0' matrix layout is not transposable.", + "%0 matrix layout is not transposable", ) self.add_valrule_msg( From faf6df0709dd5bf5e49a03f17c3b7b8fdb1bcbbd Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 18 Apr 2025 11:37:46 -0700 Subject: [PATCH 92/93] Missing trailing comma was bugging darker --- utils/hct/hctdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index d2c2b7cc33..63af8c0b38 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -8427,7 +8427,7 @@ def build_valrules(self): self.add_valrule_msg( "Instr.LinalgInvalidMemoryInterpValue", "In Memory Interpolation value must be valid.", - "'%0' is not a valid %1 interpretation value" + "'%0' is not a valid %1 interpretation value", ) self.add_valrule_msg( From 8782246fe59653341725fd1762f346f326151a41 Mon Sep 17 00:00:00 2001 From: anupamac Date: Fri, 18 Apr 2025 12:27:31 -0700 Subject: [PATCH 93/93] Fix linalg-builtins.hlsl file check: missing comma --- .../hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl index 573c2273cd..c3b4a3a8d7 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/intrinsics/linalg_builtins/linalg-builtins.hlsl @@ -28,7 +28,7 @@ void cs_main() // CHECK: %[[MLD0:[^ ]+]] = load %struct.ByteAddressBuffer, %struct.ByteAddressBuffer* @"\01?matrix_buffer@@3UByteAddressBuffer@@A" // CHECK: %[[MCH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.ByteAddressBuffer)"(i32 0, %struct.ByteAddressBuffer %[[MLD0]]) - // CHECK: %[[MAH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH0]] %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer undef) + // CHECK: %[[MAH0:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.ByteAddressBuffer)"(i32 14, %dx.types.Handle %[[MCH0]], %dx.types.ResourceProperties { i32 11, i32 0 }, %struct.ByteAddressBuffer undef) // CHECK: call void @"dx.hl.op..void (i32, <4 x float>*, i1, <4 x float>, i1, i32, %dx.types.Handle, i32, i32, i32, i32, i32, i1, i32)"(i32 390, <4 x float>* %{{[^ ]+}}, i1 false, <4 x float> %{{[^ ]+}}, i1 false, i32 9, %dx.types.Handle %[[MAH0]], i32 0, i32 9, i32 4, i32 4, i32 0, i1 false, i32 64) __builtin_MatVecMul(output_vector, is_output_unsigned, input_vector, is_input_unsigned, input_interpretation, matrix_buffer, matrix_offset,