Beispiel #1
0
        private void ImportStoreHelper(LLVMValueRef toStore, LLVMTypeRef valueType, LLVMValueRef basePtr, uint offset)
        {
            LLVMTypeKind toStoreKind   = LLVM.GetTypeKind(LLVM.TypeOf(toStore));
            LLVMTypeKind valueTypeKind = LLVM.GetTypeKind(valueType);

            LLVMValueRef typedToStore = toStore;

            if (toStoreKind == LLVMTypeKind.LLVMPointerTypeKind && valueTypeKind == LLVMTypeKind.LLVMPointerTypeKind)
            {
                typedToStore = LLVM.BuildPointerCast(_builder, toStore, valueType, "storePtrCast");
            }
            else if (toStoreKind == LLVMTypeKind.LLVMPointerTypeKind && valueTypeKind != LLVMTypeKind.LLVMPointerTypeKind)
            {
                typedToStore = LLVM.BuildPtrToInt(_builder, toStore, valueType, "storeIntCast");
            }
            else if (toStoreKind != LLVMTypeKind.LLVMPointerTypeKind && valueTypeKind == LLVMTypeKind.LLVMPointerTypeKind)
            {
                typedToStore = LLVM.BuildIntToPtr(_builder, toStore, valueType, "storePtrCast");
            }
            else
            {
                Debug.Assert(toStoreKind != LLVMTypeKind.LLVMPointerTypeKind && valueTypeKind != LLVMTypeKind.LLVMPointerTypeKind);
                typedToStore = LLVM.BuildIntCast(_builder, toStore, valueType, "storeIntCast");
            }

            var storeLocation = LLVM.BuildGEP(_builder, basePtr,
                                              new LLVMValueRef[] { LLVM.ConstInt(LLVM.Int32Type(), offset, LLVMMisc.False) },
                                              String.Empty);
            var typedStoreLocation = LLVM.BuildPointerCast(_builder, storeLocation, LLVM.PointerType(valueType, 0), String.Empty);

            LLVM.BuildStore(_builder, typedToStore, typedStoreLocation);
        }
Beispiel #2
0
 private protected Type(LLVMTypeRef handle, LLVMTypeKind expectedTypeKind)
 {
     if (handle.Kind != expectedTypeKind)
     {
         throw new ArgumentException(nameof(handle));
     }
     Handle = handle;
 }
Beispiel #3
0
 private protected SequentialType(LLVMTypeRef handle, LLVMTypeKind expectedTypeKind) : base(handle, expectedTypeKind)
 {
 }
Beispiel #4
0
 private protected CompositeType(LLVMTypeRef handle, LLVMTypeKind expectedTypeKind) : base(handle, expectedTypeKind)
 {
 }