Exemplo n.º 1
0
        private static Type GetMsilType(LLVMSharp.API.Type typeRef)
        {
            switch (typeRef)
            {
            case IntegerType t:
                var intTypeWidth = t.BitWidth;
                switch (intTypeWidth)
                {
                case 1:
                case 32:
                    return(typeof(int));

                case 8:
                    return(typeof(byte));

                default:
                    throw new NotImplementedException();
                }

            case VoidType _:
                return(typeof(void));

            case PointerType t:
                var elementType = GetMsilType(t.ElementType);
                return(elementType.IsArray
                        ? elementType
                        : elementType.MakeArrayType());

            case ArrayType t:
                return(GetMsilType(t.ElementType).MakeArrayType());

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 2
0
 public static VectorType Get(Type elementType, uint numElements) => LLVM.VectorType(elementType.Unwrap(), numElements).WrapAs <VectorType>();
Exemplo n.º 3
0
 public static bool IsValidElementType(Type type) => type is IntegerType || type is FPType || type is PointerType;
Exemplo n.º 4
0
 public static ConstantExpr GetNull(Type type) => LLVM.ConstNull(type.MustHaveConstants().Unwrap()).WrapAs <ConstantExpr>();
Exemplo n.º 5
0
 public static ConstantExpr GetSizeOf(Type type) => LLVM.SizeOf(type.MustBeSized().Unwrap()).WrapAs <ConstantExpr>();
Exemplo n.º 6
0
 public static ConstantExpr GetInlineAsm(Type ty, string asmString, string constraints, bool hasSideEffects, bool isAlignStack) => LLVM.ConstInlineAsm(ty.MustHaveConstants().Unwrap(), asmString, constraints, hasSideEffects, isAlignStack).WrapAs <ConstantExpr>();
Exemplo n.º 7
0
 public static ConstantExpr GetFPCast(Constant constantVal, Type toType) => LLVM.ConstFPCast(constantVal.Unwrap(), toType.MustHaveConstants().Unwrap()).WrapAs <ConstantExpr>();
Exemplo n.º 8
0
 public static ConstantExpr GetIntCast(Constant constantVal, Type toType, bool isSigned) => LLVM.ConstIntCast(constantVal.Unwrap(), toType.MustHaveConstants().Unwrap(), isSigned).WrapAs <ConstantExpr>();
Exemplo n.º 9
0
 public static ConstantFP Get(Type type, string text) => LLVM.ConstRealOfString(type.Unwrap(), text).WrapAs <ConstantFP>();