Exemplo n.º 1
0
        private static IrFunction CreateInvalidFunction(BitcodeModule module, string name)
        {
            var ctx = module.Context;

            var testFunc = module.CreateFunction(name, ctx.GetFunctionType(ctx.VoidType));

            testFunc.AppendBasicBlock("entry");

            // UNTERMINATED BLOCK INTENTIONAL
            return(testFunc);
        }
Exemplo n.º 2
0
        private static InstructionBuilder CreateFunctionAndGetBuilder(BitcodeModule module, DebugBasicType doubleType, string name, string section, uint line)
        {
            DIFile file = module.DIBuilder.CreateFile(TestSrcFileName);

            DebugFunctionType signature = module.Context.CreateFunctionType(module.DIBuilder, doubleType, doubleType, doubleType);
            var func = module.CreateFunction(module.DICompileUnit, name, name, file, line, signature, true, true, line + 1, DebugInfoFlags.None, false);

            func.Section = section;
            var entry = func.AppendBasicBlock("entry");

            return(new InstructionBuilder(entry));
        }
Exemplo n.º 3
0
        private static IrFunction CreateSimpleVoidNopTestFunction(BitcodeModule module, string name)
        {
            var ctx = module.Context;

            Assert.IsNotNull(ctx);

            var testFunc   = module.CreateFunction(name, ctx.GetFunctionType(ctx.VoidType));
            var entryBlock = testFunc.AppendBasicBlock("entry");

            Assert.IsNotNull(testFunc.EntryBlock);
            Assert.AreSame(entryBlock, testFunc.EntryBlock);

            var irBuilder = new InstructionBuilder(testFunc.EntryBlock !);

            irBuilder.Return( );
            return(testFunc);
        }
Exemplo n.º 4
0
        private static Function DeclareDoCopyFunc(BitcodeModule module, DIFile diFile, IDebugType <ITypeRef, DIType> voidType)
        {
            var doCopySig = module.Context.CreateFunctionType(module.DIBuilder, voidType);

            var doCopyFunc = module.CreateFunction(scope: diFile
                                                   , name: "DoCopy"
                                                   , linkageName: null
                                                   , file: diFile
                                                   , line: 23
                                                   , signature: doCopySig
                                                   , isLocalToUnit: false
                                                   , isDefinition: true
                                                   , scopeLine: 24
                                                   , debugFlags: DebugInfoFlags.None
                                                   , isOptimized: false
                                                   ).AddAttributes(FunctionAttributeIndex.Function, AttributeKind.NoInline, AttributeKind.NoUnwind, AttributeKind.OptimizeNone)
                             .AddAttributes(FunctionAttributeIndex.Function, TargetDependentAttributes);

            return(doCopyFunc);
        }
Exemplo n.º 5
0
        private static Function DeclareCopyFunc(BitcodeModule module
                                                , DIFile diFile
                                                , IDebugType <ITypeRef, DIType> voidType
                                                , DIDerivedType constFoo
                                                , DebugPointerType fooPtr
                                                )
        {
            // Since the first parameter is passed by value
            // using the pointer + alloca + memcopy pattern, the actual
            // source, and therefore debug, signature is NOT a pointer.
            // However, that usage would create a signature with two
            // pointers as the arguments, which doesn't match the source
            // To get the correct debug info signature this inserts an
            // explicit DebugType<> that overrides the default behavior
            // to pair the LLVM pointer type with the original source type.
            var copySig = module.Context.CreateFunctionType(module.DIBuilder
                                                            , voidType
                                                            , DebugType.Create(fooPtr, constFoo)
                                                            , fooPtr
                                                            );

            var copyFunc = module.CreateFunction(scope: diFile
                                                 , name: "copy"
                                                 , linkageName: null
                                                 , file: diFile
                                                 , line: 11
                                                 , signature: copySig
                                                 , isLocalToUnit: true
                                                 , isDefinition: true
                                                 , scopeLine: 14
                                                 , debugFlags: DebugInfoFlags.Prototyped
                                                 , isOptimized: false
                                                 ).Linkage(Linkage.Internal)  // static function
                           .AddAttributes(FunctionAttributeIndex.Function, AttributeKind.NoUnwind, AttributeKind.NoInline, AttributeKind.OptimizeNone)
                           .AddAttributes(FunctionAttributeIndex.Function, TargetDependentAttributes);

            TargetDetails.AddABIAttributesForByValueStructure(copyFunc, 0);
            return(copyFunc);
        }