Click or drag to resize
Llvm.NET LogoValueExtensionsRegisterNameT Method

[This is preliminary documentation and is subject to change.]

Sets the virtual register name for a value

Namespace:  Llvm.NET.Values
Assembly:  Llvm.NET (in Llvm.NET.dll) Version: 3.8.6158
Syntax
C#
public static T RegisterName<T>(
	this T value,
	string name
)
where T : Value

Parameters

value
Type: T
Value to set register name for
name
Type: SystemString
Name for the virtual register the value represents

Type Parameters

T
Type of the value to set the name for

Return Value

Type: T

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type . When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks

Technically speaking only an Instruction can have register name information. However, since LLVM will perform constant folding in the InstructionBuilder it almost all of the methods in InstructionBuilder return a Value rather than an more specific Instruction. Thus, without this extension method here, code would need to know ahead of time that an actual instruction would be produced then cast the result to an Instruction and then set the debug location. This makes the code rather ugly and tedious to manage. Placing this as a generic extension method ensures that the return type matches the original and no additional casting is needed, which would defeat the purpose of doing this. For Value types that are not instructions this does nothing. This allows for a simpler fluent style of programming where the actual type is retained even in cases where an InstructionBuilder method will always return an actual instruction.

Since the Name property is available on all Values this is slightly redundant. It is useful for maintaining the fluent style of coding along with expressing intent more clearly. (e.g. using this makes it expressly clear that the intent is to set the virtual register name and not the name of a local variable etc...) Using the fluent style allows a significant reduction in the number of overloaded methods in InstructionBuilder to account for all variations with or without a name.

See Also