private static TypeNode ComputeType(IRContext context, PredicateBarrierKind kind) { if (kind == PredicateBarrierKind.PopCount) { return(context.GetPrimitiveType(BasicValueType.Int32)); } return(context.GetPrimitiveType(BasicValueType.Int1)); }
/// <summary> /// Constructs a new value. /// </summary> /// <param name="context">The current IR context.</param> /// <param name="basicBlock">The parent basic block.</param> internal LaneIdxValue( IRContext context, BasicBlock basicBlock) : base( basicBlock, context.GetPrimitiveType(BasicValueType.Int32)) { }
/// <summary> /// Constructs a new value. /// </summary> /// <param name="context">The current IR context.</param> /// <param name="basicBlock">The parent basic block.</param> internal WarpSizeValue( IRContext context, BasicBlock basicBlock) : base( ValueKind.WarpSize, basicBlock, context.GetPrimitiveType(BasicValueType.Int32)) { }
/// <summary> /// Constructs a new value. /// </summary> /// <param name="context">The current IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="dimension">The device constant dimension.</param> internal DeviceConstantDimensionValue( IRContext context, BasicBlock basicBlock, DeviceConstantDimension3D dimension) : base( basicBlock, context.GetPrimitiveType(BasicValueType.Int32)) { Dimension = dimension; }
/// <summary> /// Constructs a new sizeof value. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="targetType">The target type of the size of computation.</param> internal SizeOfValue( IRContext context, BasicBlock basicBlock, TypeNode targetType) : base( basicBlock, context.GetPrimitiveType(BasicValueType.Int32)) { TargetType = targetType; }
/// <summary> /// Constructs a new primitive constant. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="basicValueType">The basic value type.</param> /// <param name="value">The raw value.</param> internal PrimitiveValue( IRContext context, BasicBlock basicBlock, BasicValueType basicValueType, long value) : base( basicBlock, context.GetPrimitiveType(basicValueType)) { BasicValueType = basicValueType; rawValue = value; }
private static TypeNode ComputeType( IRContext context, ValueReference operand, UnaryArithmeticKind kind) { var type = operand.Type; switch (kind) { case UnaryArithmeticKind.IsInfF: case UnaryArithmeticKind.IsNaNF: type = context.GetPrimitiveType(BasicValueType.Int1); break; } return(type); }
private static TypeNode ComputeType(IRContext context) => context.GetPrimitiveType(BasicValueType.Int32);
public Resolver(Context context, IRContext irContext) : base(irContext) { MathImplementationResolver resolver; using (var phase = context.BeginCodeGeneration(irContext)) { using (var frontendPhase = phase.BeginFrontendCodeGeneration()) { resolver = new MathImplementationResolver( frontendPhase, mathFunction => mathFunction.GetCustomAttribute <PTXMathIntrinsicAttribute>() == null, typeof(XMath), typeof(Resolver)); // Declare debugging functions var deviceAssertFunction = frontendPhase.DeclareMethod( new MethodDeclaration( DebugAssertFailedName, irContext.VoidType, MethodFlags.External)); using (var failedBuilder = deviceAssertFunction.CreateBuilder()) { failedBuilder.AddParameter(irContext.StringType, "message"); failedBuilder.AddParameter(irContext.StringType, "file"); failedBuilder.AddParameter( irContext.GetPrimitiveType(BasicValueType.Int32), "line"); failedBuilder.AddParameter(irContext.StringType, "function"); failedBuilder.AddParameter( irContext.GetPrimitiveType(BasicValueType.Int32), "charSize"); } debugAssertFunction = frontendPhase.DeclareMethod( new MethodDeclaration( WrapperDebugAssertFailedName, irContext.VoidType, MethodFlags.Inline)); using (var assertBuilder = debugAssertFunction.CreateBuilder()) { var messageParam = assertBuilder.AddParameter(irContext.StringType, "message"); var entryBlock = assertBuilder.CreateEntryBlock(); entryBlock.CreateCall( deviceAssertFunction, ImmutableArray.Create( messageParam, entryBlock.CreatePrimitiveValue("Kernel.cs"), entryBlock.CreatePrimitiveValue(0), entryBlock.CreatePrimitiveValue("Kernel"), entryBlock.CreatePrimitiveValue(1))); entryBlock.CreateReturn(); } } } // Perform an initial pass to resolve all PTX-specific intrinsic functions var transformer = Transformer.Create( new TransformerConfiguration(MethodTransformationFlags.None, false), new IntrinsicSpecializer <PTXIntrinsicConfiguration>(new PTXIntrinsicConfiguration( this))); irContext.Transform(transformer); resolver.ApplyTo(this); // Resolve all previously unresolved intrinsic functions /* This is required since the intrinsic implementation resolver does not perform * time-consuming recursive dependency analyses. This is not an issue since * these analyses and recursive passes are not required for default user kernels. * Unfortunately, we need a second pass at this point to ensure that all intrinsic * function declarations have been properly resolved. */ irContext.Transform(transformer); // Optimize the whole module irContext.Optimize(); }