diff --git a/cpp/src/compilation/latecontextcompiler2.cpp b/cpp/src/compilation/latecontextcompiler2.cpp deleted file mode 100644 index 915f57b..0000000 --- a/cpp/src/compilation/latecontextcompiler2.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * LateContextCompiler2.cpp - * - * Created on: 10 февр. 2016 - * Author: pgess - */ - -//TOTEST default variants - do not enable specialization context in order to check default variant invocation - -#include "latecontextcompiler2.h" -#include "llvmlayer.h" -#include "pass/compilepass.h" -#include "query/context.h" -#include - -using namespace std; - -namespace xreate { - -const string topicSpecializationAtom = "specialization"; -const string topicDependencyAtom = "dependency"; - -LateContextCompiler2::LateContextCompiler2(compilation::FunctionUnit* f, CompilePass* p) - : function(f), pass(p){ - - ContextQuery* context = pass->queryContext; - __sizeOfDemand = context->getFunctionDemand(function->function->getName()).size(); -} - -llvm::Function* -LateContextCompiler2::findFunction(const std::string& calleeName, llvm::Function* specializationDefault, ScopePacked scopeCaller){ - const string& functionName = function->function->getName(); - ContextQuery* context = pass->queryContext; - llvm::IRBuilder<>& builder = pass->man->llvm->builder; - - const FunctionDemand& demand = context->getFunctionDemand(functionName); - const std::list& specializations = pass->man->root->getFunctionVariants(calleeName); - - //independent decision: - Expression topic(Operator::CALL, {(Atom(string(topicSpecializationAtom))), (Atom(string(calleeName))), (Atom(scopeCaller))}); - assert(demand.right.count(topic) && "Can't determine specialization for the function"); - size_t topicId = demand.right.at(topic); - llvm::Value* topicDecisionRaw = builder.CreateExtractValue(this->rawContextArgument, llvm::ArrayRef{(unsigned) topicId}); - - const Domain& specializationsDomain= context->getTopicDomain(topic); - - std::vector vectorVariants; - vectorVariants.reserve(specializationsDomain.size()); - for (const ManagedFnPtr& f: specializations){ - if (!f->guardContext.isValid()) continue; - const auto& variantId = specializationsDomain.getIdOptional(f->guardContext); - if (variantId){ - if (vectorVariants.size() < *variantId + 1) { - vectorVariants.resize(*variantId + 1); - } - - vectorVariants[*variantId] = pass->getFunctionUnit(f)->compile(); - } - } - - return - llvm::dyn_cast( - compileDecisionSelectorAsSwitch(topicDecisionRaw, vectorVariants, specializationDefault)); -} - -llvm::Value* -LateContextCompiler2::compileContextArgument(const std::string& callee, ScopePacked scopeCaller){ - const std::string& atomDependentDecision = Config::get("clasp.context.decisions.dependent"); - llvm::IRBuilder<>& builder = pass->man->llvm->builder; - ContextQuery* context = pass->queryContext; - - const string& functionName = function->function->getName(); - const Decisions& dictStaticDecisions = context->getFinalDecisions(scopeCaller); - - const FunctionDemand& demandCallee = context->getFunctionDemand(callee); - const FunctionDemand& demandSelf = context->getFunctionDemand(functionName); - - llvm::IntegerType* ty32 = llvm::Type::getInt32Ty(llvm::getGlobalContext()); - llvm::Type* tyDemand = llvm::ArrayType::get(ty32, demandCallee.size()); - - //builder.CreateAlloca(tyDemand, llvm::ConstantInt::get(ty32, 1)); - llvm::Value* res = llvm::ConstantArray::getNullValue(tyDemand); - - for (size_t i=0, size = demandCallee.size(); irawContextArgument, llvm::ArrayRef{(unsigned) topicId}); - - } else if (dictStaticDecisions.count(topic)){ - //static final decision: - const Expression& decision = dictStaticDecisions.at(topic); - const Domain& domainOfTopic = context->getTopicDomain(topic); - const DomainId& decisionCode = domainOfTopic.getId(decision); - decisionRaw = llvm::ConstantInt::get(ty32, decisionCode); - - } else { - //dependent decision - decisionRaw = compileDependentDecision(topic, scopeCaller); - } - - res = builder.CreateInsertValue(res, decisionRaw, llvm::ArrayRef{(unsigned) i}); - } - - return res; -} - -llvm::Value* -LateContextCompiler2::compileDependentDecision(const Expression& topic, ScopePacked scopeCaller){ - const string& functionName = function->function->getName(); - ContextQuery* context = pass->queryContext; - llvm::IRBuilder<>& builder = pass->man->llvm->builder; - llvm::IntegerType* ty32 = llvm::Type::getInt32Ty(llvm::getGlobalContext()); - - const FunctionDemand& demandSelf = context->getFunctionDemand(functionName); - const Expression topicDependency = Expression(Operator::CALL, {Atom(string(topicDependencyAtom)), topic, Atom(scopeCaller)}); - - const Domain& demandOfTopic = context->getTopicDomain(topic); - const Domain& domainOfTopicDependency = context->getTopicDomain(topicDependency); - - //dependent decision - vector vectorDecisions(domainOfTopicDependency.size(), llvm::UndefValue::get(ty32)); - for (const std::pair& entry: context->getDependentDecision(scopeCaller,topic)){ - vectorDecisions[domainOfTopicDependency.getId(entry.first)]= llvm::ConstantInt::get(ty32, demandOfTopic.getId(entry.second)); - } - - size_t topicDependencyId = demandSelf.right.at(topicDependency); - llvm::Value* decisionRaw = builder.CreateExtractValue(this->rawContextArgument, llvm::ArrayRef{(unsigned) topicDependencyId}); - - auto result = compileDecisionSelector(decisionRaw, vectorDecisions); - - return result; -} - -llvm::Value* -LateContextCompiler2::compileDecisionSelector(llvm::Value* selector, std::vector vectorVariants, llvm::Value* variantDefault){ - //TODO implement variantDefault; - assert(vectorVariants.size()>0); - llvm::IRBuilder<>& builder = pass->man->llvm->builder; - llvm::IntegerType* ty32 = llvm::Type::getInt32Ty(llvm::getGlobalContext()); - - llvm::Type* tyElement = vectorVariants[0]->getType(); - llvm::Type* tyVariants = llvm::VectorType::get(tyElement, vectorVariants.size()); - llvm::Value* vectorRaw = llvm::ConstantVector::getNullValue(tyVariants); - - - for(DomainId i=0; i vectorVariants, llvm::Value* variantDefault){ - llvm::IRBuilder<>& builder = pass->man->llvm->builder; - llvm::IntegerType* ty32 = llvm::Type::getInt32Ty(llvm::getGlobalContext()); - - llvm::BasicBlock* blockDefault = llvm::BasicBlock::Create(llvm::getGlobalContext(), "caseDefault", this->function->raw); - llvm::BasicBlock *blockEpilog = llvm::BasicBlock::Create(llvm::getGlobalContext(), "VariantDeterminationEnd", this->function->raw); - - llvm::SwitchInst* instrSwitch = builder.CreateSwitch(selector, blockDefault, vectorVariants.size()); - - builder.SetInsertPoint(blockEpilog); - llvm::PHINode *result = builder.CreatePHI(variantDefault->getType(), vectorVariants.size(), "callee"); - - for (size_t i=0; ifunction->raw); - builder.SetInsertPoint(blockCase); - builder.CreateBr(blockEpilog); - result->addIncoming(vectorVariants[i], blockCase); - instrSwitch->addCase(llvm::ConstantInt::get(ty32, i), blockCase); - } - - builder.SetInsertPoint(blockDefault); - builder.CreateBr(blockEpilog); - result->addIncoming(variantDefault, blockDefault); - - builder.SetInsertPoint(blockEpilog); - return result; -} - -size_t -LateContextCompiler2::getFunctionDemandSize() const { - return __sizeOfDemand; -} - -} /* namespace xreate */ diff --git a/cpp/src/compilation/latecontextcompiler2.h b/cpp/src/compilation/latecontextcompiler2.h deleted file mode 100644 index 791d8d4..0000000 --- a/cpp/src/compilation/latecontextcompiler2.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * LateContextCompiler2.h - * - * Created on: 10 февр. 2016 - * Author: pgess - */ - -//TOTEST compile several context arguments -#ifndef LATECONTEXTCOMPILER2_H_ -#define LATECONTEXTCOMPILER2_H_ - -#include "serialization.h" - -namespace llvm { - class Value; - class Function; -} - -namespace xreate { - class CompilePass; - -namespace compilation { - class FunctionUnit; -}} - -namespace xreate { - -typedef unsigned int ScopePacked; -class LateContextCompiler2 { -public: - llvm::Value* rawContextArgument = nullptr; - - LateContextCompiler2(compilation::FunctionUnit* f, CompilePass* p); - llvm::Function* findFunction(const std::string& calleeName, llvm::Function* specializationDefault, ScopePacked scopeCaller); - llvm::Value* compileContextArgument(const std::string& callee, ScopePacked scopeCaller); - size_t getFunctionDemandSize() const; - -private: - typedef ExpressionSerialization::Code DomainId; - typedef ExpressionSerialization::Serializer Domain; - //boost::bimap __decisions; - //std::vector __scheme; - - compilation::FunctionUnit* function; - CompilePass* pass; - size_t __sizeOfDemand; - - llvm::Value* compileDependentDecision(const Expression& topic, ScopePacked scopeCaller); - llvm::Value* compileDecisionSelector(llvm::Value* selector, std::vector vectorVariants, llvm::Value* variantDefault=nullptr); - llvm::Value* compileDecisionSelectorAsSwitch(llvm::Value* selector, std::vector vectorVariants, llvm::Value* variantDefault); -}; -} /* namespace xreate */ - -#endif /* LATECONTEXTCOMPILER2_H_ */ diff --git a/cpp/tests/testExpressionSerializer.cpp b/cpp/tests/ExpressionSerializer.cpp similarity index 100% rename from cpp/tests/testExpressionSerializer.cpp rename to cpp/tests/ExpressionSerializer.cpp diff --git a/cpp/tests/ExpressionSerializer2_test.cpp b/cpp/tests/ExpressionSerializer2_test.cpp deleted file mode 100644 index 9170de7..0000000 --- a/cpp/tests/ExpressionSerializer2_test.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/* - * ExpressionSerializer2_test.cpp - * - * Created on: 9 февр. 2016 - * Author: pgess - */ - -#include "serialization/expressionserializer2.h" - -namespace xreate { - -} /* namespace xreate */ diff --git a/cpp/tests/testBasic.cpp b/cpp/tests/basic.cpp similarity index 100% rename from cpp/tests/testBasic.cpp rename to cpp/tests/basic.cpp diff --git a/cpp/tests/CFGtests.cpp b/cpp/tests/cfa.cpp similarity index 100% rename from cpp/tests/CFGtests.cpp rename to cpp/tests/cfa.cpp diff --git a/cpp/tests/DFGtests.cpp b/cpp/tests/dfa.cpp similarity index 100% rename from cpp/tests/DFGtests.cpp rename to cpp/tests/dfa.cpp diff --git a/documentation/Articles/declarative_patterns.remarkup b/documentation/Articles/declarative_patterns.remarkup index fbe712a..51d31d1 100644 --- a/documentation/Articles/declarative_patterns.remarkup +++ b/documentation/Articles/declarative_patterns.remarkup @@ -1,36 +1,41 @@ -==Overview== - In addition to a classic object-oriented common patterns and practices there are several areas and problems not very easy and conveniently expressed by object oriented approach. Few of so called declarative patterns are presented below : * **Dependency resolution** Starting at some level of complexity every software project usually faces need of managing dependencies of some kind like package dependencies, components and versions dependency. - Dependencies are easily represented by declarative means and moreover - usually do not change in runtime. Thus dependency management is good candidate for static or comile-time resolution. S ee [[articles/declarative_patterns#dependency-resolution|details]]. + Dependencies are easily represented by declarative means and moreover usually do not change + drastically at runtime. Thus dependency management is good candidate for static or comile-time resolution. + See [[articles/declarative_patterns#dependency-resolution|details]]. * **Demand and supply** A big amount of a problems could be expressed in terms of supply and demand of interacting components. See [[articles/declarative_patterns#demand-and-supply|details]]. * **Share or joint use**: Examples: first/last use determination, share use planning and allocation(memory, etc).See for example [[concepts/usage| resources usage]]. ===Dependency resolution=== +* **Verification and Adaptation** +TODO expand on verification and adaptation. Upstream/downstream + +* **Preferences** +Abitility to express preferences allows recognize situation ... +* **Distibuted information** +Information gathered from different sources. -fdfdfdfd ===Demand and supply=== dssdsds ===Share or joint use=== bdfvfsl; \ No newline at end of file diff --git a/documentation/Aspects/Virtualization/virtualization.remarkup b/documentation/Aspects/Virtualization/index.remarkup similarity index 100% rename from documentation/Aspects/Virtualization/virtualization.remarkup rename to documentation/Aspects/Virtualization/index.remarkup diff --git a/documentation/Concepts/context.remarkup b/documentation/Concepts/context.remarkup index ccbd334..bc3028b 100644 --- a/documentation/Concepts/context.remarkup +++ b/documentation/Concepts/context.remarkup @@ -1,6 +1,9 @@ ===Static context=== ===Dynamic context=== ===Path dependent dynamic context=== + + + diff --git a/documentation/development/files.remarkup b/documentation/development/files.remarkup new file mode 100644 index 0000000..40b54c5 --- /dev/null +++ b/documentation/development/files.remarkup @@ -0,0 +1,116 @@ +|Filename|Description|Unittests| +| ___ | ___ | ___ | +| analysis/cfagraph.*, /pass/cfapass.h | CFA | | +| analysis/dfagraph.*, | DFA | | +| analysis/DominatorsTreeAnalysisProvider.* | Dominators analysis || +| compilation/advanced.* | Additional constructions compilation +| compilation/containers.h | Containers support + + + + +analysis + file:///private/prg/code/xreate/cpp/src/analysis/aux.h + file:///private/prg/code/xreate/cpp/src/analysis/aux.cpp + + +compilation + file:///private/prg/code/xreate/cpp/src/ + file:///private/prg/code/xreate/cpp/src/ + file:///private/prg/code/xreate/cpp/src/compilation/latecontextcompiler.h + file:///private/prg/code/xreate/cpp/src/compilation/latecontextcompiler2.h + file:///private/prg/code/xreate/cpp/src/compilation/targetinterpretation.h + file:///private/prg/code/xreate/cpp/src/compilation/targets.h + file:///private/prg/code/xreate/cpp/src/compilation/transformations.h + file:///private/prg/code/xreate/cpp/src/compilation/advanced.cpp + file:///private/prg/code/xreate/cpp/src/compilation/containers.cpp + file:///private/prg/code/xreate/cpp/src/compilation/latecontextcompiler.cpp + file:///private/prg/code/xreate/cpp/src/compilation/latecontextcompiler2.cpp + file:///private/prg/code/xreate/cpp/src/compilation/targetinterpretation.cpp + file:///private/prg/code/xreate/cpp/src/compilation/transformations.cpp + +pass/ + file:///private/prg/code/xreate/cpp/src/pass/abstractpass.h + file:///private/prg/code/xreate/cpp/src/pass/adhocpass.h + file:///private/prg/code/xreate/cpp/src/pass/cfapass.h + file:///private/prg/code/xreate/cpp/src/pass/compilepass.h + file:///private/prg/code/xreate/cpp/src/pass/dfapass.h + file:///private/prg/code/xreate/cpp/src/pass/environmenttestspass.h + file:///private/prg/code/xreate/cpp/src/pass/interpretationpass.h + file:///private/prg/code/xreate/cpp/src/pass/loggerpass.h + file:///private/prg/code/xreate/cpp/src/pass/rulespass.h + file:///private/prg/code/xreate/cpp/src/pass/abstractpass.cpp + file:///private/prg/code/xreate/cpp/src/pass/adhocpass.cpp + file:///private/prg/code/xreate/cpp/src/pass/cfapass.cpp + file:///private/prg/code/xreate/cpp/src/pass/compilepass.cpp + file:///private/prg/code/xreate/cpp/src/pass/dfapass.cpp + file:///private/prg/code/xreate/cpp/src/pass/environmenttestspass.cpp + file:///private/prg/code/xreate/cpp/src/pass/interpretationpass.cpp + file:///private/prg/code/xreate/cpp/src/pass/loggerpass.cpp + file:///private/prg/code/xreate/cpp/src/pass/rulespass.cpp + +query: + file:///private/prg/code/xreate/cpp/src/query/containers.h + file:///private/prg/code/xreate/cpp/src/query/context.h + file:///private/prg/code/xreate/cpp/src/query/ptrvalid.h + file:///private/prg/code/xreate/cpp/src/query/containers.cpp + file:///private/prg/code/xreate/cpp/src/query/context.cpp + file:///private/prg/code/xreate/cpp/src/query/ptrvalid.cpp + +serialization + file:///private/prg/code/xreate/cpp/src/serialization/expressionserializer.h + file:///private/prg/code/xreate/cpp/src/serialization/expressionserializer2.h + file:///private/prg/code/xreate/cpp/src/serialization/expressionserializer.cpp + file:///private/prg/code/xreate/cpp/src/serialization/expressionserializer2.cpp + + +src + file:///private/prg/code/xreate/cpp/src/ast.h + file:///private/prg/code/xreate/cpp/src/attachments.h + file:///private/prg/code/xreate/cpp/src/clasplayer.h + file:///private/prg/code/xreate/cpp/src/contextrule.h + file:///private/prg/code/xreate/cpp/src/ExternLayer.h + file:///private/prg/code/xreate/cpp/src/llvmlayer.h + file:///private/prg/code/xreate/cpp/src/passmanager.h + file:///private/prg/code/xreate/cpp/src/serialization.h + file:///private/prg/code/xreate/cpp/src/utils.h + file:///private/prg/code/xreate/cpp/src/ast.cpp + file:///private/prg/code/xreate/cpp/src/attachments.cpp + file:///private/prg/code/xreate/cpp/src/clasplayer.cpp + file:///private/prg/code/xreate/cpp/src/contextrule.cpp + file:///private/prg/code/xreate/cpp/src/ExternLayer.cpp + file:///private/prg/code/xreate/cpp/src/llvmlayer.cpp + file:///private/prg/code/xreate/cpp/src/passmanager.cpp + file:///private/prg/code/xreate/cpp/src/utils.cpp + file:///private/prg/code/xreate/cpp/src/CMakeLists.txt + +tests + file:///private/prg/code/xreate/cpp/tests/testClangAPI.h + file:///private/prg/code/xreate/cpp/tests/adhoc-skipdetection.cpp + file:///private/prg/code/xreate/cpp/tests/adhoc.cpp + file:///private/prg/code/xreate/cpp/tests/ast.cpp + file:///private/prg/code/xreate/cpp/tests/basic.cpp + file:///private/prg/code/xreate/cpp/tests/cfa.cpp + file:///private/prg/code/xreate/cpp/tests/compilation.cpp + file:///private/prg/code/xreate/cpp/tests/containers.cpp + file:///private/prg/code/xreate/cpp/tests/context.cpp + file:///private/prg/code/xreate/cpp/tests/dfa.cpp + file:///private/prg/code/xreate/cpp/tests/diagnostic-messages.cpp + file:///private/prg/code/xreate/cpp/tests/ExpressionSerializer.cpp + file:///private/prg/code/xreate/cpp/tests/externc.cpp + file:///private/prg/code/xreate/cpp/tests/installation.cpp + file:///private/prg/code/xreate/cpp/tests/interpretation.cpp + file:///private/prg/code/xreate/cpp/tests/loops.cpp + file:///private/prg/code/xreate/cpp/tests/main.cpp + file:///private/prg/code/xreate/cpp/tests/pass-Logger.cpp + file:///private/prg/code/xreate/cpp/tests/pointers.cpp + file:///private/prg/code/xreate/cpp/tests/safety.cpp + file:///private/prg/code/xreate/cpp/tests/testClangAPI.cpp + file:///private/prg/code/xreate/cpp/tests/testExploitation.cpp + file:///private/prg/code/xreate/cpp/tests/testJson.cpp + file:///private/prg/code/xreate/cpp/tests/testLibXml2.cpp + file:///private/prg/code/xreate/cpp/tests/types.cpp + file:///private/prg/code/xreate/cpp/tests/upcoming.cpp + file:///private/prg/code/xreate/cpp/tests/xml.cpp + file:///private/prg/code/xreate/cpp/tests/CMakeLists.txt + \ No newline at end of file diff --git a/documentation/development/index.remarkup b/documentation/development/index.remarkup new file mode 100644 index 0000000..e69de29 diff --git a/documentation/diagrams/diagram-annotations-processing.graphml b/documentation/diagrams/diagram-annotations-processing.graphml new file mode 100644 index 0000000..e31a950 --- /dev/null +++ b/documentation/diagrams/diagram-annotations-processing.graphml @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Main program + + + + + + + + + + Folder 2 + + + + + + + + + + + + + + + + + Client code + + + + + + + + + + + + + + + + + + Library + + + + + + + + + + + + + + + + + + + + + + + Group 2 + + + + + + + + + + Folder 2 + + + + + + + + + + + + + + + + + Annotations +storage + + + + + + + + + + + + + + + + + + Solver + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/documentation/diagrams/diagram-annotations-processing.remarkup b/documentation/diagrams/diagram-annotations-processing.remarkup new file mode 100644 index 0000000..8ed486c --- /dev/null +++ b/documentation/diagrams/diagram-annotations-processing.remarkup @@ -0,0 +1,19 @@ +~~~cpp +dfdffdfdfdfd +~~~ + +
+graph TD +subgraph analysis + client-.->storage[Gathering annotations] + library-.->storage + storage-->solver + solver==>library +end + +subgraph main + client[Client Code]-->library[Library code] +end + + +
\ No newline at end of file diff --git a/documentation/index.remarkup b/documentation/index.remarkup index a58a0cb..cb900ee 100644 --- a/documentation/index.remarkup +++ b/documentation/index.remarkup @@ -1,13 +1,19 @@ -## Overview +Main idea behind Xreate is to employ logic inference to address practical day-to-day programming problems. -Xreate is a language for write safe and efficient programs. +Goals: -## Getting started +* Optimization +* Security and safety +* Virtualization +* High-level +To begin with, in Xreate we treat defininiton of "high-level" as practical term, meaning ability +to adapt, alter, adjust component or whole program to comply with new changed requirements or environment in general. +The more "high-level" techniques language provides, the less efforts need to be done for such transformation, given all else things being equal. -### Functions - : +TODO To reduce high-level or abstraction penalty .... -#### Syntax +* +* Code readability +* Literary programming -This formula here \\(y=a\sum_{k=1}^{\infty}\frac{1}{k^{2}}\\) is a test.