Граф коммитов

149 Коммитов

Автор SHA1 Сообщение Дата
yurido1 35f727ac33 Added support for functions without arguments. (#292) 2017-05-12 12:46:01 -07:00
Tex Riddell 5cb5131b32 Update PSV data structures with ViewID dependency data and Dxil Signatures (#289)
* Update PSV with ViewID data structures
* Update PSV with signature element data and gate PSV1 on SM 6.1
* Unwrap array on primitive when assigning semantic indexes
- fix semantic index assignment for matrix and primitives
- fix some tests
- disable two tests due to AssembleToContainer fail:
  ValidationTest::SigOutOfRangeFail
  ValidationTest::SimpleGs1Fail
2017-05-10 18:17:04 -07:00
yurido1 df132d59b4 Initial implementation of ViewId state analysis. (#290) 2017-05-10 18:14:43 -07:00
Young Kim f66e8083d6 Allow two SV_Barycentrics (#282)
unlike other system value semantics, pixel shader is allowed to declare at most two input attributes with SV_Barycentrics, with one declaration uses perspective interpolation type while other one uses noperspective interpolation type.
2017-05-09 18:59:30 -07:00
Marcelo Lopez Ruiz ad76d814a4 Debug name part implementation (#264)
* Add documentation with source-level debugging with HLSL and DXIL.
* Fix trailing underscore in generate .rst documentation.
* Add container support for debug name part.
* Bump validator version to 1.1.
* Implement debug stripping in dxc, including /Fd dir-named behavior.
* Implement IDxcCompiler2 and CompileWithDebug.
2017-05-09 18:32:48 -07:00
Xiang Li 9edb1a553e Lower static global resource and local resource to handle. (#276)
1. Add ResourceToHandle pass to lower resource to handle.
2. Don't performPromotion in SROA_HLSL.
3. Add Option support for DynamicIndexingVectorToArray.
4. Fix bug in GetPassOption.
5. Replace GEP ptr, 0 with ptr in DynamicIndexingVectorToArray::ReplaceStaticIndexingOnVector.
6. Run mem2reg before DxilGenerationPass.
7.Legalize EvalOperations before change vector to array.
2017-05-05 18:31:35 -07:00
Lei Zhang 2c7a3fc39d [spirv] Add bare bone code for SPIR-V codegen (#233)
* [spirv] Add libclangSPIRV and skeleton FrontendAction for SPIR-V

* [spirv] Add -spirv into dxc for invoking EmitSPIRVAction

* [spirv] Build SPIR-V codegen conditionally

Added ENABLE_SPIRV_CODEGEN in CMake config to control the
building of SPIR-V component and wrap up SPIR-V code using it.
Also add -spirv to hctbuild to turn it on.
2017-05-05 19:39:59 -03:00
Young Kim 47d21ad6c0 Fix EvalauteAttribute Intrinsics (#275)
Currently the compiler crashes when we pass in matrix or vectors with reduced dimension from the original signature element for EvalAttribute functions. This change resolves this issue by replacing allocas before we translate these function calls from DXIR to DXIL and find LoadInputs to replace correctly.
2017-05-05 15:10:46 -07:00
Tex Riddell da5f98bb95 Updates to DxcValidator and DxcCompiler wrt. versioning/flags (#269)
Make DxcCreateInstance load validator from dxil.dll when available
Add DxcVersionInfoFlags_Internal flag to indicate internal validator
Add DxcValidatorFlags_ModuleOnly to indicate absense of full container for validation, requiring explicit use. This will not succeed when using dxil.dll validator.
Bump Validator version
Implement IDxcVersionInfo in DxcCompiler to indicate DXIL highest version supported and debug flag for compiler separately from validator
Refactor version detection code for tests, adding dxil and validator versions
Make SystemValueTest version aware
Add version check to AttributeAtVertex and SV_Barycentrics tests.
Fix line endings for HlslTestUtils.h
2017-05-04 22:18:57 -07:00
Xiang Li 7179f13400 Do not create phi on non-default address space. (#273) 2017-05-04 16:25:44 -07:00
Young Kim 13cf7d466c Update barycentric with new spec (#265)
1. Adding SV_Barycentric and removing barycentric intrinsics/dxilops
2. GetAttributeAtVertex only thakes no_interpolation attribute
3. SV_Barycentric can take any interpolation modifier except nointerpolation
4. SV_Barycentric can only have float3 type
2017-05-03 17:07:02 -07:00
Tex Riddell c0d3163ee3 Dxil versioned OpCode/Class counts, and other dxil versioning fixes (#263) 2017-05-02 14:42:05 -07:00
Tex Riddell bd6c105e9b Add ViewID slot validation for PSIn (#254) 2017-05-01 17:54:33 -07:00
Xiang Li d108a552de Refactoring DynamicIndexingVectorToArray to share code with MultiDimArrayToOneDimArray. (#259) 2017-05-01 11:15:32 -07:00
Xiang Li 9f437adda5 Lower memcpy before SORA a pointer. (#253)
1. Try to propagate if the pointer is only write once by the memcpy.
2. Use correct size for memcpy created in AppendBuffer::Append.
3. Ignore unused Constant user of Matrix value.
4. Replace Constant with Inst on the Instruction version of Constant.
5. When match size of memcpy, go deeper if struct only has 1 element.
   Doing this will leave memcpy be lowered at deeper level.
6. Do not replace when SimplePtrCopy, cannot decide replace is safe or not.
2017-04-28 14:42:04 -07:00
Tex Riddell a581927370 Add SV_ViewID support (#251)
- Add SV_ViewID loaded from intrinsic in Dxil,
  for input to all graphics shader stages
- hctdb: rename shader_models to shader_stages,
  add shader_model for min required shader model
- Validator: validate dxil version required for shader model
- DxilModule: Add GetDxilVersion
- Set Barycentric intrinsics to SM 6.1
- Update SystemValueTest for SM 6.1
2017-04-27 14:17:31 -07:00
Young Kim 108b897f40 Barycentric init (#250)
This change is the initial step to support Barycentric coordinates for shader model 6.1 / DXIL 1.1
 - Add GetBarycentrics, GetAttributeAtVertex intrinsics and their corresponding dxil ops
 - Lowering intrinsics to dxil ops
 - Adding codegen tests for these operations
2017-04-26 12:29:48 -07:00
Xiang Li aec310b4ea Use memcpy to copy when possible in clang code gen to avoid flatten too early. (#247) 2017-04-25 13:37:06 -07:00
Xiang Li 478a433366 Disable CSE, leave it to target backend. (#246) 2017-04-24 19:19:22 -07:00
Tex Riddell 23082dbef2 Add HLSL 2017 (-HV 2017) option. (#245)
- Fix detection of invalid options in dxcompilerobj
2017-04-24 16:05:06 -07:00
Xiang Li bc4a68b6b4 Use SRet for struct return type. (#243)
1. Use SRet for struct return type.
2. Add SM6.1 and DXIL1.1.
2017-04-24 14:34:57 -07:00
Xiang Li 6bc247d4af Lower parameter (#242)
* Lower vector/matrix/resource/multi-dim array parameters to  scalars/array/handle/one-dim array.

* Code cleanup.
2017-04-21 17:47:26 -07:00
Xiang Li e14dc5ed1b Update matrix code gen. (#234)
1. Keep major for matrix pointers.
2. Change matrix values to row major to match hlsl.
   Only ColMatLoad, RowMatrixToColMatrix and col matrix value parameter for entry function are col major matrix value.
   And should only used by ColMatStore and ColMatrixToRowMatrix.
2017-04-21 11:56:37 -07:00
Xiang Li 4c22ec7802 Prepare to support handle as parameter. (#231)
1. Add resource attribute to FieldAnnotation.
2. Find resource arribute from Argument in FindCreateHandleResourceBase.
3. Remove limitation handle must be instruction.
4. Add HandleToResCast to help lower resource parameter to handle parameter.
2017-04-19 11:33:33 -07:00
Xiang Li 3911371309 Fix dbg info for temp variable. (#230)
1. Remove debug info when strip function parameter from entry function.
2. Set OptLevel to 0 for -Od.
3. If optimization is disabled, always load ReturnValue.
2017-04-18 13:49:59 -07:00
Marcelo Lopez Ruiz b3eb288629 Add opt support for naming module prints and to diff them in dndxc. (#228) 2017-04-16 22:01:30 -07:00
David Peixotto 449165a52d Run constant array hoisting pass by default (#224) 2017-04-13 17:56:28 -07:00
David Peixotto 022eb5717f Add hooks for constant folding extensions (#209)
This commit adds placeholder hooks to support constant folding of
extensions.  They are defined in a separate file to make it easy to merge
changes or link in other versions. There should be no upstream changes to
these definitions.
2017-04-13 15:04:14 -07:00
Lei Zhang c9f8438d90 Remove unnecessary const qualifier on return type (#221)
This solves compiler warnings given by -Wignored-qualifiers.
2017-04-13 14:41:08 -07:00
David Peixotto 76a4288913 Support lowering extensions directly to dxil (#217)
This commit adds the 'dxil' strategy for lowering extensions. This
strategy will change the extension call into a call to a dxil intrinsic.
This is useful for targeting dxil intrinsics that are not exposed in hlsl.
2017-04-13 10:19:00 -07:00
Lei Zhang 7008b2ad52 Add default virtual destructors for virtual classes (#218)
This fixes compiler warnings generated by -Wnon-virtual-dtor.
2017-04-12 14:21:01 -07:00
Lei Zhang 806fbb2bbf Fix initialization order of various class members (#211)
This solves compiler warnings given -Wreorder.
2017-04-12 13:34:28 -07:00
Lei Zhang 8c6ba6716b Upgrade SAL annotations in some source files (#197) 2017-04-12 12:39:41 -07:00
David Peixotto 0ba250e9dc Add pass to hoist constant arrays (#205)
This commit adds a new pass to hoist arrays from local to global scope
when the array only contains constant values. A local array will use
alloca and stores for initialization, but a global array uses a global
variable with a constant initializer.

The idea is that a global array with constant initializer will allow the
backend compilers to produce better code because it is much easier to see
that the array is fully constant.
2017-04-11 13:58:16 -07:00
Lei Zhang 026176362f Use typename to mark subtypes in templated class (#200) 2017-04-11 09:26:39 -07:00
Lei Zhang 8afb120125 Use llvm::make_unique instead of std::make_unique (#201)
std::make_unique is a C++14 feature.
2017-04-11 09:15:34 -07:00
Lei Zhang 892e7953fd Match filename cases (#199) 2017-04-10 22:52:10 -07:00
David Peixotto b0fd2d3949 Use opcode class to guide constant folding possibilities (#191)
This change modifies dxil constant folding to use the opcode class when
deciding if a dxil function can be constant folded. We now require a
DxilModule to be available when constant folding dxil functions.

To ensure that the dxil module is available we add a new pass that loads a
dxil module from metadata if it does not exist. We use the new pass in the
dxopt tests for constant folding.
2017-04-06 17:42:42 -07:00
Xiang Li bd16165aa7 Keep unused pointer in TranslateHLSubscript, it will be removed in TranslateSubscriptOperation. (#188) 2017-04-06 13:56:09 -07:00
David Peixotto deec58372a Ensure the cached Function->OpCodeClass map is updated (#186)
* Ensure the cached Function->OpCodeClass map is updated

The original goal of this change was to use opcode class for deciding when we
can perform constant folding on a function.

We maintain a mapping from Function* to OpCodeClass inside the OP class.
We wanted to use this map in constant folding to decide if we can constant
fold a function to avoid string comparison on the function names.

However, it turns out that the DxilModule is not always available during
constant folding of dxil calls so we cannot use the map inside of OP. The
change contains a few bug fixes and improvements that came out of trying
to get opcode class working inside constant folding.

  1. Use opcode class in dxil constant folding where possible.
  2. Make sure the opcode cache is refreshed properly.
  3. Remove 64-bit test for bfi.
  4. Add equality comparison for the ShaderModel class.

When switching to use the opcode class for constant folding, we discovered
that our test for 64-bit bfi is invalid. There is no 64-bit overload for
bfi in dxil, so the test we had written was not legal dxil. This change
removes the 64-bit test for bfi constant prop.
2017-04-06 13:48:27 -07:00
Xiang Li 9e8137c54d Use high level intrinsic when lower matrix mul to make sure DXIL operation only exist when DxilModule is ready. (#189) 2017-04-06 12:36:28 -07:00
Xiang Li 73e76ff294 Use mad for matrix mul. (#184) 2017-04-05 10:39:56 -07:00
Marcelo Lopez Ruiz a528d7bd86 Remove use of dynamic_cast, use dyn_cast instead. (#183)
Remove use of dynamic_cast, use dyn_cast instead.
2017-04-05 02:28:20 +01:00
David Peixotto ae69cf0a58 Add constant folding for dxil intrinsics (#179)
This commit adds the ability to constant fold dxil intrinsics when
all inputs are constant. We reuse the llvm constant folding
infrastructure and add special cases for calls to dxil intrinsics.
2017-04-04 09:15:19 -07:00
David Peixotto 84c30e388d Make hctdb output stable (#172) 2017-03-30 18:38:48 -07:00
Xiang Li c7db25781e Report error on invalid input/ouput type. (#176) 2017-03-30 14:12:36 -07:00
Xiang Li 2b4f3e4801 Support resource inside cbuffer. (#175) 2017-03-30 12:06:21 -07:00
Xiang Li 238c2221e2 Cast i32 col idx into i8. (#170) 2017-03-29 16:53:39 -07:00
David Peixotto 13f92a77c4 Fix #169 - Bad codegen for firstbithigh/firstbitlow (#171)
This patch changes codegen for firstbithigh and firstbitlow.

For firstbitlow we do not generate a select on the return value from the
intrinsic. The previous codegen would check if the value is 0 and return -1 if
it was. However, the FirstbitLo intrinsic will return -1 when the input is 0 so
the select is not needed. So regardless of the input value we can take the
result of the intrinsic. This would match the code produced by fxc.

For firstbithi we check the value returned from the intrinsic for -1. If
the value returned is -1 we return -1. We do this for both signed and
unsigned intrinsics. The old codegen would check the input value for
0 and so would produce wrong code when the input value was -1.

We also disable constant folding in the front end for these intrinsics.
There was a bug in the constant folding that would cause a crash and
we are adding constant folding for dxil intrinsics to the optimizer
so we should not need it explicitly in the frontend for these
intrinsics.
2017-03-29 12:38:07 -07:00
Xiang Li a3306bff1d Lower resource to createHandle at clang code gen. (#163)
* Lower resource to createHandle at clang code gen.
1. A HL createHandle will have 1 or 2 parameters.
   For  uav/srv/sampler, 1 parameter. 1 is the resource load from resource ptr.
   For cbuffer, 2 parameter. 1 is the same. 2 is for dynamic indexing on array of cbuffers.
   uav/srv/sampler don't have 2 is because all the use of them is on builtin methods. Resource on methods is scalar.
   createHandle function will have metadata to save the resource information like class/kind/type/...

2. Added 2 more passes DxilLegalizeResourceUsePass DxilLegalizeStaticResourceUsePass to remove load/store on local/static resource.
   Also make sure HL createHandle don't have phi operand.

3. For DxilGenerationPass,  Dxil createHandle will be generated after GenerateDxilOperations.
   And HLObjectOperationLowerHelper now get RK/RC from MetadataAsValue argument of HL createHandle.
2017-03-28 18:43:59 -07:00