ILGPU  0.9.0
ILGPU.IR.Method.Builder Class Reference

A builder to build methods. More...

Inheritance diagram for ILGPU.IR.Method.Builder:
ILGPU.Util.DisposeBase ILGPU.IR.IMethodMappingObject ILGPU.IR.ILocation ILGPU.IR.IDumpable

Public Member Functions

void ScheduleControlFlowUpdate ()
 Schedules control-flow updates. More...
 
void ScheduleControlFlowUpdate (TerminatorValue oldTerminator, TerminatorValue newTerminator)
 Schedules control-flow updates if the successor relation has been changed by setting a new terminator. More...
 
void AcceptControlFlowUpdates (bool accept)
 Accepts or rejects control-flow updates in case of control-flow changes. More...
 
void AssertNoControlFlowUpdate ()
 Asserts that no control-flow update has happened and the predecessor and successor relations are still up to date. More...
 
string FormatErrorMessage (string message)
 Formats an error message to include the current debug information. More...
 
void UpdateReturnType< TTypeConverter > (TTypeConverter typeConverter)
 Converts the return type. More...
 
void UpdateParameterTypes< TTypeConverter > (TTypeConverter typeConverter)
 Converts all parameter types. More...
 
IRRebuilder CreateRebuilder< TMode > (ParameterMapping parameterMapping, in BasicBlockCollection< ReversePostOrder, Forwards > blocks)
 Creates a new rebuilder that works on the given scope. More...
 
IRRebuilder CreateRebuilder< TMode > (ParameterMapping parameterMapping, MethodMapping methodMapping, in BasicBlockCollection< ReversePostOrder, Forwards > blocks)
 Creates a new rebuilder that works on the given scope. More...
 
Parameter AddParameter (TypeNode type)
 Adds a new parameter to the encapsulated function. More...
 
Parameter AddParameter (TypeNode type, string name)
 Adds a new parameter to the encapsulated function. More...
 
Parameter InsertParameter (TypeNode type)
 Inserts a new parameter to the encapsulated function at the beginning. More...
 
Parameter InsertParameter (TypeNode type, string name)
 Inserts a new parameter to the encapsulated function at the beginning. More...
 
BasicBlock.Builder CreateBasicBlock (Location location)
 Creates a new basic block. More...
 
BasicBlock.Builder CreateBasicBlock (Location location, string name)
 Creates a new basic block. More...
 
Method DeclareMethod (MethodBase methodBase, out bool created)
 Declares a method. More...
 
Method DeclareMethod (in MethodDeclaration declaration, out bool created)
 Declares a method. More...
 
BasicBlockCollection< TOrder, ForwardsComputeBlockCollection< TOrder > ()
 Computes an updated block collection using the latest terminator information. More...
 
void Dump (TextWriter textWriter)
 Dumps the underlying method to the given text writer. More...
 
void EnsureUniqueExitBlock ()
 Ensures that there is only one exit block. More...
 
override string ToString ()
 Returns the string representation of the underlying function. More...
 
- Public Member Functions inherited from ILGPU.Util.DisposeBase
void Dispose ()
 Triggers the 'dispose' functionality of this object. More...
 

Public Attributes

IRContext Context => Method.Context
 Returns the associated IR context. More...
 
Location Location => Method.Location
 Returns the location of the underlying method. More...
 
BasicBlock.Builder EntryBlockBuilder => this[EntryBlock]
 Returns the builder of the entry block. More...
 
MethodHandle Handle => Method.Handle
 Returns the associated function handle. More...
 
MethodBase Source => Method.Source
 Returns the original source method (may be null). More...
 
BasicBlockCollection< ReversePostOrder, ForwardsSourceBlocks
 Returns all blocks of the source method. More...
 
Parameter this[int index] => parameters[index]
 Returns the parameter with the given index. More...
 
int NumParams => parameters.Count
 Returns the number of parameters. More...
 

Protected Member Functions

override void Dispose (bool disposing)
 

Properties

Method Method [get]
 Returns the associated method. More...
 
BasicBlock EntryBlock [get]
 Gets the current entry block. More...
 
BasicBlock.Builder this[BasicBlock basicBlock] [get]
 Returns the associated basic block builder. More...
 
- Properties inherited from ILGPU.IR.IMethodMappingObject
MethodHandle Handle [get]
 Returns the associated function handle. More...
 
MethodBase Source [get]
 Returns the original source method (may be null). More...
 

Detailed Description

A builder to build methods.

Member Function Documentation

void ILGPU.IR.Method.Builder.AcceptControlFlowUpdates ( bool  accept)

Accepts or rejects control-flow updates in case of control-flow changes.

Parameters
acceptTrue, if all changes will be accepted.

This operation is only available in debug mode.

Parameter ILGPU.IR.Method.Builder.AddParameter ( TypeNode  type)

Adds a new parameter to the encapsulated function.

Parameters
typeThe parameter type.
Returns
The created parameter.
Parameter ILGPU.IR.Method.Builder.AddParameter ( TypeNode  type,
string  name 
)

Adds a new parameter to the encapsulated function.

Parameters
typeThe parameter type.
nameThe parameter name (for debugging purposes).
Returns
The created parameter.
void ILGPU.IR.Method.Builder.AssertNoControlFlowUpdate ( )

Asserts that no control-flow update has happened and the predecessor and successor relations are still up to date.

This operation is only available in debug mode.

BasicBlockCollection<TOrder, Forwards> ILGPU.IR.Method.Builder.ComputeBlockCollection< TOrder > ( )

Computes an updated block collection using the latest terminator information.

Template Parameters
TOrderThe collection order.
Returns
The newly ordered collection.
Type Constraints
TOrder :struct 
TOrder :ITraversalOrder 
BasicBlock.Builder ILGPU.IR.Method.Builder.CreateBasicBlock ( Location  location)

Creates a new basic block.

Parameters
locationThe current location.
Returns
The created basic block.
BasicBlock.Builder ILGPU.IR.Method.Builder.CreateBasicBlock ( Location  location,
string  name 
)

Creates a new basic block.

Parameters
locationThe current location.
nameThe block name.
Returns
The created basic block.
IRRebuilder ILGPU.IR.Method.Builder.CreateRebuilder< TMode > ( ParameterMapping  parameterMapping,
in BasicBlockCollection< ReversePostOrder, Forwards blocks 
)

Creates a new rebuilder that works on the given scope.

Template Parameters
TModeThe rebuilder mode.
Parameters
parameterMappingThe target value of every parameter.
blocksThe block collection.
Returns
The created rebuilder.
Type Constraints
TMode :IRRebuilder.IMode 
TMode :CreateRebuilder<TMode> 
TMode :parameterMapping 
TMode :default 
TMode :blocks 
IRRebuilder ILGPU.IR.Method.Builder.CreateRebuilder< TMode > ( ParameterMapping  parameterMapping,
MethodMapping  methodMapping,
in BasicBlockCollection< ReversePostOrder, Forwards blocks 
)

Creates a new rebuilder that works on the given scope.

Template Parameters
TModeThe rebuilder mode.
Parameters
parameterMappingThe target value of every parameter.
methodMappingThe method mapping.
blocksThe block collection.
Returns
The created rebuilder.
Type Constraints
TMode :IRRebuilder.IMode 
TMode :IRRebuilder.Create<TMode> 
TMode :this 
TMode :parameterMapping 
TMode :methodMapping 
TMode :blocks 
Method ILGPU.IR.Method.Builder.DeclareMethod ( MethodBase  methodBase,
out bool  created 
)

Declares a method.

Parameters
methodBaseThe method base.
createdTrue, if the method has been created.
Returns
The declared method.
Method ILGPU.IR.Method.Builder.DeclareMethod ( in MethodDeclaration  declaration,
out bool  created 
)

Declares a method.

Parameters
declarationThe method declaration.
createdTrue, if the method has been created.
Returns
The declared method.
override void ILGPU.IR.Method.Builder.Dispose ( bool  disposing)
protectedvirtual

Reimplemented from ILGPU.Util.DisposeBase.

void ILGPU.IR.Method.Builder.Dump ( TextWriter  textWriter)

Dumps the underlying method to the given text writer.

Parameters
textWriterThe text writer.

Implements ILGPU.IR.IDumpable.

void ILGPU.IR.Method.Builder.EnsureUniqueExitBlock ( )

Ensures that there is only one exit block.

CAUTION: This function changes the control flow.

string ILGPU.IR.Method.Builder.FormatErrorMessage ( string  message)

Formats an error message to include the current debug information.

Implements ILGPU.IR.ILocation.

Parameter ILGPU.IR.Method.Builder.InsertParameter ( TypeNode  type)

Inserts a new parameter to the encapsulated function at the beginning.

Parameters
typeThe parameter type.
Returns
The created parameter.
Parameter ILGPU.IR.Method.Builder.InsertParameter ( TypeNode  type,
string  name 
)

Inserts a new parameter to the encapsulated function at the beginning.

Parameters
typeThe parameter type.
nameThe parameter name (for debugging purposes).
Returns
The created parameter.
void ILGPU.IR.Method.Builder.ScheduleControlFlowUpdate ( )

Schedules control-flow updates.

void ILGPU.IR.Method.Builder.ScheduleControlFlowUpdate ( TerminatorValue  oldTerminator,
TerminatorValue  newTerminator 
)

Schedules control-flow updates if the successor relation has been changed by setting a new terminator.

override string ILGPU.IR.Method.Builder.ToString ( )

Returns the string representation of the underlying function.

Returns
The string representation of the underlying function.
void ILGPU.IR.Method.Builder.UpdateParameterTypes< TTypeConverter > ( TTypeConverter  typeConverter)

Converts all parameter types.

Template Parameters
TTypeConverterThe type converter.
Parameters
typeConverterThe type converter instance.
Type Constraints
TTypeConverter :ITypeConverter<TypeNode> 
void ILGPU.IR.Method.Builder.UpdateReturnType< TTypeConverter > ( TTypeConverter  typeConverter)

Converts the return type.

Template Parameters
TTypeConverterThe type converter.
Parameters
typeConverterThe type converter instance.
Type Constraints
TTypeConverter :ITypeConverter<TypeNode> 

Member Data Documentation

IRContext ILGPU.IR.Method.Builder.Context => Method.Context

Returns the associated IR context.

BasicBlock.Builder ILGPU.IR.Method.Builder.EntryBlockBuilder => this[EntryBlock]

Returns the builder of the entry block.

MethodHandle ILGPU.IR.Method.Builder.Handle => Method.Handle

Returns the associated function handle.

Location ILGPU.IR.Method.Builder.Location => Method.Location

Returns the location of the underlying method.

int ILGPU.IR.Method.Builder.NumParams => parameters.Count

Returns the number of parameters.

MethodBase ILGPU.IR.Method.Builder.Source => Method.Source

Returns the original source method (may be null).

BasicBlockCollection<ReversePostOrder, Forwards> ILGPU.IR.Method.Builder.SourceBlocks
Initial value:

Returns all blocks of the source method.

Parameter ILGPU.IR.Method.Builder.this[int index] => parameters[index]

Returns the parameter with the given index.

Parameters
indexThe parameter index.
Returns
The resolved parameter.

Property Documentation

BasicBlock ILGPU.IR.Method.Builder.EntryBlock
get

Gets the current entry block.

Method ILGPU.IR.Method.Builder.Method
get

Returns the associated method.

BasicBlock.Builder ILGPU.IR.Method.Builder.this[BasicBlock basicBlock]
get

Returns the associated basic block builder.

Parameters
basicBlockThe basic block to resolve the builder for.
Returns
The resolved basic block builder.

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