Exemplo n.º 1
0
		/// <summary>
		///   Replace references to old parameters that have been split with the new local parameters that represents them.
		/// </summary>
		/// <param name="mergedParams"> </param>
		/// <param name="paramsRefMap"> </param>
		internal static void ReplaceSplitParametersReferences( Dictionary<Parameter, Parameter> localParamsMap,
		                                                       Dictionary<Parameter, List<Operand>> paramsRefMap )
		{
			foreach ( var it in localParamsMap )
			{
				Parameter curSrcParam = it.Key;

				if ( paramsRefMap.ContainsKey( curSrcParam ) )
				{
					Parameter dstParameter = it.Value;
					var srcParamRefs = paramsRefMap[ curSrcParam ];

					for ( int i = 0; i < srcParamRefs.Count; i++ )
					{
						Operand srcOperand = srcParamRefs[ i ];
						int dstOpMask;

						if ( srcOperand.Mask == (int)Operand.OpMask.All )
						{
							dstOpMask = GetParameterMaskByType( curSrcParam.Type );
						}
						else
						{
							dstOpMask = srcOperand.Mask;
						}

						//Replace the original source operand with a new operand the reference the new merged parameter
						srcOperand = new Operand( dstParameter, srcOperand.Semantic, dstOpMask, 0 );
					}
				}
			}
		}
Exemplo n.º 2
0
		/// <summary>
		///   Replace references to old parameters with the new merged parameters.
		/// </summary>
		/// <param name="mergedParams"> </param>
		/// <param name="paramsRefMap"> </param>
		internal static void ReplaceParametersReferences( List<MergeParameter> mergedParams,
		                                                  Dictionary<Parameter, List<Operand>> paramsRefMap )
		{
			for ( int i = 0; i < mergedParams.Count; i++ )
			{
				MergeParameter curMergeParameter = mergedParams[ i ];
				int paramBitMaskOffset = 0;

				for ( int j = 0; j < curMergeParameter.SourceParameterCount; j++ )
				{
					Parameter curSrcParam = curMergeParameter.SourceParameter[ j ];

					//Case the source parameter has some references
					if ( paramsRefMap.ContainsKey( curSrcParam ) )
					{
						List<Operand> srcParamRefs = paramsRefMap[ curSrcParam ];
						Parameter dstParameter;

						//Case the source paramter is fully contained within the destination merged parameter.
						if ( curMergeParameter.GetSourceParameterMask( j ) == (int)Operand.OpMask.All )
						{
							dstParameter = curMergeParameter.GetDestinationParameter( (int)Operand.OpSemantic.InOut, i );

							for ( int op = 0; op < srcParamRefs.Count; op++ )
							{
								Operand srcOperand = srcParamRefs[ op ];
								int dstOpMask;

								if ( srcOperand.Mask == (int)Operand.OpMask.All )
								{
									//Case the merged parameter contains only one source - no point in adding special mask.
									if ( curMergeParameter.SourceParameterCount == 1 )
									{
										dstOpMask = (int)Operand.OpMask.All;
									}
									else
									{
										dstOpMask = GetParameterMaskByType( curSrcParam.Type ) << paramBitMaskOffset;
									}
								}
								else
								{
									dstOpMask = srcOperand.Mask << paramBitMaskOffset;
								}
								// Replace the original source operand with a new operand the reference the new merged parameter.						
								srcOperand = new Operand( dstParameter, srcOperand.Semantic, dstOpMask, 0 );
							}
						}
					}

					//Update the bit mask offset
					paramBitMaskOffset += GetParameterFloatCount( curSrcParam.Type );
				}
			}
		}