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

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

The framework for the unicode categories is in place. The static c++ code for each of the categories just needs to be placed into the stub unicode categories class.

File size: 4.0 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::string basis_pattern, std::string lf_ccname, int bits);
104    ~LLVM_Generator();
105    LLVM_Gen_RetVal Generate_LLVMIR(CodeGenState cg_state,
106                                    std::list<PabloS*> cc_cgo);
107    void Print_Register(char* name, BitBlock bit_block);
108    BitBlock Get_UnicodeCategory(const char* name);
109private:
110    void MakeLLVMModule();
111    void DefineTypes();
112    void DeclareFunctions();
113    void StoreBitBlockMarkerPtr(std::string name, int index);
114    void LoadBitBlocksFromStaticExtern();
115    void SetReturnMarker(std::string marker, int output_idx);
116    Value* GetMarker(std::string name);
117    std::string Generate_PabloStatements(std::list<PabloS*> stmts);
118    std::string Generate_PabloS(PabloS* stmt);
119    Value* Generate_PabloE(PabloE* expr);
120
121    int         mBits;
122    std::string m_lf_ccname;
123    std::string mBasis_Pattern;
124
125    Module*          mMod;
126    BasicBlock*      mBasicBlock;
127
128    ExecutionEngine* mExecutionEngine;
129
130    VectorType*  m64x2Vect;
131    PointerType* m64x2Vect_Ptr1;
132
133    VectorType* m128x1Vect;
134
135    PointerType* mStruct_Basis_Bits_Ptr1;
136    PointerType* mStruct_Output_Ptr1;
137
138    std::map<std::string, Value*> mMarkerMap;
139
140    int         mCarryQueueIdx;
141    Value*      mptr_carry_q;
142
143    int         mCarryQueueSize;
144
145    ConstantInt*           mConst_int64_neg1;
146    ConstantAggregateZero* mConst_Aggregate_64x2_0;
147    Constant*              mConst_Aggregate_64x2_neg1;
148
149    FunctionType* mFuncTy_0;
150    Function*     mFunc_process_block;
151
152    Constant*     mFunc_print_register;
153    Constant*     mFunc_test_getCategory;
154    Constant*     mFunc_get_unicode_category;
155
156    AllocaInst*  mPtr_basis_bits_addr;
157    AllocaInst*  mPtr_carry_q_addr;
158    AllocaInst*  mPtr_output_addr;
159};
160
161
162#endif // LLVM_GENERATOR_H
Note: See TracBrowser for help on using the repository browser.