Mercurial > octave-nkf
diff libinterp/corefcn/jit-ir.h @ 20654:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 1f9ed81bd173 |
children |
line wrap: on
line diff
--- a/libinterp/corefcn/jit-ir.h Tue Oct 13 11:40:05 2015 +0100 +++ b/libinterp/corefcn/jit-ir.h Fri Feb 27 16:59:36 2015 +0100 @@ -25,7 +25,7 @@ #if !defined (octave_jit_ir_h) #define octave_jit_ir_h 1 -#ifdef HAVE_LLVM +#ifdef HAVE_JIT #include <list> #include <stack> @@ -188,7 +188,11 @@ jit_value : public jit_internal_list<jit_value, jit_use> { public: - jit_value (void) : llvm_value (0), ty (0), mlast_use (0), + jit_value (void) : llvm_value (0), +#ifdef HAVE_GCCJIT + m_gcc_lvalue (), m_gcc_rvalue (), +#endif + ty (0), mlast_use (0), min_worklist (false) {} virtual ~jit_value (void); @@ -212,10 +216,19 @@ jit_type *type (void) const { return ty; } +#if HAVE_LLVM llvm::Type *type_llvm (void) const { return ty ? ty->to_llvm () : 0; } +#endif + +#if HAVE_GCCJIT + gccjit::type type_gccjit (void) const + { + return ty ? ty->to_gccjit () : gccjit::type (); + } +#endif const std::string& type_name (void) const { @@ -247,6 +260,7 @@ virtual void accept (jit_ir_walker& walker) = 0; +#if HAVE_LLVM bool has_llvm (void) const { return llvm_value; @@ -262,6 +276,34 @@ { llvm_value = compiled; } +#endif + +#if HAVE_GCCJIT + bool has_lvalue (void) const + { + return m_gcc_lvalue.get_inner_lvalue (); + } + bool has_rvalue (void) const + { + return m_gcc_rvalue.get_inner_rvalue (); + } + gccjit::lvalue as_lvalue (void) const + { + return m_gcc_lvalue; + } + gccjit::rvalue as_rvalue (void) const + { + return m_gcc_rvalue; + } + void stash_lvalue (gccjit::lvalue lvalue) + { + m_gcc_lvalue = lvalue; + } + void stash_rvalue (gccjit::rvalue rvalue) + { + m_gcc_rvalue = rvalue; + } +#endif protected: std::ostream& print_indent (std::ostream& os, size_t indent = 0) const @@ -271,7 +313,13 @@ return os; } +#if HAVE_LLVM llvm::Value *llvm_value; +#endif +#if HAVE_GCCJIT + gccjit::lvalue m_gcc_lvalue; + gccjit::rvalue m_gcc_rvalue; +#endif private: jit_type *ty; jit_instruction *mlast_use; @@ -371,22 +419,26 @@ return marguments[i].value (); } +#if HAVE_LLVM llvm::Value *argument_llvm (size_t i) const { assert (argument (i)); return argument (i)->to_llvm (); } +#endif jit_type *argument_type (size_t i) const { return argument (i)->type (); } +#if HAVE_LLVM llvm::Type *argument_type_llvm (size_t i) const { assert (argument (i)); return argument_type (i)->to_llvm (); } +#endif std::ostream& print_argument (std::ostream& os, size_t i) const { @@ -452,7 +504,9 @@ return mlocation; } +#if HAVE_LLVM llvm::BasicBlock *parent_llvm (void) const; +#endif void stash_parent (jit_block *aparent, std::list<jit_instruction *>::iterator alocation) @@ -494,10 +548,10 @@ jit_argument : public jit_value { public: - jit_argument (jit_type *atype, llvm::Value *avalue) + jit_argument (jit_type *atype/*, llvm::Value *avalue*/) { stash_type (atype); - stash_llvm (avalue); + //stash_llvm (avalue); } virtual std::ostream& print (std::ostream& os, size_t indent = 0) const @@ -584,6 +638,13 @@ const std::string& name (void) const { return mname; } + std::string name_and_id (void) const + { + std::ostringstream os; + short_print (os); + return os.str (); + } + jit_instruction *prepend (jit_instruction *instr); jit_instruction *prepend_after_phi (jit_instruction *instr); @@ -719,7 +780,9 @@ return os; } +#if HAVE_LLVM llvm::BasicBlock *to_llvm (void) const; +#endif std::list<jit_block *>::iterator location (void) const { return mlocation; } @@ -975,10 +1038,12 @@ return mincomming[i].value (); } +#if HAVE_LLVM llvm::BasicBlock *incomming_llvm (size_t i) const { return incomming (i)->to_llvm (); } +#endif virtual void construct_ssa (void) { } @@ -1009,7 +1074,9 @@ return os; } +#if HAVE_LLVM llvm::PHINode *to_llvm (void) const; +#endif JIT_VALUE_ACCEPT; private: @@ -1037,10 +1104,12 @@ return static_cast<jit_block *> (argument (idx)); } +#if HAVE_LLVM llvm::BasicBlock *successor_llvm (size_t idx = 0) const { return successor (idx)->to_llvm (); } +#endif size_t successor_index (const jit_block *asuccessor) const; @@ -1068,7 +1137,9 @@ virtual bool infer (void); +#if HAVE_LLVM llvm::TerminatorInst *to_llvm (void) const; +#endif protected: virtual bool check_alive (size_t) const { return true; } private: @@ -1106,10 +1177,12 @@ return cond ()->short_print (os); } +#if HAVE_LLVM llvm::Value *cond_llvm (void) const { return cond ()->to_llvm (); } +#endif virtual size_t successor_count (void) const { return 2; } @@ -1351,10 +1424,12 @@ return result ()->type (); } +#if HAVE_LLVM llvm::Value *result_llvm (void) const { return result ()->to_llvm (); } +#endif virtual std::ostream& print (std::ostream& os, size_t indent = 0) const { @@ -1431,5 +1506,5 @@ #undef JIT_VALUE_ACCEPT +#endif /* ifdef HAVE_JIT */ #endif -#endif