public Value(LLVMValueRef* handle) { if(handle == null) throw new ArgumentNullException("handle"); m_handle = handle; }
public static bool Used(LLVMValueRef* value) { if(value == null) throw new ArgumentNullException("value"); return Native.GetFirstUse(value) != null; }
public static string GetName(LLVMValueRef* value) { if(value == null) throw new ArgumentNullException("value"); IntPtr name = Native.GetValueName(value); if(name == null) return null; return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(name); }
public static int GetUseCount(LLVMValueRef* value) { if(value == null) throw new ArgumentNullException("value"); LLVMUseRef* use = Native.GetFirstUse(value); int count = 0; while(use != null) { count++; use = Native.GetNextUse(use); } return count; }
public Function(string name, LLVMValueRef* handle) { m_name = name; m_handle = handle; m_funcType = Native.GetElementType(Native.TypeOf(handle)); m_returnType = new TypeRef(Native.GetReturnType(m_funcType)); uint paramCount = Native.CountParamTypes(m_funcType); m_paramTypes = new TypeRef[paramCount]; if(paramCount > 0) { IntPtr[] types = new IntPtr[paramCount]; Native.GetParamTypes(m_funcType, types); for(int i = 0; i < paramCount; ++i) { m_paramTypes[i] = new TypeRef((LLVMTypeRef*)types[i]); } } }
internal ConstantPointerNull(LLVMValueRef valueRef) : base(valueRef) { }
private static extern void LLVMSetOperand(LLVMValueRef @User, uint @Index, LLVMValueRef @Val);
public static extern void ViewFunctionCFGOnly(LLVMValueRef* Fn);
/// <summary> /// Emits LLVM IR instructions that test if the type corresponding /// to a type metadata handle is a subtype of another type. /// </summary> /// <param name="subtypeMetadata"> /// A type metadata handle of a potential subtype. /// </param> /// <param name="supertype"> /// A potential supertype. /// </param> /// <param name="module"> /// The LLVM module to generate the instructions in. /// </param> /// <param name="builder"> /// An instruction builder to use for emitting instructions. /// </param> /// <param name="name"> /// A suggested name for the resulting Boolean value. /// </param> /// <returns> /// A Boolean value that is <c>true</c> if the type corresponding /// to <paramref name="subtypeMetadata"/> is a subtype of <paramref name="supertype"/>; /// otherwise, <c>false</c>. /// </returns> public abstract LLVMValueRef EmitIsSubtype( LLVMValueRef subtypeMetadata, IType supertype, ModuleBuilder module, IRBuilder builder, string name);
public static extern LLVMGenericValueRef* RunFunction(LLVMExecutionEngineRef* EE, LLVMValueRef* F, uint NumArgs, System.IntPtr[] Args);
public static extern void AddGlobalMapping(LLVMExecutionEngineRef* EE, LLVMValueRef* Global, System.IntPtr Addr);
protected abstract LLVMValueRef ProcessFloating(MethodCompiler compiler, LLVMValueRef lhs, LLVMValueRef rhs, LLVMBuilderRef builder);
public static extern LLVMValueRef* BuildIsNotNull(LLVMBuilderRef* LLVMBuilderRef, LLVMValueRef* Val, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
public BuiltinFunction(FunctionType type, LLVMValueRef function) : this(type) { this.function = function; }
protected abstract LLVMValueRef ProcessIntegral(MethodCompiler compiler, LLVMValueRef lhs, LLVMValueRef rhs, LLVMBuilderRef builder);
/// <summary> /// Emits instructions that load an object's metadata handle. /// </summary> /// <param name="objectPointer">An object to inspect for its metadata handle.</param> /// <param name="module">The module that defines the metadata-loading instructions.</param> /// <param name="builder">An instruction builder to use for emitting instructions.</param> /// <param name="name">A suggested name for the value that refers to the metadata.</param> /// <returns>A handle to the metadata.</returns> public abstract LLVMValueRef EmitLoadMetadata( LLVMValueRef objectPointer, ModuleBuilder module, IRBuilder builder, string name);
/// <summary> /// Emits instructions that allocate a GC-managed instance of a type. /// </summary> /// <param name="type">A type to instantiate.</param> /// <param name="tailRoom">A number of bytes to allocate after the end of the object.</param> /// <param name="module">The module that defines the object-allocating instructions.</param> /// <param name="builder">An instruction builder to use for emitting instructions.</param> /// <param name="name">A suggested name for the value that refers to the allocated object.</param> /// <returns>A pointer to the allocated object.</returns> public abstract LLVMValueRef EmitAllocObject( IType type, LLVMValueRef tailRoom, ModuleBuilder module, IRBuilder builder, string name);
private static extern int LLVMGetNumOperands(LLVMValueRef @Val);
public static extern LLVMValueRef* BuildVAArg(LLVMBuilderRef* LLVMBuilderRef, LLVMValueRef* List, LLVMTypeRef* Ty, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
/// <summary> /// Initializes new instance of ExpressionEntry /// </summary> /// <param name="kind">Kind of entry</param> /// <param name="name">String representation of entry</param> /// <param name="type">Type if any of entry</param> public ExpressionEntry(StackValueKind kind, string name, LLVMValueRef llvmValue, TypeDesc type = null) : base(kind, type) { Name = name; RawLLVMValue = llvmValue; }
public static extern LLVMValueRef* BuildShuffleVector(LLVMBuilderRef* LLVMBuilderRef, LLVMValueRef* V1, LLVMValueRef* V2, LLVMValueRef* Mask, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
/// <summary> /// Initializes new instance of ExpressionEntry /// </summary> /// <param name="kind">Kind of entry</param> /// <param name="name">String representation of entry</param> /// <param name="type">Type if any of entry</param> public AddressExpressionEntry(StackValueKind kind, string name, LLVMValueRef llvmValue, TypeDesc type = null) : base(kind, name, llvmValue, type) { }
public static extern int RunFunctionPassManager(LLVMPassManagerRef* FPM, LLVMValueRef* F);
internal ConstantVector(LLVMValueRef valueRef) : base(valueRef) { }
public static extern int FindFunction(LLVMExecutionEngineRef* EE, [In][MarshalAs(UnmanagedType.LPStr)] string Name, ref LLVMValueRef * OutFn);
internal FPExt(LLVMValueRef valueRef) : base(valueRef) { }
public static extern uint PreferredAlignmentOfGlobal(LLVMTargetDataRef* LLVMTargetDataRef, LLVMValueRef* GlobalVar);
internal Trunc(LLVMValueRef valueRef) : base(valueRef) { }
public static extern LLVMValueRef* GetNextFunction(LLVMValueRef* Fn);
public static extern LLVMValueRef* BuildFPCast(LLVMBuilderRef* LLVMBuilderRef, LLVMValueRef* Val, LLVMTypeRef* DestTy, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
internal UIToFP(LLVMValueRef valueRef) : base(valueRef) { }
public static extern LLVMValueRef* BuildCall(LLVMBuilderRef* LLVMBuilderRef, LLVMValueRef* Fn, System.IntPtr[] Args, uint NumArgs, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
internal AtomicCmpXchg(LLVMValueRef valueRef) : base(valueRef) { }
private static extern LLVMValueRef LLVMGetOperand(LLVMValueRef @Val, uint @Index);
public static extern void SetVolatile(LLVMValueRef* MemoryAccessInst, int IsVolatile);
public Number() { this.State = NumberState.Ok; this.Kind = Semantics.DefaultKind; this.Value = LLVM.ConstInt(GetLLVMType(), 0, new LLVMBool(0)); }
public static extern LLVMValueRef* BuildFCmp(LLVMBuilderRef* LLVMBuilderRef, LLVMRealPredicate Op, LLVMValueRef* LHS, LLVMValueRef* RHS, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
void LoadZeroExternalValue() { this.ExternalValue = LLVM.ConstInt(GetLLVMType(internalType: false), 0, new LLVMBool(0)); }
public static extern LLVMValueRef* BuildSelect(LLVMBuilderRef* LLVMBuilderRef, LLVMValueRef* If, LLVMValueRef* Then, LLVMValueRef* Else, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
protected TerminatorInst(LLVMValueRef instance) : base(instance) { }
public static extern LLVMValueRef* BuildInsertElement(LLVMBuilderRef* LLVMBuilderRef, LLVMValueRef* VecVal, LLVMValueRef* EltVal, LLVMValueRef* Index, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
internal IntToPointer(LLVMValueRef valueRef) : base(valueRef) { }
public static extern LLVMValueRef* BuildInsertValue(LLVMBuilderRef* LLVMBuilderRef, LLVMValueRef* AggVal, LLVMValueRef* EltVal, uint Index, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
internal FNeg(LLVMValueRef instance) : base(instance) { }
public static extern LLVMValueRef* BuildPtrDiff(LLVMBuilderRef* LLVMBuilderRef, LLVMValueRef* LHS, LLVMValueRef* RHS, [In][MarshalAs(UnmanagedType.LPStr)] string Name);
public static LLVMValueRef IppExp(this CodeGenerator g, LLVMValueRef a, string name = "") => g.Call(FunctionNames.Exp64FI, new[] { a, g.NPaths }, name);
public static extern int RunFunctionAsMain(LLVMExecutionEngineRef* EE, LLVMValueRef* F, uint ArgC, [MarshalAs(UnmanagedType.LPStr)] ref StringBuilder ArgV, [MarshalAs(UnmanagedType.LPStr)] ref StringBuilder EnvP);
public static LLVMValueRef IppCpy(this CodeGenerator g, LLVMValueRef a, LLVMValueRef b, string name = "", LLVMValueRef?length = null) => g.Call(FunctionNames.Copy64F, new[] { a, b, length ?? g.NPaths }, name);
public static extern void FreeMachineCodeForFunction(LLVMExecutionEngineRef* EE, LLVMValueRef* F);
public static LLVMValueRef IppSet(this CodeGenerator g, double value, LLVMValueRef vector, string name = "", LLVMValueRef?length = null) => value == 0.0 ? g.Call(FunctionNames.Zero64F, new[] { vector, length ?? g.NPaths }, name) : g.Call(FunctionNames.Set64F, new[] { g.Const(value), vector, length ?? g.NPaths }, name);
public static extern System.IntPtr RecompileAndRelinkFunction(LLVMExecutionEngineRef* EE, LLVMValueRef* Fn);
public static IppMallocHandle Allocate(this CodeGenerator g, LLVMValueRef count, string name = "") => new IppMallocHandle(g, g.Call(FunctionNames.Malloc64F, new[] { count }, name));
public static extern System.IntPtr GetPointerToGlobal(LLVMExecutionEngineRef* EE, LLVMValueRef* Global);
public static LLVMValueRef IppAdd(this CodeGenerator g, LLVMValueRef a, LLVMValueRef b, string name = "") => g.Call(FunctionNames.Add64FI, new[] { a, b, g.NPaths }, name);
public static extern int VerifyFunction(LLVMValueRef* Fn, LLVMVerifierFailureAction Action);
internal Cast(LLVMValueRef valueRef) : base(valueRef) { }
public static extern void AddNamedMetadataOperand(LLVMModuleRef* M, [In][MarshalAs(UnmanagedType.LPStr)] string name, LLVMValueRef* Val);
public static LLVMValueRef BuildAtomicCmpXchg(this LLVMBuilderRef builder, LLVMValueRef ptr, LLVMValueRef cmp, LLVMValueRef @new, LLVMAtomicOrdering successOrdering, LLVMAtomicOrdering failureOrdering, bool singleThread) => LLVM.BuildAtomicCmpXchg(builder, ptr, cmp, @new, successOrdering, failureOrdering, singleThread ? 1 : 0);
public static extern LLVMValueRef* GetPreviousFunction(LLVMValueRef* Fn);
/// <summary> /// Builds LLVM IR instructions that perform a virtual method lookup: /// loads the address of the implementation of a virtual method given /// a type metadata pointer for the 'this' type. /// </summary> /// <param name="callee"> /// A virtual method to find an implementation for. /// </param> /// <param name="metadata"> /// A handle to the type metadata of the 'this' type. /// </param> /// <param name="module"> /// The LLVM module to generate the instructions in. /// </param> /// <param name="builder"> /// An instruction builder to use for emitting instructions. /// </param> /// <param name="name"> /// A suggested name for the value that refers to the method /// implementation address. /// </param> /// <returns>A pointer to a method implementation.</returns> public abstract LLVMValueRef EmitMethodAddress( IMethod callee, LLVMValueRef metadata, ModuleBuilder module, IRBuilder builder, string name);