Goose  Diff

Differences From Artifact [62d939ce04]:

  • File bs/codegen/module.h — part of check-in [1c33db7499] at 2020-03-07 16:36:09 on branch trunk — More work and fixes on references. Reading a tuple member using the . operator (which returns a constant reference) is now working. (user: achavasse size: 5665)

To Artifact [e5cb843988]:

  • File bs/codegen/module.h — part of check-in [e814ad7e23] at 2020-04-11 21:01:58 on branch trunk —
    • Implemented load, store and pointers in execute and codegen.
    • Implemented load and pointers in verify.
    • When unifying a local variable against a parameter, generate a reference.
    (user: achavasse size: 6500)

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
29
30
31
32
33
34
35

36
37
38
39
40
41
42







-







            bool emitToFile( const string& filename, llvm::TargetMachine::CodeGenFileType type );

        private:
            struct Infos
            {
                Infos( const Context& c ) : context( c ) {}
                const Context& context;
                llvm::SmallVector< llvm::Value*, 8 > m_locals;

                llvm::BasicBlock* allocaBasicBlock = nullptr;
                llvm::AllocaInst* lastEmittedAlloca = nullptr;

                using storage_type = llr::TempStorage< NullInit< llvm::Value* > >;
                ptr< storage_type > temporaries = make_shared< storage_type >();
            };
101
102
103
104
105
106
107











108
109
110
111
112
113
114
115
116
117
118
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128







+
+
+
+
+
+
+
+
+
+
+












            template< typename T >
            bool buildTerminator( Infos& inf, const T& t )
            {
                return false;
            }

            llvm::Value* buildPointer( Infos& inf, const Pointer& ptr );
            llvm::Value* buildPointer( Infos& inf, const llr::TemporaryAddress& ta );
            llvm::Value* buildPointer( Infos& inf, const llr::VarAddress& va );
            llvm::Value* buildPointer( Infos& inf, const unique_ptr< llr::GEP >& gep );

            llvm::Value* buildGEP( Infos& inf, llvm::SmallVector< llvm::Value*, 4 >& indices, const Pointer& ptr );
            llvm::Value* buildGEP( Infos& inf, llvm::SmallVector< llvm::Value*, 4 >& indices, const llr::TemporaryAddress& ta );
            llvm::Value* buildGEP( Infos& inf, llvm::SmallVector< llvm::Value*, 4 >& indices, const llr::VarAddress& va );
            llvm::Value* buildGEP( Infos& inf, llvm::SmallVector< llvm::Value*, 4 >& indices, const unique_ptr< llr::GEP >& gep );

            llvm::Value* buildAlloca( Infos& inf, llvm::Type* type );
            llvm::Value* createTemporary( Infos& inf, uint32_t index, llvm::Value* pValue ) const;

            llvm::Module m_llvmModule;
            llvm::IRBuilder<> m_llvmBuilder;
            llvm::TargetMachine* m_targetMachine = nullptr;

            unordered_map< string, llvm::GlobalVariable* > m_strings;
    };
}

#endif