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

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

A change to the way unicode categories are handled. This version supports the unicode categlry 'Nd'.

File size: 4.1 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//TODO: Remove
47//#include "unicode_categories.h"
48
49#include "categories_Nd.h"
50
51
52#include <iostream>
53#include <string>
54#include <sstream>
55#include <list>
56#include <map>
57#include <algorithm>
58
59#include <llvm/Support/raw_ostream.h>
60
61#include <llvm/Pass.h>
62#include <llvm/PassManager.h>
63#include <llvm/ADT/SmallVector.h>
64#include <llvm/Analysis/Verifier.h>
65#include "llvm/Analysis/Passes.h"
66#include <llvm/Assembly/PrintModulePass.h>
67#include <llvm/IR/BasicBlock.h>
68#include <llvm/IR/CallingConv.h>
69#include <llvm/IR/Constants.h>
70#include "llvm/IR/DataLayout.h"
71#include "llvm/IR/DerivedTypes.h"
72#include <llvm/IR/Function.h>
73#include <llvm/IR/GlobalVariable.h>
74#include <llvm/IR/InlineAsm.h>
75#include <llvm/IR/Instructions.h>
76#include <llvm/IR/LLVMContext.h>
77#include <llvm/IR/Module.h>
78#include <llvm/Support/FormattedStream.h>
79#include <llvm/Support/MathExtras.h>
80#include <llvm/Support/Casting.h>
81
82#include "llvm/Support/TargetSelect.h"
83#include "llvm/Transforms/Scalar.h"
84
85#include <llvm/ExecutionEngine/ExecutionEngine.h>
86#include <llvm/ExecutionEngine/MCJIT.h>
87
88#include <llvm/Linker.h>
89#include <llvm/IRReader/IRReader.h>
90#include <llvm/Bitcode/ReaderWriter.h>
91#include <llvm/Support/MemoryBuffer.h>
92
93#include <llvm/IR/IRBuilder.h>
94
95#include <simd-lib/bitblock.hpp>
96
97using namespace llvm;
98
99struct LLVM_Gen_RetVal
100{
101    int carry_q_size;
102    void *process_block_fptr;
103};
104
105class LLVM_Generator
106{
107public:
108    LLVM_Generator(std::map<std::string, std::string> name_map, std::string basis_pattern, int bits);
109    ~LLVM_Generator();
110    LLVM_Gen_RetVal Generate_LLVMIR(CodeGenState cg_state,
111                                    CodeGenState subexpression_cg_state,
112                                    std::list<PabloS*> cc_cgo);
113private:
114    void MakeLLVMModule();
115    void DefineTypes();
116    void DeclareFunctions();
117    void StoreBitBlockMarkerPtr(std::string name, int index);
118    void LoadBitBlocksFromStaticExtern();
119    void SetReturnMarker(std::string marker, int output_idx);
120    Value* GetMarker(std::string name);
121    std::string Generate_PabloStatements(std::list<PabloS*> stmts);
122    std::string Generate_PabloS(PabloS* stmt);
123    Value* Generate_PabloE(PabloE* expr);
124
125    int         mBits;
126    std::map<std::string, std::string> m_name_map;
127    std::string mBasis_Pattern;
128
129    Module*          mMod;
130    BasicBlock*      mBasicBlock;
131
132    ExecutionEngine* mExecutionEngine;
133
134    VectorType*  m64x2Vect;
135    PointerType* m64x2Vect_Ptr1;
136
137    VectorType* m128x1Vect;
138
139    PointerType* mStruct_Basis_Bits_Ptr1;
140    PointerType* mStruct_Output_Ptr1;
141
142    std::map<std::string, Value*> mMarkerMap;
143
144    int         mCarryQueueIdx;
145    Value*      mptr_carry_q;
146
147    int         mCarryQueueSize;
148
149    ConstantInt*           mConst_int64_neg1;
150    ConstantAggregateZero* mConst_Aggregate_64x2_0;
151    Constant*              mConst_Aggregate_64x2_neg1;
152
153    FunctionType* mFuncTy_0;
154    Function*     mFunc_process_block;
155
156    Constant*     mFunc_print_register;
157    Constant*     mFunc_test_getCategory;
158    Constant*     mFunc_get_unicode_category;
159    Constant*     mFunc_get_unicode_category_Nd;
160
161    AllocaInst*  mPtr_basis_bits_addr;
162    AllocaInst*  mPtr_carry_q_addr;
163    AllocaInst*  mPtr_output_addr;
164};
165
166
167#endif // LLVM_GENERATOR_H
Note: See TracBrowser for help on using the repository browser.