source: icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h @ 4870

Last change on this file since 4870 was 4870, checked in by nmedfort, 3 years ago

Bug fix for Multiplexing. Added ability to set the body of a If/While? node after creation.

File size: 3.2 KB
RevLine 
[3850]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
[4237]7#ifndef PABLO_COMPILER_H
8#define PABLO_COMPILER_H
9
[4240]10//indicates that we use llvm.uadd.with.overflow.carryin for genAddWithCarry
[4237]11//#define USE_UADD_OVERFLOW
[4289]12//#define USE_LONG_INTEGER_SHIFT
[4301]13//#define USE_TWO_UADD_OVERFLOW
[4237]14
[4301]15#if defined(USE_TWO_UADD_OVERFLOW) && !defined(USE_UADD_OVERFLOW)
16static_assert(false, "Need to turn on them together.");
17#endif
18
[4237]19//Pablo Expressions
20#include <string>
21#include <list>
[4417]22#include <vector>
[4237]23#include <map>
24#include <algorithm>
[4510]25#include <unordered_map>
26#include <pablo/pe_string.h>
[4647]27#include <pablo/carry_manager.h>
[4274]28#include <llvm/ADT/Twine.h>
[4628]29#include <llvm/IR/IRBuilder.h>
[4663]30#include <IDISA/idisa_builder.h>
[4237]31
[4274]32namespace llvm {
33    class Value;
34    class Module;
35    class ExecutionEngine;
36    class VectorType;
37    class PointerType;
38    class ConstantAggregateZero;
39    class Constant;
40    class FunctionType;
41    class Function;
[4416]42    class BasicBlock;
[4274]43}
[4237]44
[4416]45namespace pablo {
46
[4237]47using namespace llvm;
48
[4416]49class PabloAST;
50class PabloBlock;
[4657]51class PabloFunction;
[4416]52class String;
53class Var;
54class Statement;
55class StatementList;
[4535]56class If;
57class While;
[4237]58
[4537]59#if (BLOCK_SIZE==256)
60#define USE_UADD_OVERFLOW
61#define USE_TWO_UADD_OVERFLOW
62#endif
[4237]63
64class PabloCompiler {
[4240]65    #ifdef USE_UADD_OVERFLOW
66    struct SumWithOverflowPack {
67        Value * sum;
68        Value * obit;
69    };
70    #endif
[4257]71
[4674]72    typedef std::unordered_map<const pablo::PabloAST *, Value *>   ASTToValueMap;
[4410]73    typedef std::vector<Value*>                                    CarryQueueVector;
[4257]74
[4237]75public:
[4839]76    PabloCompiler(Type * bitBlockType);
[4237]77    ~PabloCompiler();
[4734]78    Function * compile(pablo::PabloFunction * function);
79    Function * compile(pablo::PabloFunction * function, Module *module);
[4665]80    Module *getModule();
[4237]81private:
[4659]82    void GenerateFunction(PabloFunction & function);
[4665]83    void Examine(PabloFunction & function);
[4870]84    void Examine(PabloBlock * block);
[4684]85
[4268]86    void SetOutputValue(Value * marker, const unsigned index);
[4237]87
[4870]88    void compileBlock(PabloBlock * block);
[4410]89    void compileStatement(const Statement * stmt);
[4535]90    void compileIf(const If * ifStmt);
91    void compileWhile(const While * whileStmt);
[4244]92    Value* compileExpression(const PabloAST * expr);
[4237]93
[4510]94    ASTToValueMap                       mMarkerMap;
[4545]95    CarryQueueVector                    mCarryInVector;
96    CarryQueueVector                    mCarryOutVector;
[4237]97
[4665]98
[4572]99    Module *                            mMod;
[4628]100    IRBuilder <> *                      mBuilder;
[4663]101
[4647]102    CarryManager *                      mCarryManager;
[4237]103
[4837]104    Type* const                   mBitBlockType;
[4663]105    IDISA::IDISA_Builder                iBuilder;
[4665]106    PointerType*                        mInputType;
[4237]107
[4640]108    PabloBlock *                        mPabloBlock;
109   
[4545]110    unsigned                            mWhileDepth;
111    unsigned                            mIfDepth;
[4237]112
[4659]113    Function *                          mFunction;
114    Value *                             mInputAddressPtr;
115    Value *                             mOutputAddressPtr;
[4237]116
[4545]117    unsigned                            mMaxWhileDepth;
[4273]118
[4237]119};
120
[4661]121inline Module * PabloCompiler::getModule() {
122    return mMod;
[4237]123}
124
[4661]125}
126
[4237]127#endif // LLVM_GENERATOR_H
Note: See TracBrowser for help on using the repository browser.