ILGPU  0.9.0
ILGPU.IR.BasicBlock.Builder Class Reference

Represents a basic block builder. More...

Inheritance diagram for ILGPU.IR.BasicBlock.Builder:
ILGPU.IR.Construction.IRBuilder ILGPU.IR.IDumpable ILGPU.IR.Types.IIRTypeContext ILGPU.IR.ILocation

Public Member Functions

void SetupInsertPosition (ValueEntry valueEntry)
 Sets the insert position to the index stored in the given value entry. More...
 
void SetupInsertPositionToEnd ()
 Sets the insert position to the end of the current value list. More...
 
void SetupInsertPosition (Value value)
 Sets the insert position to the index stored in the given value entry. More...
 
void InsertAtBeginning (Value value)
 Inserts the given value at the beginning of this block. More...
 
void Add (Value value)
 Adds the given value to this block. More...
 
void Clear ()
 Removes all operations of this block (including the terminator). More...
 
void Remove (Value value)
 Schedules the given value for removal. More...
 
void RemapPhiArguments< TArgumentRemapper > (TArgumentRemapper remapper)
 Updates phi values in the current block to point to the new blocks instead. More...
 
void RemapPhiArguments< TArgumentRemapper > (ReadOnlySpan< BasicBlock > blocks, TArgumentRemapper remapper)
 Updates phi values in the supplied blocks to point to the new blocks instead. More...
 
void UpdatePhiType< TTypeConverter > (PhiValue phiValue, TTypeConverter typeConverter)
 Updates the type of the given phi value. More...
 
Builder SpecializeCall (MethodCall call)
 Specializes a function call. More...
 
Builder SplitBlock (Value splitPoint, bool keepSplitPoint)
 Splits the current block at the given value. More...
 
void MergeBlock (BasicBlock other)
 Merges the given block into the current one. More...
 
void ReplaceWithCall (Value value, Method implementationMethod)
 Replaces the given value with a call to the provided function. More...
 
BasicBlock ToBasicBlock ()
 Implicitly converts the current builder into its associated basic block. More...
 
void Dump (TextWriter textWriter)
 Dumps the underlying method to the given text writer. More...
 
Enumerator GetEnumerator ()
 Returns a value enumerator. More...
 
- Public Member Functions inherited from ILGPU.IR.Construction.IRBuilder
ValueReference CreateArithmetic (Location location, Value node, UnaryArithmeticKind kind)
 Creates a unary arithmetic operation. More...
 
ValueReference CreateArithmetic (Location location, Value node, UnaryArithmeticKind kind, ArithmeticFlags flags)
 Creates a unary arithmetic operation. More...
 
ValueReference CreateArithmetic (Location location, Value left, Value right, BinaryArithmeticKind kind)
 Creates a binary arithmetic operation. More...
 
ValueReference CreateArithmetic (Location location, Value left, Value right, BinaryArithmeticKind kind, ArithmeticFlags flags)
 Creates a binary arithmetic operation. More...
 
ValueReference CreateArithmetic (Location location, Value first, Value second, Value third, TernaryArithmeticKind kind)
 Creates a ternary arithmetic operation. More...
 
ValueReference CreateArithmetic (Location location, Value first, Value second, Value third, TernaryArithmeticKind kind, ArithmeticFlags flags)
 Creates a ternary arithmetic operation. More...
 
ValueReference CreateArray (Location location, TypeNode elementType, int dimensions, Value extent)
 Creates a new array value. More...
 
ValueReference CreateArray (Location location, ArrayType type, Value extent)
 Creates a new array value. More...
 
ValueReference CreateGetArrayExtent (Location location, Value arrayValue)
 Creates an operation to extract the extent from an array value. More...
 
ValueReference CreateGetArrayElement (Location location, Value arrayValue, Value index)
 Creates a load operation of an array element. More...
 
ValueReference CreateSetArrayElement (Location location, Value arrayValue, Value index, Value value)
 Creates a store operation of an array element. More...
 
ValueReference CreateGetArrayLength (Location location, Value arrayValue)
 Creates a value reference that represents an array length. More...
 
MemoryValue CreateAtomic (Location location, Value target, Value value, AtomicKind kind, AtomicFlags flags)
 Creates a new atomic operation. More...
 
MemoryValue CreateAtomicCAS (Location location, Value target, Value value, Value compareValue, AtomicFlags flags)
 Creates a new atomic compare-and-swap operation More...
 
ValueReference CreateIntAsPointerCast (Location location, Value node)
 Creates a cast operation that casts an integer value to a raw pointer. More...
 
ValueReference CreatePointerCast (Location location, Value node, TypeNode targetElementType)
 Creates a cast operation that casts the element type of a pointer but does not change its address space. More...
 
ValueReference CreateAddressSpaceCast (Location location, Value node, MemoryAddressSpace targetAddressSpace)
 Creates an address-space cast. More...
 
ValueReference CreateViewCast (Location location, Value node, TypeNode targetElementType)
 Creates a view cast. More...
 
ValueReference CreateFloatAsIntCast (Location location, Value node)
 Creates a float as int reinterpret bit cast. More...
 
ValueReference CreateIntAsFloatCast (Location location, Value node)
 Creates an int as float reinterpret bit cast. More...
 
ValueReference CreateCompare (Location location, Value left, Value right, CompareKind kind)
 Creates a compare operation. More...
 
ValueReference CreateCompare (Location location, Value left, Value right, CompareKind kind, CompareFlags flags)
 Creates a compare operation. More...
 
ValueReference CreatePredicate (Location location, Value conditionOrValue, ref ValueList values)
 Creates a conditional predicate. More...
 
ValueReference CreateIfPredicate (Location location, Value condition, Value trueValue, Value falseValue)
 Creates a conditional if predicate. More...
 
SwitchPredicate.Builder CreateSwitchPredicate (Location location, Value condition)
 Creates a conditional switch predicate. More...
 
SwitchPredicate.Builder CreateSwitchPredicate (Location location, Value condition, int capacity)
 Creates a conditional switch predicate. More...
 
ValueReference CreateConvertToInt32 (Location location, Value node)
 Creates a convert operation to a 32bit integer. More...
 
ValueReference CreateConvertToInt64 (Location location, Value node)
 Creates a convert operation to a 64bit integer. More...
 
ValueReference CreateConvert (Location location, Value node, BasicValueType basicValueType)
 Creates a convert operation. More...
 
ValueReference CreateConvert (Location location, Value node, TypeNode targetType)
 Creates a convert operation. More...
 
ValueReference CreateConvert (Location location, Value node, TypeNode targetType, ConvertFlags flags)
 Creates a convert operation. More...
 
ValueReference CreateDebug (Location location, DebugKind kind, Value message)
 Creates a new failed debug assertion. More...
 
string FormatErrorMessage (string message)
 Formats an error message to include specific exception information. More...
 
ValueReference CreateAcceleratorTypeValue (Location location)
 Creates a node that represents an Accelerator.CurrentType property. More...
 
ValueReference CreateWarpSizeValue (Location location)
 Creates a node that represents a Warp.WarpSize property. More...
 
ValueReference CreateLaneIdxValue (Location location)
 Creates a node that represents a Warp.LaneIdx property. More...
 
ValueReference CreateGridIndexValue (Location location, DeviceConstantDimension3D dimension)
 Creates a node that represents a Grid.Index property. More...
 
ValueReference CreateGroupIndexValue (Location location, DeviceConstantDimension3D dimension)
 Creates a node that represents a Group.Index property. More...
 
ValueReference CreateGridDimensionValue (Location location, DeviceConstantDimension3D dimension)
 Creates a node that represents a Grid.Dimension property. More...
 
ValueReference CreateGroupDimensionValue (Location location, DeviceConstantDimension3D dimension)
 Creates a node that represents of a Group.Dimension property. More...
 
ValueReference CreateSizeOf (Location location, TypeNode type)
 Creates a node that represents the native size of the given type. More...
 
ValueReference CreateLongSizeOf (Location location, TypeNode type)
 Creates a node that represents the native size of the given type. More...
 
ValueReference CreateOffsetOf (Location location, TypeNode type, int fieldIndex)
 Creates a node that represents the native offset of the specified field index. More...
 
ValueReference CreateUndefined ()
 Creates a node that represents an undefined value. More...
 
ValueReference CreateRuntimeHandle (Location location, object handle)
 Creates a node that represents a managed runtime handle. More...
 
ValueReference CreateIndex (Location location, ValueReference dimension)
 Creates a new index structure instance. More...
 
ValueReference CreateAlloca (Location location, TypeNode type, MemoryAddressSpace addressSpace)
 Creates a local allocation. More...
 
ValueReference CreateStaticAllocaArray (Location location, Value arrayLength, TypeNode type, MemoryAddressSpace addressSpace)
 Creates an array based local allocation. More...
 
ValueReference CreateDynamicAllocaArray (Location location, TypeNode type, MemoryAddressSpace addressSpace)
 Creates a dynamic local memory allocation. More...
 
ValueReference CreateLoad (Location location, Value source)
 Creates a load operation. More...
 
ValueReference CreateStore (Location location, Value target, Value value)
 Creates a store operation. More...
 
ValueReference CreateMemoryBarrier (Location location, MemoryBarrierKind kind)
 Creates a memory barrier. More...
 
ValueReference CreateSubViewValue (Location location, Value source, Value offset, Value length)
 Computes a new sub view from a given view. More...
 
ValueReference CreateLoadElementAddress (Location location, Value source, Value elementIndex)
 Computes the address of a single element in the scope of a view or a pointer. More...
 
ValueReference CreateLoadFieldAddress (Location location, Value source, FieldSpan fieldSpan)
 Computes the address of a single field. More...
 
MethodCall.Builder CreateCall (Location location, Method target)
 Creates a new call node builder. More...
 
PhiValue.Builder CreatePhi (Location location, TypeNode type)
 Creates a new phi node builder. More...
 
PhiValue.Builder CreatePhi (Location location, TypeNode type, int capacity)
 Creates a new phi node builder. More...
 
Method DeclareMethod (in MethodDeclaration declaration, out bool created)
 Declares a method. More...
 
ValueReference CreateObjectValue (Location location, object instance)
 Creates a new object value. More...
 
StructureValue.Builder CreateStructure (Location location, StructureType structureType)
 Creates a new structure instance builder. More...
 
StructureValue.DynamicBuilder CreateDynamicStructure (Location location)
 Creates a new dynamic structure instance builder. More...
 
StructureValue.DynamicBuilder CreateDynamicStructure (Location location, int capacity)
 Creates a new dynamic structure instance builder. More...
 
ValueReference CreateDynamicStructure (Location location, ref ValueList values)
 Creates a new dynamic structure instance. More...
 
ValueReference CreateDynamicStructure (Location location, ValueReference item1, ValueReference item2)
 Creates a new dynamic structure instance. More...
 
ValueReference CreateDynamicStructure (Location location, ValueReference item1, ValueReference item2, ValueReference item3)
 Creates a new dynamic structure instance. More...
 
ValueReference CreateDynamicStructure< TList > (Location location, TList values)
 Creates a new dynamic structure instance. More...
 
ValueReference CreateGetField (Location location, Value objectValue, FieldSpan fieldSpan)
 Creates a load operation of an object field. More...
 
ValueReference CreateSetField (Location location, Value objectValue, FieldSpan fieldSpan, Value value)
 Creates a store operation of an object field using the given field access. More...
 
TerminatorValue CreateReturn (Location location)
 Creates a new return terminator. More...
 
TerminatorValue CreateReturn (Location location, Value returnValue)
 Creates a new return terminator. More...
 
Branch CreateBranch (Location location, BasicBlock target)
 Creates a new unconditional branch. More...
 
Branch CreateIfBranch (Location location, Value condition, BasicBlock trueTarget, BasicBlock falseTarget)
 Creates a new conditional branch. More...
 
SwitchBranch.Builder CreateSwitchBranch (Location location, Value value)
 Creates a switch terminator builder. More...
 
SwitchBranch.Builder CreateSwitchBranch (Location location, Value value, int capacity)
 Creates a switch terminator builder. More...
 
BuilderTerminator.Builder CreateBuilderTerminator (int capacity)
 Creates a temporary builder terminator. More...
 
BuilderTerminator CreateBuilderTerminator (ref BlockList targets)
 Creates a temporary builder terminator. More...
 
MemoryValue CreateBarrier (Location location, Value predicate, PredicateBarrierKind kind)
 Creates a new predicated barrier. More...
 
MemoryValue CreateBarrier (Location location, BarrierKind kind)
 Creates a new barrier. More...
 
ValueReference CreateBroadcast (Location location, Value variable, Value origin, BroadcastKind kind)
 Creates a new broadcast operation. More...
 
ValueReference CreateShuffle (Location location, Value variable, Value origin, ShuffleKind kind)
 Creates a new shuffle operation. More...
 
ValueReference CreateShuffle (Location location, Value variable, Value origin, Value width, ShuffleKind kind)
 Creates a new sub-warp shuffle operation that operates on sub-groups of a warp. More...
 
PrimitiveType GetPrimitiveType (BasicValueType basicValueType)
 Creates a primitive type. More...
 
TypeNode GetIndexType (int dimension)
 Creates an intrinsic index type. More...
 
PointerType CreatePointerType (TypeNode elementType, MemoryAddressSpace addressSpace)
 Creates a pointer type. More...
 
ViewType CreateViewType (TypeNode elementType, MemoryAddressSpace addressSpace)
 Creates a view type. More...
 
ArrayType CreateArrayType (TypeNode elementType, int dimension)
 Creates a new array type. More...
 
StructureType.Builder CreateStructureType (int capacity)
 Creates a new structure type builder with the given capacity. More...
 
TypeNode CreateType (Type type)
 Creates a new type based on a type from the .Net world. More...
 
TypeNode CreateType (Type type, MemoryAddressSpace addressSpace)
 Creates a new type based on a type from the .Net world. More...
 
AddressSpaceType SpecializeAddressSpaceType (AddressSpaceType addressSpaceType, MemoryAddressSpace addressSpace)
 Specializes the address space of the given AddressSpaceType. More...
 
bool TrySpecializeAddressSpaceType (TypeNode type, MemoryAddressSpace addressSpace, out TypeNode specializedType)
 Tries to specialize a view or a pointer address space. More...
 
ValueReference CreateNull (Location location, TypeNode type)
 Creates a null value for the given type. More...
 
ValueReference CreateEnumValue (Location location, object value)
 Creates a new primitive Enum constant. More...
 
ValueReference CreatePrimitiveValue (Location location, object value)
 Creates a new primitive constant. More...
 
ValueReference CreatePrimitiveValue (Location location, string @string)
 Creates a new string constant. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, bool value)
 Creates a primitive bool value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, sbyte value)
 Creates a primitive sbyte value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, byte value)
 Creates a primitive byte value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, short value)
 Creates a primitive short value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, ushort value)
 Creates a primitive ushort value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, int value)
 Creates a primitive int value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, uint value)
 Creates a primitive uint value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, long value)
 Creates a primitive long value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, ulong value)
 Creates a primitive ulong value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, Half value)
 Creates a primitive Half value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, float value)
 Creates a primitive float value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, double value)
 Creates a primitive double value. More...
 
PrimitiveValue CreatePrimitiveValue (Location location, BasicValueType type, long rawValue)
 Creates a primitive value. More...
 
ValueReference CreateValue (Location location, object value, Type type)
 Creates a generic value. More...
 
ValueReference CreateNewView (Location location, Value pointer, Value length)
 Constructs a new view from a pointer and a length. More...
 
ValueReference CreateGetViewLength (Location location, Value view)
 Creates a node that resolves the length of the given view. More...
 
ValueReference CreateGetViewLongLength (Location location, Value view)
 Creates a node that resolves the length of the given view. More...
 

Static Public Member Functions

static implicit operator BasicBlock (Builder builder)
 Implicitly converts the given builder into its associated basic block. More...
 

Public Attributes

int Count => Values.Count
 Returns the number of attached values. More...
 
- Public Attributes inherited from ILGPU.IR.Construction.IRBuilder
Method Method => BasicBlock.Method
 Returns the parent method. More...
 
VoidType VoidType => Context.VoidType
 Returns the void type. More...
 
StringType StringType => Context.StringType
 Returns the string type. More...
 

Protected Member Functions

override T CreateTerminator< T > (T node)
 
override PhiValue CreatePhiValue (PhiValue phiValue)
 
override T Append< T > (T node)
 
override void Dispose (bool disposing)
 
- Protected Member Functions inherited from ILGPU.IR.Construction.IRBuilder
 IRBuilder (BasicBlock basicBlock)
 Constructs a new IR builder. More...
 

Properties

Method.Builder MethodBuilder [get]
 Returns the parent function builder. More...
 
TerminatorValue Terminator [get, set]
 Gets or sets the current terminator. More...
 
int InsertPosition [get, set]
 Gets or sets the current insert position for new instructions. More...
 
- Properties inherited from ILGPU.IR.Construction.IRBuilder
IRContext Context [get]
 Returns the associated context. More...
 
BasicBlock BasicBlock [get]
 Returns the associated basic block. More...
 
bool UseConstantPropagation [get]
 True, if the IR builder should use constant propagation. More...
 
- Properties inherited from ILGPU.IR.Types.IIRTypeContext
VoidType VoidType [get]
 Returns the void type. More...
 
StringType StringType [get]
 Returns the memory type. More...
 

Detailed Description

Represents a basic block builder.

Member Function Documentation

void ILGPU.IR.BasicBlock.Builder.Add ( Value  value)

Adds the given value to this block.

Parameters
valueThe value to add.
override T ILGPU.IR.BasicBlock.Builder.Append< T > ( node)
protectedvirtual
void ILGPU.IR.BasicBlock.Builder.Clear ( )

Removes all operations of this block (including the terminator).

override PhiValue ILGPU.IR.BasicBlock.Builder.CreatePhiValue ( PhiValue  phiValue)
protectedvirtual
override T ILGPU.IR.BasicBlock.Builder.CreateTerminator< T > ( node)
protectedvirtual
override void ILGPU.IR.BasicBlock.Builder.Dispose ( bool  disposing)
protected

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

Dumps the underlying method to the given text writer.

Parameters
textWriterThe text writer.

Implements ILGPU.IR.IDumpable.

Enumerator ILGPU.IR.BasicBlock.Builder.GetEnumerator ( )

Returns a value enumerator.

Returns
The resolved enumerator.
void ILGPU.IR.BasicBlock.Builder.InsertAtBeginning ( Value  value)

Inserts the given value at the beginning of this block.

Parameters
valueThe value to add.
void ILGPU.IR.BasicBlock.Builder.MergeBlock ( BasicBlock  other)

Merges the given block into the current one.

Parameters
otherThe other block to merge.
static implicit ILGPU.IR.BasicBlock.Builder.operator BasicBlock ( Builder  builder)
static

Implicitly converts the given builder into its associated basic block.

Parameters
builderThe builder to convert.
void ILGPU.IR.BasicBlock.Builder.RemapPhiArguments< TArgumentRemapper > ( TArgumentRemapper  remapper)

Updates phi values in the current block to point to the new blocks instead.

Template Parameters
TArgumentRemapperThe argument mapper type.
Parameters
remapperThe remapper to use.
Type Constraints
TArgumentRemapper :PhiValue.IArgumentRemapper 
void ILGPU.IR.BasicBlock.Builder.RemapPhiArguments< TArgumentRemapper > ( ReadOnlySpan< BasicBlock blocks,
TArgumentRemapper  remapper 
)

Updates phi values in the supplied blocks to point to the new blocks instead.

Template Parameters
TArgumentRemapperThe argument mapper type.
Parameters
blocksThe blocks containing phi values to be updated.
remapperThe remapper to use.
Type Constraints
TArgumentRemapper :PhiValue.IArgumentRemapper 
void ILGPU.IR.BasicBlock.Builder.Remove ( Value  value)

Schedules the given value for removal.

Parameters
valueThe value to remove.
void ILGPU.IR.BasicBlock.Builder.ReplaceWithCall ( Value  value,
Method  implementationMethod 
)

Replaces the given value with a call to the provided function.

Parameters
valueThe value to replace.
implementationMethodThe target implementation method.
void ILGPU.IR.BasicBlock.Builder.SetupInsertPosition ( ValueEntry  valueEntry)

Sets the insert position to the index stored in the given value entry.

Parameters
valueEntryThe value entry.
void ILGPU.IR.BasicBlock.Builder.SetupInsertPosition ( Value  value)

Sets the insert position to the index stored in the given value entry.

Parameters
valueThe value entry.
void ILGPU.IR.BasicBlock.Builder.SetupInsertPositionToEnd ( )

Sets the insert position to the end of the current value list.

Builder ILGPU.IR.BasicBlock.Builder.SpecializeCall ( MethodCall  call)

Specializes a function call.

Parameters
callThe call to specialize.
Returns
The created target block.
Builder ILGPU.IR.BasicBlock.Builder.SplitBlock ( Value  splitPoint,
bool  keepSplitPoint 
)

Splits the current block at the given value.

Parameters
splitPointThe split point.
keepSplitPointTrue, if you want to keep the split point.
Returns
The created temporary block.
BasicBlock ILGPU.IR.BasicBlock.Builder.ToBasicBlock ( )

Implicitly converts the current builder into its associated basic block.

void ILGPU.IR.BasicBlock.Builder.UpdatePhiType< TTypeConverter > ( PhiValue  phiValue,
TTypeConverter  typeConverter 
)

Updates the type of the given phi value.

Template Parameters
TTypeConverterThe type converter.
Parameters
phiValueThe phi value.
typeConverterThe type converter instance.
Type Constraints
TTypeConverter :ITypeConverter<TypeNode> 
TTypeConverter :phiValue.UpdateType 
TTypeConverter :Context 
TTypeConverter :typeConverter 

Member Data Documentation

int ILGPU.IR.BasicBlock.Builder.Count => Values.Count

Returns the number of attached values.

Property Documentation

int ILGPU.IR.BasicBlock.Builder.InsertPosition
getset

Gets or sets the current insert position for new instructions.

Method.Builder ILGPU.IR.BasicBlock.Builder.MethodBuilder
get

Returns the parent function builder.

TerminatorValue ILGPU.IR.BasicBlock.Builder.Terminator
getset

Gets or sets the current terminator.


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