ILGPU  0.9.0
ILGPU.Backends.PTX.PTXKernelFunctionGenerator Class Reference

Represents a function generator for main kernel functions. More...

Inheritance diagram for ILGPU.Backends.PTX.PTXKernelFunctionGenerator:
ILGPU.Backends.PTX.PTXCodeGenerator ILGPU.Backends.PTX.PTXRegisterAllocator ILGPU.Backends.IBackendCodeGenerator< StringBuilder > ILGPU.Backends.RegisterAllocator< PTXRegisterKind >

Public Member Functions

 PTXKernelFunctionGenerator (in GeneratorArgs args, Method method, Allocas allocas)
 Creates a new PTX kernel generator. More...
 
override void GenerateHeader (StringBuilder builder)
 Generates a function declaration in PTX code. More...
 
override void GenerateCode ()
 Generates PTX code. More...
 
- Public Member Functions inherited from ILGPU.Backends.PTX.PTXCodeGenerator
void GenerateConstants (StringBuilder builder)
 Generates PTX constant declarations. More...
 
void Merge (StringBuilder builder)
 
void EmitComplexCommand< TEmitter > (string command, in TEmitter emitter, params Register[] registers)
 Emits a complex command that might depend on non-primitive registers. More...
 
void EmitComplexCommandWithOffsets< TEmitter > (string command, in TEmitter emitter, Register register, int offset=0)
 A specialized version of EmitComplexCommand<TEmitter>(string, in TEmitter, RegisterAllocator<PTXRegisterKind>.Register[]). This version uses a single register and uses internal ABI-specific offset computations to resolve the correct offset in bytes within a structure. More...
 
void EmitVectorizedCommand< TEmitter > (Value pointerValue, int safeAlignment, string command, in TEmitter emitter, Register register)
 A specialized version of EmitComplexCommand<TEmitter>(string, in TEmitter, RegisterAllocator<PTXRegisterKind>.Register[]). This version uses a single register and uses internal ABI-specific offset computations to resolve the correct offset in bytes within a structure. More...
 
PredicateScope ConvertToPredicateScope (HardwareRegister register)
 Converts the given register to a predicate register scope. More...
 
void ConvertPredicateToValue (PrimitiveRegister register, HardwareRegister targetRegister)
 Converts the given predicate register to a default integer register. More...
 
HardwareRegister ConvertValueToPredicate (HardwareRegister register)
 Converts the given register to a predicate register scope. More...
 
void ConvertValueToPredicate (PrimitiveRegister register, HardwareRegister targetRegister)
 Converts the given register to a predicate value in the target register. More...
 
void EmitIOLoad< TIOEmitter, T > (TIOEmitter emitter, string command, HardwareRegister register, T userState)
 Emits a generic IO load operation. More...
 
void EmitIOStore< TIOEmitter, T > (TIOEmitter emitter, string command, PrimitiveRegister register, T userState)
 Emits a generic IO load operation. More...
 
CommandEmitter BeginCommand (string commandString, PredicateConfiguration?predicate=null)
 Begins a new command. More...
 
void Command (string commandString, PredicateConfiguration?predicate=null)
 Emits the given command. More...
 
void Move (HardwareRegister source, HardwareRegister target, PredicateConfiguration?predicate=null)
 Emits a simple move command. More...
 
CommandEmitter BeginMove (PredicateConfiguration?predicate=null)
 Begins a new move command. More...
 
HardwareRegister MoveFromIntrinsicRegister (PTXRegisterKind registerKind, int dimension=0)
 Allocates a new target register and moves the value of the specified intrinsic register to the target register. More...
 
PrimitiveRegister MoveFromIntrinsicRegister (Value value, PTXRegisterKind registerKind, int dimension=0)
 Allocates a new target register and moves the value of the specified intrinsic register to the target register. More...
 
HardwareRegister EnsureHardwareRegister (PrimitiveRegister register)
 Ensures that the given primitive register is a hardware register. If is a constant register, its value will be moved into a newly allocated hardware register. More...
 
void GenerateCode (ReturnTerminator returnTerminator)
 
void GenerateCode (UnconditionalBranch branch)
 
void GenerateCode (IfBranch branch)
 
void GenerateCode (SwitchBranch branch)
 
void GenerateCode (MethodCall methodCall)
 
void GenerateCode (Parameter parameter)
 
void GenerateCode (PhiValue phiValue)
 
void GenerateCode (UnaryArithmeticValue value)
 
void GenerateCode (BinaryArithmeticValue value)
 
void GenerateCode (TernaryArithmeticValue value)
 
void GenerateCode (CompareValue value)
 
void GenerateCode (ConvertValue value)
 
void GenerateCode (PointerCast value)
 
void GenerateCode (FloatAsIntCast value)
 
void GenerateCode (IntAsFloatCast value)
 
void GenerateCode (IfPredicate predicate)
 
void GenerateCode (SwitchPredicate predicate)
 
void GenerateCode (GenericAtomic atomic)
 
void GenerateCode (AtomicCAS atomicCAS)
 
void GenerateCode (Alloca alloca)
 
void GenerateCode (MemoryBarrier barrier)
 
void GenerateCode (Load load)
 
void GenerateCode (Store store)
 
void GenerateCode (LoadFieldAddress value)
 
void GenerateCode (PrimitiveValue value)
 
void GenerateCode (StringValue value)
 
void GenerateCode (NullValue value)
 
void GenerateCode (StructureValue value)
 
void GenerateCode (GetField value)
 
void GenerateCode (SetField value)
 
void GenerateCode (GridIndexValue value)
 
void GenerateCode (GroupIndexValue value)
 
void GenerateCode (GridDimensionValue value)
 
void GenerateCode (GroupDimensionValue value)
 
void GenerateCode (WarpSizeValue value)
 
void GenerateCode (LaneIdxValue value)
 
void GenerateCode (PredicateBarrier barrier)
 
void GenerateCode (Barrier barrier)
 
void GenerateCode (Broadcast broadcast)
 
void GenerateCode (WarpShuffle shuffle)
 
void GenerateCode (SubWarpShuffle shuffle)
 
void GenerateCode (DebugOperation debug)
 
void GenerateCode (LoadElementAddress value)
 
void GenerateCode (AddressSpaceCast value)
 
- Public Member Functions inherited from ILGPU.Backends.PTX.PTXRegisterAllocator
 PTXRegisterAllocator (PTXBackend backend)
 Constructs a new register allocator. More...
 
HardwareRegister AllocatePlatformRegister (out RegisterDescription description)
 Allocates a platform-specific register and returns the resulting PTX type for the current platform. More...
 
HardwareRegister AllocatePlatformRegister (Value node, out RegisterDescription description)
 Allocates a platform-specific register for the given node and returns the resulting PTX type for the current platform. More...
 
sealed override void FreeRegister (HardwareRegister hardwareRegister)
 Frees the given hardware register. More...
 
HardwareRegister AllocateInt32Register ()
 Allocates a new 32bit integer register. More...
 
sealed override HardwareRegister AllocateRegister (RegisterDescription description)
 Allocates a register that is compatible with the given description. More...
 
- Public Member Functions inherited from ILGPU.Backends.RegisterAllocator< PTXRegisterKind >
HardwareRegister Allocate (Value node, RegisterDescription description)
 Allocates a specific register kind for the given node. More...
 
Register Allocate (Value node)
 Allocates a specific register kind for the given node. More...
 
HardwareRegister AllocateHardware (Value node)
 Allocates a specific register kind for the given node. More...
 
void Bind (Value node, Register targetRegister)
 Binds the given value to the target register. More...
 
Register AllocateType (TypeNode typeNode)
 Allocates a new register recursively More...
 
void Alias (Value node, Value aliasNode)
 Registers a register alias. More...
 
LoadAs< T > (Value node)
 Loads the allocated register of the given node. More...
 
Register Load (Value node)
 Loads the allocated register of the given node. More...
 
PrimitiveRegister LoadPrimitive (Value node)
 Loads the allocated primitive register of the given node. More...
 
HardwareRegister LoadHardware (Value node)
 Loads the allocated primitive register of the given node. More...
 
void Free (Value node)
 Frees the given node. More...
 
- Public Member Functions inherited from ILGPU.Backends.IBackendCodeGenerator< StringBuilder >
void GenerateConstants (TKernelBuilder builder)
 Generates all constant definitions (if any). More...
 
void GenerateHeader (TKernelBuilder builder)
 Generates a header definition (if any). More...
 
void GenerateCode ()
 Generates the actual function code. More...
 
void GenerateCode (MethodCall methodCall)
 Generates code for the given value. More...
 
void GenerateCode (PhiValue phiValue)
 Generates code for the given value. More...
 
void GenerateCode (Parameter parameter)
 Generates code for the given value. More...
 
void GenerateCode (UnaryArithmeticValue value)
 Generates code for the given value. More...
 
void GenerateCode (BinaryArithmeticValue value)
 Generates code for the given value. More...
 
void GenerateCode (TernaryArithmeticValue value)
 Generates code for the given value. More...
 
void GenerateCode (CompareValue value)
 Generates code for the given value. More...
 
void GenerateCode (ConvertValue value)
 Generates code for the given value. More...
 
void GenerateCode (PointerCast value)
 Generates code for the given value. More...
 
void GenerateCode (AddressSpaceCast value)
 Generates code for the given value. More...
 
void GenerateCode (FloatAsIntCast value)
 Generates code for the given value. More...
 
void GenerateCode (IntAsFloatCast value)
 Generates code for the given value. More...
 
void GenerateCode (IfPredicate predicate)
 Generates code for the given value. More...
 
void GenerateCode (SwitchPredicate predicate)
 Generates code for the given value. More...
 
void GenerateCode (GenericAtomic atomic)
 Generates code for the given value. More...
 
void GenerateCode (AtomicCAS atomicCAS)
 Generates code for the given value. More...
 
void GenerateCode (Alloca alloca)
 Generates code for the given value. More...
 
void GenerateCode (MemoryBarrier barrier)
 Generates code for the given value. More...
 
void GenerateCode (Load load)
 Generates code for the given value. More...
 
void GenerateCode (Store store)
 Generates code for the given value. More...
 
void GenerateCode (LoadElementAddress value)
 Generates code for the given value. More...
 
void GenerateCode (LoadFieldAddress value)
 Generates code for the given value. More...
 
void GenerateCode (PrimitiveValue value)
 Generates code for the given value. More...
 
void GenerateCode (StringValue value)
 Generates code for the given value. More...
 
void GenerateCode (NullValue value)
 Generates code for the given value. More...
 
void GenerateCode (StructureValue value)
 Generates code for the given value. More...
 
void GenerateCode (GetField value)
 Generates code for the given value. More...
 
void GenerateCode (SetField value)
 Generates code for the given value. More...
 
void GenerateCode (GridIndexValue value)
 Generates code for the given value. More...
 
void GenerateCode (GroupIndexValue value)
 Generates code for the given value. More...
 
void GenerateCode (GridDimensionValue value)
 Generates code for the given value. More...
 
void GenerateCode (GroupDimensionValue value)
 Generates code for the given value. More...
 
void GenerateCode (WarpSizeValue value)
 Generates code for the given value. More...
 
void GenerateCode (LaneIdxValue value)
 Generates code for the given value. More...
 
void GenerateCode (PredicateBarrier barrier)
 Generates code for the given value. More...
 
void GenerateCode (Barrier barrier)
 Generates code for the given value. More...
 
void GenerateCode (Broadcast broadcast)
 Generates code for the given value. More...
 
void GenerateCode (WarpShuffle shuffle)
 Generates code for the given value. More...
 
void GenerateCode (SubWarpShuffle shuffle)
 Generates code for the given value. More...
 
void GenerateCode (DebugOperation debug)
 Generates code for the given value. More...
 
void GenerateCode (ReturnTerminator returnTerminator)
 Generates code for the given value. More...
 
void GenerateCode (UnconditionalBranch branch)
 Generates code for the given value. More...
 
void GenerateCode (IfBranch branch)
 Generates code for the given value. More...
 
void GenerateCode (SwitchBranch branch)
 Generates code for the given value. More...
 
void Merge (TKernelBuilder builder)
 Merges all changes inside the current code generator into the given builder. More...
 

Properties

EntryPoint EntryPoint [get]
 Returns the associated entry point. More...
 
- Properties inherited from ILGPU.Backends.PTX.PTXCodeGenerator
Method Method [get]
 Returns the associated method. More...
 
Allocas Allocas [get]
 Returns all local allocas. More...
 
PTXArchitecture Architecture [get]
 Returns the currently used PTX architecture. More...
 
PTXDebugInfoGeneratorScope DebugInfoGenerator [get]
 Returns the associated debug information generator. More...
 
IntrinsicImplementationProvider< PTXIntrinsic.HandlerImplementationProvider [get]
 Returns the current intrinsic provider for code-generation purposes. More...
 
bool FastMath [get]
 Returns true if fast math is active. More...
 
bool EnableAssertions [get]
 Returns true if assertions are enabled. More...
 
StringBuilder Builder [get]
 Returns the associated string builder. More...
 
string ReturnParamName [get]
 Returns the name of the return parameter. More...
 
PointerAlignments PointerAlignments [get]
 Returns detailed information about all pointer alignments. More...
 
- Properties inherited from ILGPU.Backends.RegisterAllocator< PTXRegisterKind >
Backend Backend [get]
 Returns the underlying ABI. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ILGPU.Backends.PTX.PTXCodeGenerator
static HardwareRegister GetIntrinsicRegister (PTXRegisterKind registerKind, int dimension=0)
 Resolves the desired hardware register. More...
 
- Static Public Member Functions inherited from ILGPU.Backends.PTX.PTXRegisterAllocator
static PTXRegisterKind GetRegisterKind (BasicValueType basicValueType)
 Returns the associated register kind. More...
 
static BasicValueType ResolveParameterBasicValueType (BasicValueType basicValueType)
 Returns the associated register kind. More...
 
static string GetStringRepresentation (HardwareRegister register)
 Returns the string representation of the given hardware register. More...
 
- Public Attributes inherited from ILGPU.Backends.PTX.PTXCodeGenerator
new PTXBackend Backend => base.Backend as PTXBackend
 Returns the associated backend. More...
 
- Static Public Attributes inherited from ILGPU.Backends.PTX.PTXCodeGenerator
static readonly IEnumerable< PTXInstructionSetSupportedInstructionSets
 The supported PTX instruction sets (in descending order). More...
 
- Protected Member Functions inherited from ILGPU.Backends.PTX.PTXCodeGenerator
void MarkLabel (string label)
 Marks the given label. More...
 
void PrepareCodeGeneration ()
 Prepares the general code generation process. More...
 
void GenerateCodeInternal (int registerOffset)
 Generates code for all basic blocks. More...
 
void SetupAllocations< TCollection > (AllocaKindInformation allocas, string addressSpacePrefix, string namePrefix, TCollection result)
 Setups local or shared allocations. More...
 
void EmitLoadParam (string paramName, Register register)
 Emits a new set of load param instructions with the appropriate configuration. More...
 
void EmitStoreParam (string paramName, Register register)
 Emits a new set of store param instructions with the appropriate configuration. More...
 
void AppendParamDeclaration (StringBuilder targetBuilder, TypeNode paramType, string paramName)
 Appends parameter information. More...
 
- Protected Member Functions inherited from ILGPU.Backends.PTX.PTXRegisterAllocator
RegisterDescription ResolveParameterRegisterDescription (TypeNode type)
 Resolves a register description for the given parameter type. More...
 
sealed override RegisterDescription ResolveRegisterDescription (TypeNode type)
 Resolves a new PTX compatible register description. More...
 
- Protected Member Functions inherited from ILGPU.Backends.RegisterAllocator< PTXRegisterKind >
 RegisterAllocator (Backend backend)
 Constructs a new register allocator. More...
 
abstract RegisterDescription ResolveRegisterDescription (TypeNode type)
 Resolves a register description for the given type. More...
 
- Static Protected Member Functions inherited from ILGPU.Backends.PTX.PTXCodeGenerator
static string GetMethodName (Method method)
 Returns the PTX function name for the given function. More...
 
static string GetParameterName (Parameter parameter)
 Returns the PTX parameter name for the given parameter. More...
 
- Static Protected Member Functions inherited from ILGPU.Backends.PTX.PTXRegisterAllocator
static RegisterDescription ResolveRegisterDescription (BasicValueType basicValueType)
 Resolves a register description for the basic value type. More...
 
- Protected Attributes inherited from ILGPU.Backends.PTX.PTXCodeGenerator
const string DynamicSharedMemoryAllocationName = "__dyn_shared_alloca"
 The name for the globally registered dynamic shared memory alloca (if any). More...
 

Detailed Description

Represents a function generator for main kernel functions.

Constructor & Destructor Documentation

ILGPU.Backends.PTX.PTXKernelFunctionGenerator.PTXKernelFunctionGenerator ( in GeneratorArgs  args,
Method  method,
Allocas  allocas 
)

Creates a new PTX kernel generator.

Parameters
argsThe generation arguments.
methodThe current method.
allocasAll local allocas.

Member Function Documentation

override void ILGPU.Backends.PTX.PTXKernelFunctionGenerator.GenerateCode ( )
virtual

Generates PTX code.

Implements ILGPU.Backends.PTX.PTXCodeGenerator.

override void ILGPU.Backends.PTX.PTXKernelFunctionGenerator.GenerateHeader ( StringBuilder  builder)
virtual

Generates a function declaration in PTX code.

Implements ILGPU.Backends.PTX.PTXCodeGenerator.

Property Documentation

EntryPoint ILGPU.Backends.PTX.PTXKernelFunctionGenerator.EntryPoint
get

Returns the associated entry point.


The documentation for this class was generated from the following file: