예제 #1
0
        /// <summary>
        /// Declares the given intrinsic if it was not declared already.
        /// </summary>
        /// <param name="Intrinsic">The intrinsic to declare.</param>
        /// <returns>The intrinsic's declaration.</returns>
        public LLVMValueRef Declare(IntrinsicValue Intrinsic)
        {
            LLVMValueRef result;

            if (!declaredIntrinsics.TryGetValue(Intrinsic, out result))
            {
                result = Intrinsic.Declare(this, module);
                declaredIntrinsics[Intrinsic] = result;
            }
            return(result);
        }
예제 #2
0
        static IntrinsicValue()
        {
            // Signature: void* __cxa_allocate_exception(size_t thrown_size) throw()
            CxaAllocateExceptionSignature = new DescribedMethod(
                "__cxa_allocate_exception",
                null,
                PrimitiveTypes.Void.MakePointerType(PointerKind.TransientPointer),
                true);

            CxaAllocateExceptionSignature.AddParameter(
                new DescribedParameter("thrown_size", PrimitiveTypes.UInt64));

            CxaAllocateException = new IntrinsicValue(
                MethodType.Create(CxaAllocateExceptionSignature),
                DeclareCxaAllocateException);

            // Signature: void __cxa_throw(void* thrown_object, std::type_info* tinfo, void (*dest)(void*))
            CxaThrowSignature = new DescribedMethod(
                "__cxa_throw",
                null,
                PrimitiveTypes.Void,
                true);

            CxaThrowSignature.AddParameter(
                new DescribedParameter(
                    "thrown_object",
                    PrimitiveTypes.Void.MakePointerType(PointerKind.TransientPointer)));

            CxaThrowSignature.AddParameter(
                new DescribedParameter(
                    "tinfo",
                    PrimitiveTypes.Void.MakePointerType(PointerKind.TransientPointer)));

            CxaThrowSignature.AddParameter(
                new DescribedParameter(
                    "dest",
                    PrimitiveTypes.Void.MakePointerType(PointerKind.TransientPointer)));

            CxaThrow = new IntrinsicValue(
                MethodType.Create(CxaThrowSignature),
                DeclareCxaThrow);

            // Signature: void __cxa_rethrow()
            CxaRethrowSignature = new DescribedMethod(
                "__cxa_rethrow",
                null,
                PrimitiveTypes.Void,
                true);

            CxaRethrow = new IntrinsicValue(
                MethodType.Create(CxaRethrowSignature),
                DeclareCxaRethrow);

            // Signature: void* __cxa_begin_catch(void* exception_obj)
            CxaBeginCatchSignature = new DescribedMethod(
                "__cxa_begin_catch",
                null,
                PrimitiveTypes.Void.MakePointerType(PointerKind.TransientPointer),
                true);

            CxaBeginCatchSignature.AddParameter(
                new DescribedParameter(
                    "exception_obj",
                    PrimitiveTypes.Void.MakePointerType(PointerKind.TransientPointer)));

            CxaBeginCatch = new IntrinsicValue(
                MethodType.Create(CxaBeginCatchSignature),
                DeclareCxaBeginCatch);

            // Signature: void __cxa_end_catch()
            CxaEndCatchSignature = new DescribedMethod(
                "__cxa_end_catch",
                null,
                PrimitiveTypes.Void,
                true);

            CxaEndCatch = new IntrinsicValue(
                MethodType.Create(CxaEndCatchSignature),
                DeclareCxaEndCatch);

            // Signature: declare i32 @__gxx_personality_v0(...)
            GxxPersonalityV0 = new IntrinsicValue(
                PrimitiveTypes.Void.MakePointerType(PointerKind.TransientPointer),
                DeclareGxxPersonalityV0);

            // Signature: @_ZTIPv = external constant i8*
            CxaVoidPointerRtti = new IntrinsicValue(
                PrimitiveTypes.Void.MakePointerType(PointerKind.TransientPointer),
                DeclareCxaVoidPointerRtti);
        }