From d72478eb64cd99a39b754e7e1bba0e051bd29fe2 Mon Sep 17 00:00:00 2001 From: sergei Date: Thu, 28 Nov 2013 11:52:47 +0000 Subject: [PATCH] * Function tjvmaddnode.cmpnode2topcmp is, in fact, not specific to any target. Moved it to generic tcgaddnode and reused in tmipsaddnode, where the same functionality was implemented in different way. git-svn-id: trunk@26151 - --- compiler/jvm/njvmadd.pas | 29 ----------------------------- compiler/mips/ncpuadd.pas | 17 ++++------------- compiler/ncgadd.pas | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 44 deletions(-) diff --git a/compiler/jvm/njvmadd.pas b/compiler/jvm/njvmadd.pas index f6b1e44852..228cdec4bd 100644 --- a/compiler/jvm/njvmadd.pas +++ b/compiler/jvm/njvmadd.pas @@ -38,8 +38,6 @@ interface protected function jvm_first_addset: tnode; - function cmpnode2topcmp(unsigned: boolean): TOpCmp; - procedure second_generic_compare(unsigned: boolean); procedure pass_left_right;override; @@ -333,33 +331,6 @@ interface end; - function tjvmaddnode.cmpnode2topcmp(unsigned: boolean): TOpCmp; - begin - if not unsigned then - case nodetype of - gtn: result:=OC_GT; - gten: result:=OC_GTE; - ltn: result:=OC_LT; - lten: result:=OC_LTE; - equaln: result:=OC_EQ; - unequaln: result:=OC_NE; - else - internalerror(2011010412); - end - else - case nodetype of - gtn: result:=OC_A; - gten: result:=OC_AE; - ltn: result:=OC_B; - lten: result:=OC_BE; - equaln: result:=OC_EQ; - unequaln: result:=OC_NE; - else - internalerror(2011010412); - end; - end; - - procedure tjvmaddnode.second_generic_compare(unsigned: boolean); var cmpop: TOpCmp; diff --git a/compiler/mips/ncpuadd.pas b/compiler/mips/ncpuadd.pas index a98ea28703..7e0b486eec 100644 --- a/compiler/mips/ncpuadd.pas +++ b/compiler/mips/ncpuadd.pas @@ -68,29 +68,20 @@ uses {***************************************************************************** tmipsaddnode *****************************************************************************} -const - swapped_nodetype: array[ltn..unequaln] of tnodetype = - //lt lte gt gte - (gtn, gten,ltn,lten, equaln, unequaln); - - nodetype2opcmp: array[boolean,ltn..unequaln] of TOpCmp = ( - (OC_LT, OC_LTE, OC_GT, OC_GTE, OC_EQ, OC_NE), - (OC_B, OC_BE, OC_A, OC_AE, OC_EQ, OC_NE) - ); procedure tmipsaddnode.second_generic_cmp32(unsigned: boolean); var - ntype: tnodetype; + cond: TOpCmp; begin pass_left_right; force_reg_left_right(True, True); location_reset(location,LOC_FLAGS,OS_NO); - ntype:=nodetype; + cond:=cmpnode2topcmp(unsigned); if nf_swapped in flags then - ntype:=swapped_nodetype[nodetype]; + cond:=swap_opcmp(cond); - location.resflags.cond:=nodetype2opcmp[unsigned,ntype]; + location.resflags.cond:=cond; location.resflags.reg1:=left.location.register; location.resflags.use_const:=(right.location.loc=LOC_CONSTANT); if location.resflags.use_const then diff --git a/compiler/ncgadd.pas b/compiler/ncgadd.pas index 3049f95582..950760a1bf 100644 --- a/compiler/ncgadd.pas +++ b/compiler/ncgadd.pas @@ -26,7 +26,7 @@ unit ncgadd; interface uses - node,nadd,cpubase; + node,nadd,cpubase,cgbase; type tcgaddnode = class(taddnode) @@ -40,6 +40,8 @@ interface { load left and right nodes into registers } procedure force_reg_left_right(allow_swap,allow_constant:boolean); + function cmpnode2topcmp(unsigned: boolean): TOpCmp; + procedure second_opfloat; procedure second_opboolean; procedure second_opsmallset; @@ -73,7 +75,7 @@ interface cutils,verbose,globals, symconst,symdef,paramgr, aasmbase,aasmtai,aasmdata,defutil, - cgbase,procinfo,pass_2,tgobj, + procinfo,pass_2,tgobj, nutils,ncon,nset,ncgutil,cgobj,cgutils, hlcgobj ; @@ -216,6 +218,32 @@ interface end; + function tcgaddnode.cmpnode2topcmp(unsigned: boolean): TOpCmp; + begin + if unsigned then + case nodetype of + gtn: result:=OC_A; + gten: result:=OC_AE; + ltn: result:=OC_B; + lten: result:=OC_BE; + equaln: result:=OC_EQ; + unequaln: result:=OC_NE; + else + internalerror(2011010412); + end + else + case nodetype of + gtn: result:=OC_GT; + gten: result:=OC_GTE; + ltn: result:=OC_LT; + lten: result:=OC_LTE; + equaln: result:=OC_EQ; + unequaln: result:=OC_NE; + else + internalerror(2011010412); + end + end; + {***************************************************************************** Smallsets *****************************************************************************}