updates template and adds braces when using conditions
This commit is contained in:
		| @@ -38,7 +38,9 @@ | ||||
| #include <asmjit/asmjit.h> | ||||
| #include <util/logging.h> | ||||
| #include <iss/instruction_decoder.h> | ||||
|  | ||||
| <%def fcsr = registers.find {it.name=='FCSR'} | ||||
| if(fcsr != null) {%> | ||||
| #include <vm/fp_functions.h><%}%> | ||||
| #ifndef FMT_HEADER_ONLY | ||||
| #define FMT_HEADER_ONLY | ||||
| #endif | ||||
| @@ -100,7 +102,9 @@ protected: | ||||
|     void gen_block_prologue(jit_holder& jh) override; | ||||
|     void gen_block_epilogue(jit_holder& jh) override; | ||||
|     inline const char *name(size_t index){return traits::reg_aliases.at(index);} | ||||
|  | ||||
| <%if(fcsr != null) {%> | ||||
|     inline const char *fname(size_t index){return index < 32?name(index+traits::F0):"illegal";}    | ||||
| <%}%> | ||||
|     void gen_instr_prologue(jit_holder& jh); | ||||
|     void gen_instr_epilogue(jit_holder& jh); | ||||
|     inline void gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t cause); | ||||
| @@ -112,7 +116,10 @@ protected: | ||||
|         auto mask = (1ULL<<W) - 1; | ||||
|         auto sign_mask = 1ULL<<(W-1); | ||||
|         return (from & mask) | ((from & sign_mask) ? ~mask : 0); | ||||
|     }  | ||||
|     } | ||||
| <%functions.each{ it.eachLine { %> | ||||
|     ${it}<%}%> | ||||
| <%}%> | ||||
| private: | ||||
|     /**************************************************************************** | ||||
|      * start opcode definitions | ||||
|   | ||||
| @@ -112,7 +112,8 @@ protected: | ||||
|         auto mask = (1ULL<<W) - 1; | ||||
|         auto sign_mask = 1ULL<<(W-1); | ||||
|         return (from & mask) | ((from & sign_mask) ? ~mask : 0); | ||||
|     }  | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     /**************************************************************************** | ||||
|      * start opcode definitions | ||||
| @@ -500,6 +501,7 @@ private: | ||||
|                 (gen_operation(cc, band, (gen_operation(cc, add, load_reg_from_mem(jh, traits::X0 + rs1), (int16_t)sext<12>(imm)) | ||||
|                 ), addr_mask) | ||||
|                 ), 32, true); | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, urem, new_pc, static_cast<uint32_t>(traits::INSTR_ALIGNMENT)) | ||||
|             ,0); | ||||
| @@ -521,6 +523,7 @@ private: | ||||
|                     mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), static_cast<int>(UNKNOWN_JUMP)); | ||||
|                 } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = BRANCH; | ||||
|          | ||||
| @@ -566,6 +569,7 @@ private: | ||||
|             gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); | ||||
|         } | ||||
|         else{ | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, eq, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) | ||||
|             ,0); | ||||
| @@ -583,6 +587,7 @@ private: | ||||
|                 } | ||||
|             } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = BRANCH; | ||||
|          | ||||
| @@ -628,6 +633,7 @@ private: | ||||
|             gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); | ||||
|         } | ||||
|         else{ | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, ne, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) | ||||
|             ,0); | ||||
| @@ -645,6 +651,7 @@ private: | ||||
|                 } | ||||
|             } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = BRANCH; | ||||
|          | ||||
| @@ -690,6 +697,7 @@ private: | ||||
|             gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); | ||||
|         } | ||||
|         else{ | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, lt, gen_ext(cc,  | ||||
|                 load_reg_from_mem(jh, traits::X0 + rs1), 32, false), gen_ext(cc,  | ||||
| @@ -709,6 +717,7 @@ private: | ||||
|                 } | ||||
|             } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = BRANCH; | ||||
|          | ||||
| @@ -754,6 +763,7 @@ private: | ||||
|             gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); | ||||
|         } | ||||
|         else{ | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, gte, gen_ext(cc,  | ||||
|                 load_reg_from_mem(jh, traits::X0 + rs1), 32, false), gen_ext(cc,  | ||||
| @@ -773,6 +783,7 @@ private: | ||||
|                 } | ||||
|             } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = BRANCH; | ||||
|          | ||||
| @@ -818,6 +829,7 @@ private: | ||||
|             gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); | ||||
|         } | ||||
|         else{ | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, ltu, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) | ||||
|             ,0); | ||||
| @@ -835,6 +847,7 @@ private: | ||||
|                 } | ||||
|             } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = BRANCH; | ||||
|          | ||||
| @@ -880,6 +893,7 @@ private: | ||||
|             gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); | ||||
|         } | ||||
|         else{ | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, gteu, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) | ||||
|             ,0); | ||||
| @@ -897,6 +911,7 @@ private: | ||||
|                 } | ||||
|             } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = BRANCH; | ||||
|          | ||||
| @@ -3116,6 +3131,7 @@ private: | ||||
|             auto divisor = gen_ext(cc,  | ||||
|                 load_reg_from_mem(jh, traits::X0 + rs2), 32, true); | ||||
|             if(rd!=0){ | ||||
|                 { | ||||
|                 auto label_merge = cc.newLabel(); | ||||
|                 cmp(cc, gen_operation(cc, ne, divisor, 0) | ||||
|                 ,0); | ||||
| @@ -3123,6 +3139,7 @@ private: | ||||
|                 cc.je(label_else); | ||||
|                 { | ||||
|                     auto MMIN = ((uint32_t)1)<<(static_cast<uint32_t>(traits::XLEN)-1); | ||||
|                     { | ||||
|                     auto label_merge = cc.newLabel(); | ||||
|                     cmp(cc, gen_operation(cc, land, gen_operation(cc, eq, load_reg_from_mem(jh, traits::X0 + rs1), MMIN) | ||||
|                     , gen_operation(cc, eq, divisor, - 1) | ||||
| @@ -3143,6 +3160,7 @@ private: | ||||
|                                       ), 32, true)); | ||||
|                         } | ||||
|                     cc.bind(label_merge); | ||||
|                     } | ||||
|                 } | ||||
|                 cc.jmp(label_merge); | ||||
|                 cc.bind(label_else); | ||||
| @@ -3151,6 +3169,7 @@ private: | ||||
|                               (uint32_t)- 1); | ||||
|                     } | ||||
|                 cc.bind(label_merge); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = CONT; | ||||
| @@ -3196,6 +3215,7 @@ private: | ||||
|             gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); | ||||
|         } | ||||
|         else{ | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, ne, load_reg_from_mem(jh, traits::X0 + rs2), 0) | ||||
|             ,0); | ||||
| @@ -3217,6 +3237,7 @@ private: | ||||
|                     } | ||||
|                 } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = CONT; | ||||
|          | ||||
| @@ -3261,6 +3282,7 @@ private: | ||||
|             gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); | ||||
|         } | ||||
|         else{ | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, ne, load_reg_from_mem(jh, traits::X0 + rs2), 0) | ||||
|             ,0); | ||||
| @@ -3268,6 +3290,7 @@ private: | ||||
|             cc.je(label_else); | ||||
|             { | ||||
|                 auto MMIN = (uint32_t)1<<(static_cast<uint32_t>(traits::XLEN)-1); | ||||
|                 { | ||||
|                 auto label_merge = cc.newLabel(); | ||||
|                 cmp(cc, gen_operation(cc, land, gen_operation(cc, eq, load_reg_from_mem(jh, traits::X0 + rs1), MMIN) | ||||
|                 , gen_operation(cc, eq, gen_ext(cc,  | ||||
| @@ -3296,6 +3319,7 @@ private: | ||||
|                         } | ||||
|                     } | ||||
|                 cc.bind(label_merge); | ||||
|                 } | ||||
|             } | ||||
|             cc.jmp(label_merge); | ||||
|             cc.bind(label_else); | ||||
| @@ -3306,6 +3330,7 @@ private: | ||||
|                     } | ||||
|                 } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = CONT; | ||||
|          | ||||
| @@ -3350,6 +3375,7 @@ private: | ||||
|             gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); | ||||
|         } | ||||
|         else{ | ||||
|             { | ||||
|             auto label_merge = cc.newLabel(); | ||||
|             cmp(cc, gen_operation(cc, ne, load_reg_from_mem(jh, traits::X0 + rs2), 0) | ||||
|             ,0); | ||||
| @@ -3371,6 +3397,7 @@ private: | ||||
|                     } | ||||
|                 } | ||||
|             cc.bind(label_merge); | ||||
|             } | ||||
|         } | ||||
|         auto returnValue = CONT; | ||||
|          | ||||
| @@ -4194,6 +4221,7 @@ private: | ||||
|         cc.comment("//behavior:"); | ||||
|         /*generate behavior*/ | ||||
|         mov(jh.cc, get_ptr_for(jh, traits::LAST_BRANCH), static_cast<int>(NO_JUMP)); | ||||
|         { | ||||
|         auto label_merge = cc.newLabel(); | ||||
|         cmp(cc, gen_operation(cc, eq, load_reg_from_mem(jh, traits::X0 + rs1+8), 0) | ||||
|         ,0); | ||||
| @@ -4204,6 +4232,7 @@ private: | ||||
|             mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), static_cast<int>(KNOWN_JUMP)); | ||||
|         } | ||||
|         cc.bind(label_merge); | ||||
|         } | ||||
|         auto returnValue = BRANCH; | ||||
|          | ||||
|         gen_sync(jh, POST_SYNC, 75); | ||||
| @@ -4243,6 +4272,7 @@ private: | ||||
|         cc.comment("//behavior:"); | ||||
|         /*generate behavior*/ | ||||
|         mov(jh.cc, get_ptr_for(jh, traits::LAST_BRANCH), static_cast<int>(NO_JUMP)); | ||||
|         { | ||||
|         auto label_merge = cc.newLabel(); | ||||
|         cmp(cc, gen_operation(cc, ne, load_reg_from_mem(jh, traits::X0 + rs1+8), 0) | ||||
|         ,0); | ||||
| @@ -4253,6 +4283,7 @@ private: | ||||
|             mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), static_cast<int>(KNOWN_JUMP)); | ||||
|         } | ||||
|         cc.bind(label_merge); | ||||
|         } | ||||
|         auto returnValue = BRANCH; | ||||
|          | ||||
|         gen_sync(jh, POST_SYNC, 76); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user