roadrunner  2.6.0
Fast simulator for SBML models
ASTNodeCodeGen.h
1 /*
2  * ASTNodeCodeGen.h
3  *
4  * Created on: Jun 16, 2013
5  *
6  * Author: Andy Somogyi,
7  * email decode: V1 = "."; V2 = "@"; V3 = V1;
8  * andy V1 somogyi V2 gmail V3 com
9  */
10 #ifndef ASTNodeCodeGenH
11 #define ASTNodeCodeGenH
12 
13 #include "LLVMIncludes.h"
14 #include "CodeGen.h"
15 #include "ModelGeneratorContext.h"
16 #include <thread>
17 
18 static std::mutex ASTNodeMtx;
19 
20 namespace libsbml
21 {
22 class ASTNode;
23 }
24 
25 namespace rrllvm
26 {
31 {
32 public:
33  ASTNodeCodeGen(llvm::IRBuilder<> &builder,
34  LoadSymbolResolver &resolver,
35  const ModelGeneratorContext& ctx,
36  llvm::Value *modelData);
37  ~ASTNodeCodeGen();
38 
39  llvm::Value* codeGenDouble(const libsbml::ASTNode* ast);
40  llvm::Value* codeGenBoolean(const libsbml::ASTNode* ast);
41 private:
42  llvm::Value* codeGen(const libsbml::ASTNode* ast);
43 
48  llvm::Value *binaryExprCodeGen(const libsbml::ASTNode *ast);
49 
50  llvm::Value *notImplemented(const libsbml::ASTNode *ast);
51 
52  llvm::Value *delayExprCodeGen(const libsbml::ASTNode *ast);
53 
54  llvm::Value* rateOfCodeGen(const libsbml::ASTNode* ast);
55 
56  llvm::Value *nameExprCodeGen(const libsbml::ASTNode *ast);
57 
58  llvm::Value *realExprCodeGen(const libsbml::ASTNode *ast);
59 
63  llvm::Value *distribCodeGen(const libsbml::ASTNode *ast);
64 
65 
71  llvm::Value *integerCodeGen(const libsbml::ASTNode *ast);
72 
78  llvm::Value *applyArithmeticCodeGen(const libsbml::ASTNode *ast);
79 
80  llvm::Value *minmaxCodeGen(const libsbml::ASTNode *ast);
81 
82  // AHu: As of June'18, there is no difference between the two relation CodeGen
83  // functions, so I am refactoring this function to just take two arguments,
84  // and using it to be the only relational switch statement
85  llvm::Value *applyBinaryRelationalCodeGen(const libsbml::ASTNode *ast,
86  llvm::Value* left, llvm::Value* right);
87 
88  // JKM: NOTE: Not SBML-compliant, needed for idiosyncrasies in some legacy JDesigner models
89  llvm::Value *applyScalarRelationalCodeGen(const libsbml::ASTNode *ast);
90 
91  // Ahu: I made this just so that later we can have an interface for non-scalar relations
92  llvm::Value *applyRelationalCodeGen(const libsbml::ASTNode *ast);
93 
94  llvm::Value *applyLogicalCodeGen(const libsbml::ASTNode *ast);
95 
96  llvm::Value *functionCallCodeGen(const libsbml::ASTNode *ast);
97 
98  llvm::Value *intrinsicCallCodeGen(const libsbml::ASTNode *ast);
99 
100  llvm::Value *piecewiseCodeGen(const libsbml::ASTNode *ast);
101 
107  llvm::Value *toBoolean(llvm::Value *value);
108 
114  llvm::Value *toDouble(llvm::Value* value);
115 
116 
117  llvm::IRBuilder<> &builder;
118  LoadSymbolResolver &resolver;
119  const ModelGeneratorContext& ctx;
120  llvm::Value *modelData;
121 
130  llvm::Module *getModule();
131 
132  bool scalar_mode_;
133 
134  friend class ASTNodeCodeGenScalarTicket;
135 };
136 
137 std::string to_string(const libsbml::ASTNode *ast);
138 
144  public:
145  ASTNodeCodeGenScalarTicket(ASTNodeCodeGen& gen, bool val, std::string n = "");
146 
148 
149  private:
150  ASTNodeCodeGen& z_;
151  bool v_;
152  std::string n_;
153 };
154 
155 } /* namespace rr */
156 
157 #endif /* ASTNodeCodeGenH */
Used in LoadSymbolResolverBase::loadReactionRate when resolving a kinetic law.
Definition: ASTNodeCodeGen.h:143
All of the LLVM IR generation is handled here.
Definition: ASTNodeCodeGen.h:31
LLVM load instruction class.
Definition: CodeGen.h:37
All LLVM code generating objects basically need at a minimum three things to operate:
Definition: ModelGeneratorContext.h:95