ILGPU  0.9.0
ILGPU.Backends.OpenCL.CLCodeGenerator Class Referenceabstract

Generates OpenCL source code out of IR values. More...

Inheritance diagram for ILGPU.Backends.OpenCL.CLCodeGenerator:
ILGPU.Backends.OpenCL.CLVariableAllocator ILGPU.Backends.IBackendCodeGenerator< StringBuilder > ILGPU.Backends.VariableAllocator ILGPU.Backends.OpenCL.CLFunctionGenerator ILGPU.Backends.OpenCL.CLKernelFunctionGenerator

Classes

struct  GeneratorArgs
 Generation arguments for code-generator construction. More...
 
interface  IParametersSetupLogic
 Represents a parameter logic to setup function parameters. More...
 
struct  MappedParameter
 Represents a parameter that is mapped to OpenCL.
 
struct  StatementEmitter
 Generates OpenCL source statements. More...
 

Public Member Functions

abstract void GenerateHeader (StringBuilder builder)
 Generates a function declaration in PTX code. More...
 
abstract void GenerateCode ()
 Generates PTX code. More...
 
void GenerateConstants (StringBuilder builder)
 Generates PTX constant declarations. More...
 
void Merge (StringBuilder builder)
 
void PushIndent ()
 Increases the current indentation level. More...
 
void PopIndent ()
 Decreases the current indentation level. More...
 
void AppendIndent ()
 Appends the current indentation level to the builder. More...
 
void PushAndAppendIndent ()
 Pushes the current indentation level and appends it to the builder. More...
 
void Declare (Variable target)
 Declares a variable More...
 
void GotoStatement (BasicBlock block)
 Emits a new goto statement to the given target block. More...
 
void Move (Variable target, Variable source)
 Emits a move operation. More...
 
StatementEmitter BeginStatement (Variable target)
 Begins a new statement. More...
 
StatementEmitter BeginStatement (Variable target, FieldAccess?fieldAccess)
 Begins a new statement. More...
 
StatementEmitter BeginStatement (Variable target, FieldAccess fieldAccess)
 Begins a new statement. More...
 
StatementEmitter BeginStatement (Variable target, Variable indexer)
 Begins a new statement. More...
 
StatementEmitter BeginStatement (Variable target, string command)
 Begins a new statement. More...
 
StatementEmitter BeginStatement (string command)
 Begins a new statement. 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.OpenCL.CLVariableAllocator
 CLVariableAllocator (CLTypeGenerator typeGenerator)
 Constructs a new register allocator. More...
 
string GetVariableType (Variable variable)
 Resolves the type name of the given variable. More...
 
- Public Member Functions inherited from ILGPU.Backends.VariableAllocator
Variable Allocate (Value value)
 Allocates a new variable. More...
 
Variable Allocate (Value value, ArithmeticBasicValueType basicValueType)
 Allocates a new variable. More...
 
AllocateAs< T > (Value value)
 Allocates a new variable as type T . More...
 
Variable AllocateType (ArithmeticBasicValueType basicValueType)
 Allocates the given type. More...
 
Variable AllocateType (BasicValueType basicValueType)
 Allocates the given type. More...
 
PointerVariable AllocatePointerType (PointerType pointerType)
 Allocates a pointer type. More...
 
Variable AllocateType (TypeNode typeNode)
 Allocates the given type. More...
 
Variable Load (Value value)
 Loads the given value. More...
 
LoadAs< T > (Value value)
 Loads the given value as variable type T . More...
 
void Bind (Value node, Variable targetVariable)
 Binds the given value to the target variable. 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...
 

Protected Member Functions

void MarkLabel (string label)
 Marks the given label. More...
 
void SetupParameters< TSetupLogic > (StringBuilder targetBuilder, ref TSetupLogic logic, int paramOffset)
 Generates parameter declarations by writing them to the target builder provided. More...
 
Variable DeclareAllocation (in AllocaInformation allocaInfo, MemoryAddressSpace addressSpace)
 Setups a given allocation. More...
 
void SetupAllocations (AllocaKindInformation allocas, MemoryAddressSpace addressSpace)
 Setups local or shared allocations. More...
 
void BindSharedMemoryAllocation (in AllocaKindInformation allocas)
 Binds shared memory allocations. More...
 
void GenerateCodeInternal ()
 Generates code for all basic blocks. More...
 
- Protected Member Functions inherited from ILGPU.Backends.VariableAllocator
 VariableAllocator ()
 Constructs a new variable allocator. More...
 

Static Protected Member Functions

static string GetMethodName (Method method)
 Returns the OpenCL function name for the given function. More...
 
static string GetParameterName (Parameter parameter)
 Returns the OpenCL parameter name for the given parameter. More...
 

Properties

CLBackend Backend [get]
 Returns the associated backend. More...
 
Method Method [get]
 Returns the associated method. More...
 
Allocas Allocas [get]
 Returns all local allocas. More...
 
IntrinsicImplementationProvider< CLIntrinsic.HandlerImplementationProvider [get]
 Returns the current intrinsic provider for code-generation purposes. More...
 
StringBuilder Builder [get]
 Returns the associated string builder. More...
 
int Indent [get]
 The current indentation level. More...
 
- Properties inherited from ILGPU.Backends.OpenCL.CLVariableAllocator
CLTypeGenerator TypeGenerator [get]
 Returns the associated type generator. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ILGPU.Backends.OpenCL.CLVariableAllocator
static Variable GetSharedMemoryAllocationVariable (in AllocaInformation allocaInfo)
 Returns a shared memory allocation variable reference. More...
 
static string GetSharedMemoryAllocationName (in AllocaInformation allocaInfo)
 Returns a unique shared memory allocation name. More...
 

Detailed Description

Generates OpenCL source code out of IR values.

The code needs to be prepared for this code generator.

Member Function Documentation

void ILGPU.Backends.OpenCL.CLCodeGenerator.AppendIndent ( )

Appends the current indentation level to the builder.

StatementEmitter ILGPU.Backends.OpenCL.CLCodeGenerator.BeginStatement ( Variable  target)

Begins a new statement.

Parameters
targetThe target variable to assign to.
Returns
The created statement emitter.
StatementEmitter ILGPU.Backends.OpenCL.CLCodeGenerator.BeginStatement ( Variable  target,
FieldAccess fieldAccess 
)

Begins a new statement.

Parameters
targetThe target variable to assign to.
fieldAccessThe field access to use.
Returns
The created statement emitter.
StatementEmitter ILGPU.Backends.OpenCL.CLCodeGenerator.BeginStatement ( Variable  target,
FieldAccess  fieldAccess 
)

Begins a new statement.

Parameters
targetThe target variable to assign to.
fieldAccessThe field access to use.
Returns
The created statement emitter.
StatementEmitter ILGPU.Backends.OpenCL.CLCodeGenerator.BeginStatement ( Variable  target,
Variable  indexer 
)

Begins a new statement.

Parameters
targetThe target variable to assign to.
indexerThe indexer variable to use.
Returns
The created statement emitter.
StatementEmitter ILGPU.Backends.OpenCL.CLCodeGenerator.BeginStatement ( Variable  target,
string  command 
)

Begins a new statement.

Parameters
targetThe target variable to assign to.
commandThe initial command to emit.
Returns
The created statement emitter.
StatementEmitter ILGPU.Backends.OpenCL.CLCodeGenerator.BeginStatement ( string  command)

Begins a new statement.

Parameters
commandThe initial command to emit.
Returns
The created statement emitter.
void ILGPU.Backends.OpenCL.CLCodeGenerator.BindSharedMemoryAllocation ( in AllocaKindInformation  allocas)
protected

Binds shared memory allocations.

Parameters
allocasAll allocations to bind.
void ILGPU.Backends.OpenCL.CLCodeGenerator.Declare ( Variable  target)

Declares a variable

Parameters
targetThe target variable to declare.
Variable ILGPU.Backends.OpenCL.CLCodeGenerator.DeclareAllocation ( in AllocaInformation  allocaInfo,
MemoryAddressSpace  addressSpace 
)
protected

Setups a given allocation.

Parameters
allocaInfoThe single allocation to declare.
addressSpaceThe target address space.
Returns
The allocated variable.
void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( ReturnTerminator  returnTerminator)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( LoadElementAddress  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( MethodCall  methodCall)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( UnconditionalBranch  branch)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( IfBranch  branch)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( AddressSpaceCast  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( Parameter  parameter)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( PhiValue  phiValue)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( SwitchBranch  branch)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( UnaryArithmeticValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( BinaryArithmeticValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( TernaryArithmeticValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( CompareValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( ConvertValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( PointerCast  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( FloatAsIntCast  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( IntAsFloatCast  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( IfPredicate  predicate)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( SwitchPredicate  predicate)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( GenericAtomic  atomic)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( AtomicCAS  atomicCAS)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( Alloca  alloca)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( MemoryBarrier  barrier)

abstract void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( )
pure virtual
void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( Load  load)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( Store  store)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( LoadFieldAddress  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( PrimitiveValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( StringValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( NullValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( StructureValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( GetField  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( SetField  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( GridIndexValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( GroupIndexValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( GridDimensionValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( GroupDimensionValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( WarpSizeValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( LaneIdxValue  value)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( PredicateBarrier  barrier)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( Barrier  barrier)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( Broadcast  broadcast)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( WarpShuffle  shuffle)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( SubWarpShuffle  shuffle)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCode ( DebugOperation  debug)

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateCodeInternal ( )
protected

Generates code for all basic blocks.

void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateConstants ( StringBuilder  builder)

Generates PTX constant declarations.

Parameters
builderThe target builder.
abstract void ILGPU.Backends.OpenCL.CLCodeGenerator.GenerateHeader ( StringBuilder  builder)
pure virtual

Generates a function declaration in PTX code.

Implemented in ILGPU.Backends.OpenCL.CLKernelFunctionGenerator, and ILGPU.Backends.OpenCL.CLFunctionGenerator.

static string ILGPU.Backends.OpenCL.CLCodeGenerator.GetMethodName ( Method  method)
staticprotected

Returns the OpenCL function name for the given function.

Parameters
methodThe method.
Returns
The resolved OpenCL function name.
static string ILGPU.Backends.OpenCL.CLCodeGenerator.GetParameterName ( Parameter  parameter)
staticprotected

Returns the OpenCL parameter name for the given parameter.

Parameters
parameterThe parameter.
Returns
The resolved OpenCL parameter name.
void ILGPU.Backends.OpenCL.CLCodeGenerator.GotoStatement ( BasicBlock  block)

Emits a new goto statement to the given target block.

Parameters
blockThe target block to jump to.
void ILGPU.Backends.OpenCL.CLCodeGenerator.MarkLabel ( string  label)
protected

Marks the given label.

Parameters
labelThe label to mark.
void ILGPU.Backends.OpenCL.CLCodeGenerator.Merge ( StringBuilder  builder)

void ILGPU.Backends.OpenCL.CLCodeGenerator.Move ( Variable  target,
Variable  source 
)

Emits a move operation.

Parameters
targetThe target variable to assign to.
sourceThe source variable to assign to.
void ILGPU.Backends.OpenCL.CLCodeGenerator.PopIndent ( )

Decreases the current indentation level.

void ILGPU.Backends.OpenCL.CLCodeGenerator.PushAndAppendIndent ( )

Pushes the current indentation level and appends it to the builder.

void ILGPU.Backends.OpenCL.CLCodeGenerator.PushIndent ( )

Increases the current indentation level.

void ILGPU.Backends.OpenCL.CLCodeGenerator.SetupAllocations ( AllocaKindInformation  allocas,
MemoryAddressSpace  addressSpace 
)
protected

Setups local or shared allocations.

Parameters
allocasThe allocations to setup.
addressSpaceThe source address space.local).
void ILGPU.Backends.OpenCL.CLCodeGenerator.SetupParameters< TSetupLogic > ( StringBuilder  targetBuilder,
ref TSetupLogic  logic,
int  paramOffset 
)
protected

Generates parameter declarations by writing them to the target builder provided.

Template Parameters
TSetupLogicThe dependent code-generator type to use.
Parameters
logicThe type generator to use.
targetBuilderThe target builder to use.
paramOffsetThe intrinsic parameter offset.
Type Constraints
TSetupLogic :IParametersSetupLogic 

Property Documentation

Allocas ILGPU.Backends.OpenCL.CLCodeGenerator.Allocas
get

Returns all local allocas.

CLBackend ILGPU.Backends.OpenCL.CLCodeGenerator.Backend
get

Returns the associated backend.

StringBuilder ILGPU.Backends.OpenCL.CLCodeGenerator.Builder
get

Returns the associated string builder.

IntrinsicImplementationProvider<CLIntrinsic.Handler> ILGPU.Backends.OpenCL.CLCodeGenerator.ImplementationProvider
get

Returns the current intrinsic provider for code-generation purposes.

int ILGPU.Backends.OpenCL.CLCodeGenerator.Indent
get

The current indentation level.

Method ILGPU.Backends.OpenCL.CLCodeGenerator.Method
get

Returns the associated method.


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