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

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

The parser is now able to parse unicode categories.

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