source: icGREP/icgrep-devel/icgrep/llvm_gen.h @ 3994

Last change on this file since 3994 was 3991, checked in by daled, 5 years ago

Minor changes.

File size: 4.2 KB
Line 
1/*
2 *  Copyright (c) 2014 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef LLVM_GENERATOR_H
8#define LLVM_GENERATOR_H
9
10//Regular Expressions
11#include "re_re.h"
12#include "re_cc.h"
13#include "re_name.h"
14#include "re_start.h"
15#include "re_end.h"
16#include "re_seq.h"
17#include "re_alt.h"
18#include "re_rep.h"
19
20//Pablo Expressions
21#include "pe_pabloe.h"
22#include "pe_sel.h"
23#include "pe_advance.h"
24#include "pe_all.h"
25#include "pe_and.h"
26#include "pe_charclass.h"
27#include "pe_matchstar.h"
28#include "pe_not.h"
29#include "pe_or.h"
30#include "pe_call.h"
31#include "pe_var.h"
32#include "pe_xor.h"
33
34//Pablo Statements
35#include "ps_pablos.h"
36#include "ps_assign.h"
37#include "ps_if.h"
38#include "ps_while.h"
39
40#include "cc_codegenobject.h"
41
42#include "pbix_compiler.h"
43
44#include "llvm_gen_helper.h"
45
46//#include "unicode_categories.h"
47//#include "unicode_categories-flat.h"
48#include "unicode_categories-simple.h"
49
50#include <iostream>
51#include <string>
52#include <sstream>
53#include <list>
54#include <map>
55#include <algorithm>
56
57#include <llvm/Support/raw_ostream.h>
58
59#include <llvm/Pass.h>
60#include <llvm/PassManager.h>
61#include <llvm/ADT/SmallVector.h>
62#include <llvm/Analysis/Verifier.h>
63#include "llvm/Analysis/Passes.h"
64#include <llvm/Assembly/PrintModulePass.h>
65#include <llvm/IR/BasicBlock.h>
66#include <llvm/IR/CallingConv.h>
67#include <llvm/IR/Constants.h>
68#include "llvm/IR/DataLayout.h"
69#include "llvm/IR/DerivedTypes.h"
70#include <llvm/IR/Function.h>
71#include <llvm/IR/GlobalVariable.h>
72#include <llvm/IR/InlineAsm.h>
73#include <llvm/IR/Instructions.h>
74#include <llvm/IR/LLVMContext.h>
75#include <llvm/IR/Module.h>
76#include <llvm/Support/FormattedStream.h>
77#include <llvm/Support/MathExtras.h>
78#include <llvm/Support/Casting.h>
79
80#include "llvm/Support/TargetSelect.h"
81#include "llvm/Transforms/Scalar.h"
82
83#include <llvm/ExecutionEngine/ExecutionEngine.h>
84#include <llvm/ExecutionEngine/MCJIT.h>
85
86#include <llvm/Linker.h>
87#include <llvm/IRReader/IRReader.h>
88#include <llvm/Bitcode/ReaderWriter.h>
89#include <llvm/Support/MemoryBuffer.h>
90
91#include <llvm/IR/IRBuilder.h>
92
93#include <simd-lib/bitblock.hpp>
94
95using namespace llvm;
96
97struct LLVM_Gen_RetVal
98{
99    int carry_q_size;
100    void *process_block_fptr;
101};
102
103class LLVM_Generator
104{
105public:
106    LLVM_Generator(std::map<std::string, std::string> name_map, std::string basis_pattern, int bits);
107    ~LLVM_Generator();
108    LLVM_Gen_RetVal Generate_LLVMIR(CodeGenState cg_state,
109                                    CodeGenState subexpression_cg_state,
110                                    std::list<PabloS*> cc_cgo);
111private:
112    void MakeLLVMModule();
113    void DefineTypes();
114    void DeclareFunctions();
115    void DeclareCallFunctions(std::list<PabloS*> stmts);
116    void DeclareCallFunctions_PabloS(PabloS* stmt);
117    void DeclareCallFunctions_PabloE(PabloE* expr);
118    void StoreBitBlockMarkerPtr(std::string name, int index);
119    void LoadBitBlocksFromStaticExtern();
120    void SetReturnMarker(std::string marker, int output_idx);
121    Value* GetMarker(std::string name);
122    std::string Generate_PabloStatements(std::list<PabloS*> stmts);
123    std::string Generate_PabloS(PabloS* stmt);
124    Value* Generate_PabloE(PabloE* expr);
125
126    int         mBits;
127    std::map<std::string, std::string> m_name_map;
128    std::string mBasis_Pattern;
129
130    Module*          mMod;
131    BasicBlock*      mBasicBlock;
132
133    ExecutionEngine* mExecutionEngine;
134
135    VectorType*  m64x2Vect;
136    PointerType* m64x2Vect_Ptr1;
137
138    VectorType* m128x1Vect;
139
140    PointerType* mStruct_Basis_Bits_Ptr1;
141    PointerType* mStruct_Output_Ptr1;
142
143    std::map<std::string, Value*> mMarkerMap;
144
145    int         mCarryQueueIdx;
146    Value*      mptr_carry_q;
147
148    int         mCarryQueueSize;
149
150    ConstantInt*           mConst_int64_neg1;
151    ConstantAggregateZero* mConst_Aggregate_64x2_0;
152    Constant*              mConst_Aggregate_64x2_neg1;
153
154    FunctionType* mFuncTy_0;
155    Function*     mFunc_process_block;
156
157    Constant*     mFunc_print_register;
158    Constant*     mFunc_test_getCategory;
159    Constant*     mFunc_get_unicode_category;
160    Value*     mFunc_get_unicode_category_Nd;
161
162    AllocaInst*  mPtr_basis_bits_addr;
163    AllocaInst*  mPtr_carry_q_addr;
164    AllocaInst*  mPtr_output_addr;
165};
166
167
168#endif // LLVM_GENERATOR_H
Note: See TracBrowser for help on using the repository browser.