Exemple #1
0
        public Value(LLVMValueRef* handle)
        {
            if(handle == null)
                throw new ArgumentNullException("handle");

            m_handle = handle;
        }
Exemple #2
0
        public static bool Used(LLVMValueRef* value)
        {
            if(value == null)
                throw new ArgumentNullException("value");

            return Native.GetFirstUse(value) != null;
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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;
        }
Exemple #5
0
        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]);
                }
            }
        }
Exemple #6
0
 internal ConstantPointerNull(LLVMValueRef valueRef)
     : base(valueRef)
 {
 }
Exemple #7
0
 private static extern void LLVMSetOperand(LLVMValueRef @User, uint @Index, LLVMValueRef @Val);
 public static extern void ViewFunctionCFGOnly(LLVMValueRef* Fn);
Exemple #9
0
 /// <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);
Exemple #12
0
 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);
Exemple #14
0
 public BuiltinFunction(FunctionType type, LLVMValueRef function) : this(type)
 {
     this.function = function;
 }
Exemple #15
0
 protected abstract LLVMValueRef ProcessIntegral(MethodCompiler compiler, LLVMValueRef lhs, LLVMValueRef rhs, LLVMBuilderRef builder);
Exemple #16
0
 /// <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);
Exemple #17
0
 /// <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);
Exemple #18
0
 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);
Exemple #26
0
 internal FPExt(LLVMValueRef valueRef)
     : base(valueRef)
 {
 }
 public static extern uint PreferredAlignmentOfGlobal(LLVMTargetDataRef* LLVMTargetDataRef, LLVMValueRef* GlobalVar);
Exemple #28
0
 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);
Exemple #31
0
 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);
Exemple #33
0
 internal AtomicCmpXchg(LLVMValueRef valueRef)
     : base(valueRef)
 {
 }
Exemple #34
0
 private static extern LLVMValueRef LLVMGetOperand(LLVMValueRef @Val, uint @Index);
 public static extern void SetVolatile(LLVMValueRef* MemoryAccessInst, int IsVolatile);
Exemple #36
0
 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);
Exemple #38
0
 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);
Exemple #40
0
 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);
Exemple #44
0
 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);
Exemple #56
0
 internal Cast(LLVMValueRef valueRef)
     : base(valueRef)
 {
 }
 public static extern void AddNamedMetadataOperand(LLVMModuleRef* M, [In][MarshalAs(UnmanagedType.LPStr)] string name, LLVMValueRef* Val);
Exemple #58
0
 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);
Exemple #60
0
 /// <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);