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

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

The Unicode category 'Nd' is in place and it is working.

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