Beispiel #1
0
        private FunctionVariableStorage RunAllocator(DfirRoot function)
        {
            var cancellationToken = new CompileCancellationToken();

            RunCompilationUpToAsyncNodeDecomposition(function, cancellationToken);
            ExecutionOrderSortingVisitor.SortDiagrams(function);

            var asyncStateGrouper = new AsyncStateGrouper();

            asyncStateGrouper.Execute(function, cancellationToken);
            IEnumerable <AsyncStateGroup> asyncStateGroups = asyncStateGrouper.GetAsyncStateGroups();

            using (var contextWrapper = new ContextWrapper())
            {
                var module           = contextWrapper.CreateModule("module");
                var functionImporter = new FunctionImporter(contextWrapper, module);
                var codeGenExpander  = new CodeGenExpander(
                    function,
                    new FunctionModuleContext(contextWrapper, module, functionImporter),
                    new Dictionary <CompilableDefinitionName, bool>());
                asyncStateGroups.ForEach(codeGenExpander.ExpandAsyncStateGroup);

                var variableStorage = new FunctionVariableStorage();
                var allocator       = new Allocator(contextWrapper, variableStorage, asyncStateGroups);
                allocator.Execute(function, cancellationToken);
                return(variableStorage);
            }
        }
Beispiel #2
0
        public void LLVMModuleTest()
        {
            using (var contextWrapper = new ContextWrapper())
            {
                var module                   = contextWrapper.CreateModule("test");
                var functionType             = LLVM.FunctionType(contextWrapper.VoidType, new LLVMTypeRef[] { }, false);
                var topLevelFunction         = module.AddFunction("f", functionType);
                LLVMBasicBlockRef entryBlock = topLevelFunction.AppendBasicBlock("entry");
                var builder                  = contextWrapper.CreateIRBuilder();
                builder.PositionBuilderAtEnd(entryBlock);
                builder.CreateRetVoid();

                string moduleDump = module.PrintModuleToString();
            }
        }