diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/Makefile | 4 | ||||
-rw-r--r-- | compiler/Makefile.fpc | 8 | ||||
-rw-r--r-- | compiler/entfile.pas | 26 | ||||
-rw-r--r-- | compiler/mips/ncpuadd.pas | 25 | ||||
-rw-r--r-- | compiler/nadd.pas | 1 | ||||
-rw-r--r-- | compiler/ncginl.pas | 3 | ||||
-rw-r--r-- | compiler/options.pas | 88 | ||||
-rw-r--r-- | compiler/raatt.pas | 36 | ||||
-rw-r--r-- | compiler/riscv/agrvgas.pas | 4 | ||||
-rw-r--r-- | compiler/riscv/cgrv.pas | 45 | ||||
-rw-r--r-- | compiler/riscv/nrvadd.pas | 55 | ||||
-rw-r--r-- | compiler/riscv/rarv.pas (renamed from compiler/riscv64/rarv.pas) | 0 | ||||
-rw-r--r-- | compiler/riscv/rarvgas.pas | 819 | ||||
-rw-r--r-- | compiler/riscv32/cputarg.pas | 2 | ||||
-rw-r--r-- | compiler/riscv32/rarv32.pas | 41 | ||||
-rw-r--r-- | compiler/riscv32/rarv32gas.pas | 780 | ||||
-rw-r--r-- | compiler/riscv64/cputarg.pas | 2 | ||||
-rw-r--r-- | compiler/riscv64/rarv64gas.pas | 850 | ||||
-rw-r--r-- | compiler/x86/aoptx86.pas | 88 | ||||
-rw-r--r-- | compiler/x86/rgx86.pas | 18 |
20 files changed, 1127 insertions, 1768 deletions
diff --git a/compiler/Makefile b/compiler/Makefile index 821f0612d5..6c7e02ac48 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -4946,7 +4946,7 @@ endif $(COMPILER) pp.pas $(EXECPPAS) $(MOVE) $(COMPILER_TARGETDIR)/$(PPEXENAME) $(EXENAME) -.PHONY: cycle fullcycle wpocycle +.PHONY: cycle full full_targets fullcycle wpocycle ifeq ($(CPU_SOURCE),$(PPC_TARGET)) ifeq ($(OS_SOURCE),$(OS_TARGET)) ifndef NOWPOCYCLE @@ -5113,6 +5113,8 @@ ifdef DOWPOCYCLE $(MAKE) rtl 'FPC=$(BASEDIR)/$(EXENAMEPREFIX)$(EXENAME)' endif $(MAKE) $(FULL_TARGETS) 'FPC=$(BASEDIR)/$(EXENAMEPREFIX)$(EXENAME)' +full_targets: + $(MAKE) $(FULL_TARGETS) htmldocs: $(PASDOC) -p -h -o html$(PATHSEP)$(PPC_TARGET) -d fpc -d gdb -d $(PPC_TARGET) -u $(PPC_TARGET) $(PPC_TARGET)$(PATHSEP)*.pas systems$(PATHSEP)*.pas *.pas .PHONY: quickinstall exeinstall install installsymlink fullinstall fullinstallsymlink diff --git a/compiler/Makefile.fpc b/compiler/Makefile.fpc index df64aab8fd..38aa832ddf 100644 --- a/compiler/Makefile.fpc +++ b/compiler/Makefile.fpc @@ -851,7 +851,7 @@ endif # ##################################################################### -.PHONY: cycle fullcycle wpocycle +.PHONY: cycle full full_targets fullcycle wpocycle ifeq ($(CPU_SOURCE),$(PPC_TARGET)) @@ -1056,7 +1056,8 @@ cvstest: # unless FPC_SUPPORT_X87_TYPES_ON_WIN64 is set, # win64 cannot compile i386 or i8086 compiler # This is also the case for other CPUs that don't support -# 80bit real type. +# 80bit real type, unless -dFPC_SOFT_FPUX80 +# option is used. ifeq ($(findstring -dFPC_SOFT_FPUX80,$(LOCALOPT)),) ifeq ($(OS_SOURCE),win64) @@ -1086,6 +1087,9 @@ ifdef DOWPOCYCLE endif $(MAKE) $(FULL_TARGETS) 'FPC=$(BASEDIR)/$(EXENAMEPREFIX)$(EXENAME)' +full_targets: + $(MAKE) $(FULL_TARGETS) + ##################################################################### # Docs ##################################################################### diff --git a/compiler/entfile.pas b/compiler/entfile.pas index 8e2dc3df64..14164f2cb5 100644 --- a/compiler/entfile.pas +++ b/compiler/entfile.pas @@ -380,6 +380,11 @@ end; destructor tentryfile.destroy; begin closefile; +{$ifdef DEBUG_PPU} + if flog_open then + close(flog); + flog_open:=false; +{$endif DEBUG_PPU} if assigned(buf) then freemem(buf,entryfilebufsize); end; @@ -573,11 +578,6 @@ begin f.Free; mode:=0; closed:=true; -{$ifdef DEBUG_PPU} - if flog_open then - close(flog); - flog_open:=false; -{$endif DEBUG_PPU} end; end; @@ -683,14 +683,6 @@ var begin p:=pchar(@b); pbuf:=@buf[bufidx]; -{$ifdef DEBUG_PPU} - if ppu_log_level <= 0 then - begin - ppu_log('writedata, length='+tostr(len)+' level='+tostr(ppu_log_level)); - for i:=0 to len-1 do - ppu_log_val('p['+tostr(i)+']=$'+hexstr(byte(p[i]),2)); - end; -{$endif DEBUG_PPU} repeat left:=bufsize-bufidx; if len<left then @@ -704,6 +696,14 @@ begin exit; until false; move(pbuf^,p^,len); +{$ifdef DEBUG_PPU} + if ppu_log_level <= 0 then + begin + ppu_log('writedata, length='+tostr(len)+' level='+tostr(ppu_log_level)); + for i:=0 to len-1 do + ppu_log_val('p['+tostr(i)+']=$'+hexstr(byte(p[i]),2)); + end; +{$endif DEBUG_PPU} inc(bufidx,len); end; diff --git a/compiler/mips/ncpuadd.pas b/compiler/mips/ncpuadd.pas index 0554620030..0edbf04d8a 100644 --- a/compiler/mips/ncpuadd.pas +++ b/compiler/mips/ncpuadd.pas @@ -36,7 +36,7 @@ type private procedure cmp64_lt(left_reg, right_reg: TRegister64;unsigned:boolean); procedure cmp64_le(left_reg, right_reg: TRegister64;unsigned:boolean); - procedure second_generic_cmp32(unsigned: boolean); + procedure second_generic_cmp32(unsigned,is_smallset: boolean); procedure second_mul64bit; protected procedure second_addfloat; override; @@ -72,18 +72,31 @@ uses tmipsaddnode *****************************************************************************} -procedure tmipsaddnode.second_generic_cmp32(unsigned: boolean); +procedure tmipsaddnode.second_generic_cmp32(unsigned,is_smallset: boolean); var cond: TOpCmp; + allow_constant : boolean; + dreg : tregister; begin pass_left_right; - force_reg_left_right(True, True); + allow_constant:=(not is_smallset) or not (nodetype in [lten,gten]); + force_reg_left_right(True, allow_constant); location_reset(location,LOC_FLAGS,OS_NO); cond:=cmpnode2topcmp(unsigned); if nf_swapped in flags then cond:=swap_opcmp(cond); + if is_smallset and (nodetype in [lten,gten]) then + begin + if ((nodetype=lten) and not (nf_swapped in flags)) or + ((nodetype=gten) and (nf_swapped in flags)) then + dreg:=right.location.register + else + dreg:=left.location.register; + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(A_AND,dreg,right.location.register,left.location.register)); + cond:=OC_EQ; + end; location.resflags.cond:=cond; location.resflags.reg1:=left.location.register; location.resflags.use_const:=(right.location.loc=LOC_CONSTANT); @@ -304,13 +317,13 @@ end; procedure tmipsaddnode.second_cmpboolean; begin - second_generic_cmp32(true); + second_generic_cmp32(true,false); end; procedure tmipsaddnode.second_cmpsmallset; begin - second_generic_cmp32(true); + second_generic_cmp32(true,true); end; @@ -319,7 +332,7 @@ var unsigned: boolean; begin unsigned := not (is_signed(left.resultdef)) or not (is_signed(right.resultdef)); - second_generic_cmp32(unsigned); + second_generic_cmp32(unsigned,false); end; diff --git a/compiler/nadd.pas b/compiler/nadd.pas index 063c81b793..3018e6cf42 100644 --- a/compiler/nadd.pas +++ b/compiler/nadd.pas @@ -1715,6 +1715,7 @@ implementation (left.resultdef.typ=orddef) and (left.nodetype=andn) and (right.nodetype=andn) and + (not(is_boolean(resultdef)) or not(might_have_sideeffects(self,[mhs_exceptions])) or not(doshortbooleval(self))) and { this test is not needed but it speeds up the test and allows to bail out early } ((taddnode(left).left.nodetype=notn) or (taddnode(left).right.nodetype=notn) or (taddnode(right).left.nodetype=notn) or (taddnode(right).right.nodetype=notn) diff --git a/compiler/ncginl.pas b/compiler/ncginl.pas index e19eaa35d9..6e54cfb657 100644 --- a/compiler/ncginl.pas +++ b/compiler/ncginl.pas @@ -932,7 +932,8 @@ implementation else {$endif not cpu64bitalu and not cpuhighleveltarget} begin - if not(op2.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then + if not(op2.location.loc in [LOC_REGISTER,LOC_CREGISTER]) or + not(equal_defs(op2.resultdef,resultdef)) then hlcg.location_force_reg(current_asmdata.CurrAsmList,op2.location, op2.resultdef,resultdef,true); hlcg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,op,resultdef, diff --git a/compiler/options.pas b/compiler/options.pas index c84bff9a23..b2ecee0870 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -212,6 +212,7 @@ var p : pchar; hs,hs1,hs3,s : TCmdStr; J: longint; + xmloutput: Text; const NewLineStr = '$\n'; OSTargetsPlaceholder = '$OSTARGETS'; @@ -407,6 +408,17 @@ const end; end; + procedure ListOptimizationsXML; + var + opt: toptimizerswitch; + begin + WriteLn(xmloutput,'<optimizations>'); + for opt:=low(toptimizerswitch) to high(toptimizerswitch) do + if OptimizerSwitchStr[opt]<>'' then + WriteLn(xmloutput,'<optimization name="',OptimizerSwitchStr[opt],'"/>'); + WriteLn(xmloutput,'</optimizations>'); + end; + procedure ListWPOptimizations (OrigString: TCmdStr); var wpopt: twpoptimizerswitch; @@ -502,6 +514,23 @@ const {$POP} end; + procedure ListControllerTypesXML; + var + controllertype : tcontrollertype; + begin +{$PUSH} + {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *) + if (ControllerSupport) then + begin + WriteLn(xmloutput,'<controllertypes>'); + for controllertype:=low(tcontrollertype) to high(tcontrollertype) do + if embedded_controllers[controllertype].ControllerTypeStr<>'' then + WriteLn(xmloutput,'<controllertype name="',embedded_controllers[controllertype].ControllerTypeStr,'"/>'); + WriteLn(xmloutput,'</controllertypes>'); + end; +{$POP} + end; + procedure ListFeatures (OrigString: TCmdStr); var Feature: TFeature; @@ -627,31 +656,44 @@ begin Comment(V_Normal,s); end; end + else if Copy(More,1,1) = 'x' then + begin + Assign(xmloutput,Copy(More,2,length(More)-1)); + Rewrite(xmloutput); + WriteLn(xmloutput,'<?xml version="1.0" encoding="utf-8"?>'); + WriteLn(xmloutput,'<fpcoutput>'); + WriteLn(xmloutput,'<info>'); + ListOptimizationsXML; + ListControllerTypesXML; + WriteLn(xmloutput,'</info>'); + WriteLn(xmloutput,'</fpcoutput>'); + Close(xmloutput); + end else begin - J := 1; - while J <= Length (More) do - begin - if J > 1 then - Comment(V_Normal,''); (* Put empty line between multiple sections *) - case More [J] of - 'a': ListABITargets (''); - 'b': Comment(V_Normal, cgbackend2str[cgbackend]); - 'c': ListCPUInstructionSets (''); - 'f': ListFPUInstructionSets (''); - 'i': ListAsmModes (''); - 'm': ListModeswitches (''); - 'o': ListOptimizations (''); - 'r': ListFeatures (''); - 't': ListOSTargets (''); - 'u': ListControllerTypes (''); - 'w': ListWPOptimizations (''); - else - IllegalPara ('-i' + More); + J := 1; + while J <= Length (More) do + begin + if J > 1 then + Comment(V_Normal,''); (* Put empty line between multiple sections *) + case More [J] of + 'a': ListABITargets (''); + 'b': Comment(V_Normal, cgbackend2str[cgbackend]); + 'c': ListCPUInstructionSets (''); + 'f': ListFPUInstructionSets (''); + 'i': ListAsmModes (''); + 'm': ListModeswitches (''); + 'o': ListOptimizations (''); + 'r': ListFeatures (''); + 't': ListOSTargets (''); + 'u': ListControllerTypes (''); + 'w': ListWPOptimizations (''); + else + IllegalPara ('-i' + More); + end; + Inc (J); end; - Inc (J); - end; - end; + end; StopOptions(0); end; @@ -1955,7 +1997,7 @@ begin 'i' : begin if (More='') or - (More [1] in ['a', 'b', 'c', 'f', 'i', 'm', 'o', 'r', 't', 'u', 'w']) then + (More [1] in ['a', 'b', 'c', 'f', 'i', 'm', 'o', 'r', 't', 'u', 'w', 'x']) then WriteInfo (More) else QuickInfo:=QuickInfo+More; diff --git a/compiler/raatt.pas b/compiler/raatt.pas index 92d1e8c6ad..0bb96d9ec5 100644 --- a/compiler/raatt.pas +++ b/compiler/raatt.pas @@ -53,7 +53,7 @@ unit raatt; AS_DB,AS_DW,AS_DD,AS_DQ,AS_GLOBAL, AS_ALIGN,AS_BALIGN,AS_P2ALIGN,AS_ASCII, AS_ASCIIZ,AS_LCOMM,AS_COMM,AS_SINGLE,AS_DOUBLE,AS_EXTENDED,AS_CEXTENDED, - AS_DATA,AS_TEXT,AS_INIT,AS_FINI,AS_RVA, + AS_DATA,AS_TEXT,AS_INIT,AS_FINI,AS_RVA,AS_DC_A, AS_SET,AS_WEAK,AS_SECTION,AS_END, {------------------ Assembler Operators --------------------} AS_TYPE,AS_SIZEOF,AS_VMTOFFSET,AS_MOD,AS_SHL,AS_SHR,AS_NOT,AS_AND,AS_OR,AS_XOR,AS_NOR,AS_AT, @@ -80,7 +80,7 @@ unit raatt; '.byte','.word','.long','.quad','.globl', '.align','.balign','.p2align','.ascii', '.asciz','.lcomm','.comm','.single','.double','.tfloat','.tcfloat', - '.data','.text','.init','.fini','.rva', + '.data','.text','.init','.fini','.rva','.dc.a', '.set','.weak','.section','END', 'TYPE','SIZEOF','VMTOFFSET','%','<<','>>','!','&','|','^','~','@','reltype', 'directive'); @@ -227,7 +227,7 @@ unit raatt; actasmpattern[len]:=c; { Let us point to the next character } c:=current_scanner.asmgetchar; - while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do + while c in ['A'..'Z','a'..'z','0'..'9','_','$','.'] do begin inc(len); actasmpattern[len]:=c; @@ -1076,6 +1076,7 @@ unit raatt; section : tai_section; secflags : TSectionFlags; secprogbits : TSectionProgbits; + i: Integer; Begin Message1(asmr_d_start_reading,'GNU AS'); firsttoken:=TRUE; @@ -1163,6 +1164,12 @@ unit raatt; BuildConstant(4); end; + AS_DC_A: + Begin + Consume(AS_DC_A); + BuildConstant(sizeof(aint)); + end; + AS_DQ: Begin Consume(AS_DQ); @@ -1342,18 +1349,17 @@ unit raatt; Consume(AS_COMMA); if actasmtoken=AS_STRING then begin - case actasmpattern of - 'a': - Include(secflags,SF_A); - 'w': - Include(secflags,SF_W); - 'x': - Include(secflags,SF_X); - '': - ; - else - Message(asmr_e_syntax_error); - end; + for i:=1 to length(actasmpattern) do + case actasmpattern[i] of + 'a': + Include(secflags,SF_A); + 'w': + Include(secflags,SF_W); + 'x': + Include(secflags,SF_X); + else + Message(asmr_e_syntax_error); + end; Consume(AS_STRING); if actasmtoken=AS_COMMA then begin diff --git a/compiler/riscv/agrvgas.pas b/compiler/riscv/agrvgas.pas index 4ed6c30e82..a71a06aa74 100644 --- a/compiler/riscv/agrvgas.pas +++ b/compiler/riscv/agrvgas.pas @@ -130,7 +130,9 @@ unit agrvgas; s:=s+gas_regname(base)+','+gas_regname(index) else internalerror(2006052502); - end; + end + else + Internalerror(2021030602); case refaddr of addr_lo12: s:='%lo'+s; diff --git a/compiler/riscv/cgrv.pas b/compiler/riscv/cgrv.pas index 66f02bdaf6..9b5443b7cf 100644 --- a/compiler/riscv/cgrv.pas +++ b/compiler/riscv/cgrv.pas @@ -258,6 +258,10 @@ unit cgrv; procedure tcgrv.a_op_reg_reg_reg(list: TAsmList; op: TOpCg; size: tcgsize; src1, src2, dst: tregister); + var + name: String; + pd: tprocdef; + paraloc1, paraloc2: tcgpara; begin if op=OP_NOT then begin @@ -295,6 +299,47 @@ unit cgrv; end else {$endif RISCV64} + if (op in [OP_IMUL,OP_MUL]) and not(CPURV_HAS_MUL in cpu_capabilities[current_settings.cputype]) then + begin + case size of + OS_8: + name:='fpc_mul_byte'; + OS_S8: + name:='fpc_mul_shortint'; + OS_16: + name:='fpc_mul_word'; + OS_S16: + name:='fpc_mul_integer'; + OS_32: + name:='fpc_mul_dword'; + OS_S32: + name:='fpc_mul_longint'; + else + Internalerror(2021030601); + end; + +// if check_overflow then +// name:=name+'_checkoverflow'; + + pd:=search_system_proc(name); + paraloc1.init; + paraloc2.init; + paramanager.getcgtempparaloc(list,pd,1,paraloc1); + paramanager.getcgtempparaloc(list,pd,2,paraloc2); + a_load_reg_cgpara(list,OS_8,src1,paraloc2); + a_load_reg_cgpara(list,OS_8,src2,paraloc1); + paramanager.freecgpara(list,paraloc2); + paramanager.freecgpara(list,paraloc1); + alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default)); + a_call_name(list,upper(name),false); + dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default)); + cg.a_reg_alloc(list,NR_FUNCTION_RESULT_REG); + cg.a_load_reg_reg(list,size,size,NR_FUNCTION_RESULT_REG,dst); + cg.a_reg_dealloc(list,NR_FUNCTION_RESULT_REG); + paraloc2.done; + paraloc1.done; + end + else begin list.concat(taicpu.op_reg_reg_reg(TOpCG2AsmOp[op],dst,src2,src1)); maybeadjustresult(list,op,size,dst); diff --git a/compiler/riscv/nrvadd.pas b/compiler/riscv/nrvadd.pas index 734aa6d09a..b081612997 100644 --- a/compiler/riscv/nrvadd.pas +++ b/compiler/riscv/nrvadd.pas @@ -34,7 +34,7 @@ unit nrvadd; trvaddnode = class(tcgaddnode) function pass_1: tnode; override; protected - procedure Cmp(signed: boolean); + procedure Cmp(signed,is_smallset: boolean); function use_mul_helper: boolean; override; @@ -72,14 +72,17 @@ implementation low_value = {$ifdef CPU64BITALU} low(int64) {$else} low(longint) {$endif}; {$endif} - procedure trvaddnode.Cmp(signed: boolean); + procedure trvaddnode.Cmp(signed,is_smallset: boolean); var flabel,tlabel: tasmlabel; op, opi: TAsmOp; + allow_constant : boolean; begin pass_left_right; - force_reg_left_right(true,true); + allow_constant:=(not is_smallset) or not (nodetype in [lten,gten]); + + force_reg_left_right(true,allow_constant); if nf_swapped in flags then swapleftright; @@ -164,12 +167,20 @@ implementation if (left.location.loc=LOC_CONSTANT) and (not is_imm12(left.location.value)) then hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false); - - if left.location.loc=LOC_CONSTANT then - current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(opi,location.register,right.location.register,left.location.value)) + if is_smallset then + begin + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(A_AND,right.location.register,right.location.register,left.location.register)); + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(A_SUB,location.register,left.location.register,right.location.register)); + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(A_SLTIU,location.register,location.register,1)); + end else - current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(op,location.register,right.location.register,left.location.register)); - current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(A_SLTIU,location.register,location.register,1)); + begin + if left.location.loc=LOC_CONSTANT then + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(opi,location.register,right.location.register,left.location.value)) + else + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(op,location.register,right.location.register,left.location.register)); + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(A_SLTIU,location.register,location.register,1)); + end; end; gten: begin @@ -179,12 +190,20 @@ implementation if (right.location.loc=LOC_CONSTANT) and (not is_imm12(right.location.value)) then hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,false); - - if right.location.loc=LOC_CONSTANT then - current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(opi,location.register,left.location.register,right.location.value)) + if is_smallset then + begin + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(A_AND,left.location.register,right.location.register,left.location.register)); + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(A_SUB,location.register,left.location.register,right.location.register)); + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(A_SLTIU,location.register,location.register,1)); + end else - current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(op,location.register,left.location.register,right.location.register)); - current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(A_SLTIU,location.register,location.register,1)); + begin + if right.location.loc=LOC_CONSTANT then + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(opi,location.register,left.location.register,right.location.value)) + else + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(op,location.register,left.location.register,right.location.register)); + current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_const(A_SLTIU,location.register,location.register,1)); + end; end; else Internalerror(2016061101); @@ -194,9 +213,7 @@ implementation function trvaddnode.use_mul_helper: boolean; begin - if not (CPURV_HAS_MUL in cpu_capabilities[current_settings.cputype]) and - (nodetype=muln) and - not(torddef(resultdef).ordtype in [u8bit,s8bit]) then + if (nodetype=muln) and not(CPURV_HAS_MUL in cpu_capabilities[current_settings.cputype]) then result:=true else Result:=inherited use_mul_helper; @@ -205,7 +222,7 @@ implementation procedure trvaddnode.second_cmpsmallset; begin - Cmp(true); + Cmp(false,true); end; @@ -216,7 +233,7 @@ implementation unsigned:=not(is_signed(left.resultdef)) or not(is_signed(right.resultdef)); - Cmp(not unsigned); + Cmp(not unsigned,false); end; @@ -227,7 +244,7 @@ implementation unsigned:=not(is_signed(left.resultdef)) or not(is_signed(right.resultdef)); - Cmp(not unsigned); + Cmp(not unsigned,false); end; diff --git a/compiler/riscv64/rarv.pas b/compiler/riscv/rarv.pas index b02c55abab..b02c55abab 100644 --- a/compiler/riscv64/rarv.pas +++ b/compiler/riscv/rarv.pas diff --git a/compiler/riscv/rarvgas.pas b/compiler/riscv/rarvgas.pas index 97bacda10e..f71b568781 100644 --- a/compiler/riscv/rarvgas.pas +++ b/compiler/riscv/rarvgas.pas @@ -26,12 +26,21 @@ unit rarvgas; interface uses - raatt, + raatt,rarv, cpubase; type - trvattreader = class(tattreader) + trvgasreader = class(tattreader) + actmemoryordering: TMemoryOrdering; + function is_register(const s: string): boolean; override; + function is_asmopcode(const s: string):boolean;override; + procedure handleopcode;override; + procedure BuildReference(oper : trvoperand); + procedure BuildOperand(oper : trvoperand); + procedure BuildOpCode(instr : trvinstruction); + procedure ReadAt(oper : trvoperand); + procedure ReadSym(oper : trvoperand); function is_targetdirective(const s: string): boolean; override; procedure HandleTargetDirective; override; end; @@ -54,7 +63,7 @@ unit rarvgas; cgbase,cgobj,cgrv ; - function trvattreader.is_targetdirective(const s: string): boolean; + function trvgasreader.is_targetdirective(const s: string): boolean; begin case s of '.option': @@ -64,7 +73,8 @@ unit rarvgas; end; end; - procedure trvattreader.HandleTargetDirective; + + procedure trvgasreader.HandleTargetDirective; var id: string; begin @@ -81,5 +91,806 @@ unit rarvgas; end; end; + + procedure trvgasreader.ReadSym(oper : trvoperand); + var + tempstr, mangledname : string; + typesize,l,k : TCGInt; + begin + tempstr:=actasmpattern; + Consume(AS_ID); + { typecasting? } + if (actasmtoken=AS_LPAREN) and + SearchType(tempstr,typesize) then + begin + oper.hastype:=true; + Consume(AS_LPAREN); + BuildOperand(oper); + Consume(AS_RPAREN); + if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then + oper.SetSize(typesize,true); + end + else + if not oper.SetupVar(tempstr,false) then + Message1(sym_e_unknown_id,tempstr); + { record.field ? } + if actasmtoken=AS_DOT then + begin + BuildRecordOffsetSize(tempstr,l,k,mangledname,false); + if (mangledname<>'') then + Message(asmr_e_invalid_reference_syntax); + inc(oper.opr.ref.offset,l); + end; + end; + + + procedure trvgasreader.ReadAt(oper : trvoperand); + begin + { check for ...@ } + if actasmtoken=AS_AT then + begin + if (oper.opr.ref.symbol=nil) and + (oper.opr.ref.offset = 0) then + Message(asmr_e_invalid_reference_syntax); + Consume(AS_AT); + if actasmtoken=AS_ID then + begin + {if upper(actasmpattern)='L' then + oper.opr.ref.refaddr:=addr_low + else if upper(actasmpattern)='HI' then + oper.opr.ref.refaddr:=addr_high + else if upper(actasmpattern)='HA' then + oper.opr.ref.refaddr:=addr_higha + else} + Message(asmr_e_invalid_reference_syntax); + Consume(AS_ID); + end + else + Message(asmr_e_invalid_reference_syntax); + end; + end; + + + procedure trvgasreader.BuildReference(oper: trvoperand); + + procedure Consume_RParen; + begin + if actasmtoken <> AS_RPAREN then + Begin + Message(asmr_e_invalid_reference_syntax); + RecoverConsume(true); + end + else + begin + Consume(AS_RPAREN); + if not (actasmtoken in [AS_COMMA,AS_SEPARATOR,AS_END]) then + Begin + Message(asmr_e_invalid_reference_syntax); + RecoverConsume(true); + end; + end; + end; + + var + l : TCGInt; + relsym: string; + asmsymtyp: tasmsymtype; + isflags: tindsymflags; + + begin + Consume(AS_LPAREN); + Case actasmtoken of + AS_INTNUM, + AS_MINUS, + AS_PLUS: + Begin + { offset(offset) is invalid } + If oper.opr.Ref.Offset <> 0 Then + Begin + Message(asmr_e_invalid_reference_syntax); + RecoverConsume(true); + End + Else + Begin + oper.opr.Ref.Offset:=BuildConstExpression(false,true); + Consume(AS_RPAREN); + if actasmtoken=AS_AT then + ReadAt(oper); + end; + exit; + End; + AS_REGISTER: { (reg ... } + Begin + if ((oper.opr.typ=OPR_REFERENCE) and (oper.opr.ref.base<>NR_NO)) or + ((oper.opr.typ=OPR_LOCAL) and (oper.opr.localsym.localloc.loc<>LOC_REGISTER)) then + message(asmr_e_cannot_index_relative_var); + oper.opr.ref.base:=actasmregister; + Consume(AS_REGISTER); + Consume_RParen; + end; {end case } + AS_ID: + Begin + ReadSym(oper); + case actasmtoken of + AS_PLUS: + begin + { add a constant expression? } + l:=BuildConstExpression(true,true); + case oper.opr.typ of + OPR_CONSTANT : + inc(oper.opr.val,l); + OPR_LOCAL : + inc(oper.opr.localsymofs,l); + OPR_REFERENCE : + inc(oper.opr.ref.offset,l); + else + internalerror(2003092016); + end; + end; + AS_MINUS: + begin + Consume(AS_MINUS); + BuildConstSymbolExpression(false,true,false,l,relsym,asmsymtyp); + if (relsym<>'') then + begin + if (oper.opr.typ = OPR_REFERENCE) then + oper.opr.ref.relsymbol:=current_asmdata.RefAsmSymbol(relsym,AT_DATA) + else + begin + Message(asmr_e_invalid_reference_syntax); + RecoverConsume(false); + end + end + else + begin + case oper.opr.typ of + OPR_CONSTANT : + dec(oper.opr.val,l); + OPR_LOCAL : + dec(oper.opr.localsymofs,l); + OPR_REFERENCE : + dec(oper.opr.ref.offset,l); + else + internalerror(2007092601); + end; + end; + end; + else + ; + end; + Consume(AS_RPAREN); + if actasmtoken=AS_AT then + ReadAt(oper); + End; + AS_COMMA: { (, ... can either be scaling, or index } + Begin + Consume(AS_COMMA); + { Index } + if (actasmtoken=AS_REGISTER) then + Begin + oper.opr.ref.index:=actasmregister; + Consume(AS_REGISTER); + { check for scaling ... } + Consume_RParen; + end + else + begin + Message(asmr_e_invalid_reference_syntax); + RecoverConsume(false); + end; + end; + else + Begin + Message(asmr_e_invalid_reference_syntax); + RecoverConsume(false); + end; + end; + end; + + + procedure trvgasreader.BuildOperand(oper: trvoperand); + var + expr : string; + typesize,l : TCGInt; + + + procedure AddLabelOperand(hl:tasmlabel); + begin + if not(actasmtoken in [AS_PLUS,AS_MINUS,AS_LPAREN]) and + is_calljmp(actopcode) then + begin + oper.opr.typ:=OPR_SYMBOL; + oper.opr.symbol:=hl; + end + else + begin + oper.InitRef; + oper.opr.ref.symbol:=hl; + end; + end; + + + procedure MaybeRecordOffset; + var + mangledname: string; + hasdot : boolean; + l, + toffset, + tsize : TCGInt; + begin + if not(actasmtoken in [AS_DOT,AS_PLUS,AS_MINUS]) then + exit; + l:=0; + hasdot:=(actasmtoken=AS_DOT); + if hasdot then + begin + if expr<>'' then + begin + BuildRecordOffsetSize(expr,toffset,tsize,mangledname,false); + if (oper.opr.typ<>OPR_CONSTANT) and + (mangledname<>'') then + Message(asmr_e_wrong_sym_type); + inc(l,toffset); + oper.SetSize(tsize,true); + end; + end; + if actasmtoken in [AS_PLUS,AS_MINUS] then + inc(l,BuildConstExpression(true,false)); + case oper.opr.typ of + OPR_LOCAL : + begin + { don't allow direct access to fields of parameters, because that + will generate buggy code. Allow it only for explicit typecasting } + if hasdot and + (not oper.hastype) and + (tabstractvarsym(oper.opr.localsym).owner.symtabletype=parasymtable) and + (current_procinfo.procdef.proccalloption<>pocall_register) then + Message(asmr_e_cannot_access_field_directly_for_parameters); + inc(oper.opr.localsymofs,l) + end; + OPR_CONSTANT : + if (mangledname<>'') then + begin + if (oper.opr.val<>0) then + Message(asmr_e_wrong_sym_type); + oper.opr.typ:=OPR_SYMBOL; + oper.opr.symbol:=current_asmdata.DefineAsmSymbol(mangledname,AB_EXTERNAL,AT_FUNCTION,voidcodepointertype); + end + else + inc(oper.opr.val,l); + OPR_REFERENCE : + inc(oper.opr.ref.offset,l); + OPR_SYMBOL: + Message(asmr_e_invalid_symbol_ref); + else + internalerror(200309221); + end; + end; + + + function MaybeBuildReference:boolean; + { Try to create a reference, if not a reference is found then false + is returned } + begin + MaybeBuildReference:=true; + case actasmtoken of + AS_INTNUM, + AS_MINUS, + AS_PLUS: + Begin + oper.opr.ref.offset:=BuildConstExpression(True,False); + if actasmtoken<>AS_LPAREN then + Message(asmr_e_invalid_reference_syntax) + else + BuildReference(oper); + end; + AS_LPAREN: + BuildReference(oper); + AS_ID: { only a variable is allowed ... } + Begin + ReadSym(oper); + case actasmtoken of + AS_END, + AS_SEPARATOR, + AS_COMMA: ; + AS_LPAREN: + BuildReference(oper); + else + Begin + Message(asmr_e_invalid_reference_syntax); + Consume(actasmtoken); + end; + end; {end case } + end; + else + MaybeBuildReference:=false; + end; { end case } + end; + + + function is_fenceflag(hs : string): boolean; + var + i: longint; + flags: TFenceFlags; + begin + is_fenceflag := false; + + flags:=[]; + hs:=lower(hs); + + if (actopcode in [A_FENCE]) and (length(hs) >= 1) then + begin + for i:=1 to length(hs) do + begin + case hs[i] of + 'i': + Include(flags,ffi); + 'o': + Include(flags,ffo); + 'r': + Include(flags,ffr); + 'w': + Include(flags,ffw); + else + exit; + end; + end; + oper.opr.typ := OPR_FENCEFLAGS; + oper.opr.fenceflags := flags; + exit(true); + end; + end; + + + var + tempreg : tregister; + hl : tasmlabel; + ofs : aint; + refaddr: trefaddr; + entered_paren: Boolean; + Begin + expr:=''; + entered_paren:=false; + + refaddr:=addr_full; + if actasmtoken=AS_MOD then + begin + consume(AS_MOD); + + if actasmtoken<>AS_ID then + begin + Message(asmr_e_invalid_reference_syntax); + RecoverConsume(false); + end + else + begin + if lower(actasmpattern)='pcrel_hi' then + refaddr:=addr_pcrel_hi20 + else if lower(actasmpattern)='pcrel_lo' then + refaddr:=addr_pcrel_lo12 + else if lower(actasmpattern)='hi' then + refaddr:=addr_hi20 + else if lower(actasmpattern)='lo' then + refaddr:=addr_lo12 + else + begin + Message(asmr_e_invalid_reference_syntax); + RecoverConsume(false); + end; + + consume(AS_ID); + consume(AS_LPAREN); + entered_paren:=true; + end; + end; + + case actasmtoken of + AS_LPAREN: { Memory reference or constant expression } + Begin + oper.InitRef; + BuildReference(oper); + end; + + AS_INTNUM, + AS_MINUS, + AS_PLUS: + Begin + { Constant memory offset } + { This must absolutely be followed by ( } + oper.InitRef; + oper.opr.ref.offset:=BuildConstExpression(True,False); + if actasmtoken<>AS_LPAREN then + begin + ofs:=oper.opr.ref.offset; + BuildConstantOperand(oper); + inc(oper.opr.val,ofs); + end + else + BuildReference(oper); + end; + + AS_DOT, + AS_ID: { A constant expression, or a Variable ref. } + Begin + if is_fenceflag(actasmpattern) then + begin + consume(AS_ID); + end + else + { Local Label ? } + if is_locallabel(actasmpattern) then + begin + CreateLocalLabel(actasmpattern,hl,false); + Consume(AS_ID); + AddLabelOperand(hl); + end + else + { Check for label } + if SearchLabel(actasmpattern,hl,false) then + begin + Consume(AS_ID); + AddLabelOperand(hl); + end + else + { probably a variable or normal expression } + { or a procedure (such as in CALL ID) } + Begin + { is it a constant ? } + if SearchIConstant(actasmpattern,l) then + Begin + if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then + Message(asmr_e_invalid_operand_type); + BuildConstantOperand(oper); + end + else + begin + expr:=actasmpattern; + Consume(AS_ID); + { typecasting? } + if (actasmtoken=AS_LPAREN) and + SearchType(expr,typesize) then + begin + oper.hastype:=true; + Consume(AS_LPAREN); + BuildOperand(oper); + Consume(AS_RPAREN); + if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then + oper.SetSize(typesize,true); + end + else + begin + if oper.SetupVar(expr,false) then + ReadAt(oper) + else + Begin + { look for special symbols ... } + if expr= '__HIGH' then + begin + consume(AS_LPAREN); + if not oper.setupvar('high'+actasmpattern,false) then + Message1(sym_e_unknown_id,'high'+actasmpattern); + consume(AS_ID); + consume(AS_RPAREN); + end + else + if expr = '__RESULT' then + oper.SetUpResult + else + if expr = '__SELF' then + oper.SetupSelf + else + if expr = '__OLDEBP' then + oper.SetupOldEBP + else + Message1(sym_e_unknown_id,expr); + end; + end; + end; + if actasmtoken=AS_DOT then + MaybeRecordOffset; + { add a constant expression? } + if (actasmtoken=AS_PLUS) then + begin + l:=BuildConstExpression(true,entered_paren); + case oper.opr.typ of + OPR_CONSTANT : + inc(oper.opr.val,l); + OPR_LOCAL : + inc(oper.opr.localsymofs,l); + OPR_REFERENCE : + inc(oper.opr.ref.offset,l); + else + internalerror(2003092017); + end; + end + end; + { Do we have a indexing reference, then parse it also } + if actasmtoken=AS_LPAREN then + begin + oper.InitRef; + BuildReference(oper); + end; + end; + AS_REGISTER: { Register, a variable reference or a constant reference } + Begin + { save the type of register used. } + tempreg:=actasmregister; + Consume(AS_REGISTER); + if (actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) then + begin + if not (oper.opr.typ in [OPR_NONE,OPR_REGISTER]) then + Message(asmr_e_invalid_operand_type); + oper.opr.typ:=OPR_REGISTER; + oper.opr.reg:=tempreg; + end + else + Message(asmr_e_syn_operand); + end; + AS_END, + AS_SEPARATOR, + AS_COMMA: ; + else + Begin + Message(asmr_e_syn_operand); + Consume(actasmtoken); + end; + end; { end case } + + if refaddr<>addr_full then + begin + if oper.opr.typ<>OPR_REFERENCE then + oper.InitRef; + + oper.opr.ref.refaddr:=refaddr; + Consume(AS_RPAREN); + end + else if (oper.opr.typ=OPR_REFERENCE) and + (oper.opr.ref.refaddr=addr_no) and + assigned(oper.opr.ref.symbol) then + oper.opr.ref.refaddr:=addr_full; + end; + + +{***************************************************************************** + trvgasreader +*****************************************************************************} + + procedure trvgasreader.BuildOpCode(instr : trvinstruction); + var + operandnum : longint; + Begin + { opcode } + if (actasmtoken<>AS_OPCODE) then + Begin + Message(asmr_e_invalid_or_missing_opcode); + RecoverConsume(true); + exit; + end; + { Fill the instr object with the current state } + with instr do + begin + Opcode:=ActOpcode; + condition:=ActCondition; + ordering:=actmemoryordering; + end; + + { We are reading operands, so opcode will be an AS_ID } + operandnum:=1; + Consume(AS_OPCODE); + { Zero operand opcode ? } + if actasmtoken in [AS_SEPARATOR,AS_END] then + begin + operandnum:=0; + exit; + end; + { Read the operands } + repeat + case actasmtoken of + AS_COMMA: { Operand delimiter } + Begin + if operandnum>Max_Operands then + Message(asmr_e_too_many_operands) + else + begin + { condition operands doesn't set the operand but write to the + condition field of the instruction + } + if instr.Operands[operandnum].opr.typ<>OPR_NONE then + Inc(operandnum); + end; + Consume(AS_COMMA); + end; + AS_SEPARATOR, + AS_END : { End of asm operands for this opcode } + begin + break; + end; + else + BuildOperand(instr.Operands[operandnum] as trvoperand); + end; { end case } + until false; + if (operandnum=1) and (instr.Operands[operandnum].opr.typ=OPR_NONE) then + dec(operandnum); + instr.Ops:=operandnum; + end; + + function trvgasreader.is_register(const s: string): boolean; + type + treg2str = record + name : string[3]; + reg : tregister; + end; + + const + extraregs : array[0..31] of treg2str = ( + (name: 'A0'; reg : NR_X10), + (name: 'A1'; reg : NR_X11), + (name: 'A2'; reg : NR_X12), + (name: 'A3'; reg : NR_X13), + (name: 'A4'; reg : NR_X14), + (name: 'A5'; reg : NR_X15), + (name: 'A6'; reg : NR_X16), + (name: 'A7'; reg : NR_X17), + (name: 'RA'; reg : NR_X1), + (name: 'SP'; reg : NR_X2), + (name: 'GP'; reg : NR_X3), + (name: 'TP'; reg : NR_X4), + (name: 'T0'; reg : NR_X5), + (name: 'T1'; reg : NR_X6), + (name: 'T2'; reg : NR_X7), + (name: 'S0'; reg : NR_X8), + (name: 'FP'; reg : NR_X8), + (name: 'S1'; reg : NR_X9), + (name: 'S2'; reg : NR_X18), + (name: 'S3'; reg : NR_X19), + (name: 'S4'; reg : NR_X20), + (name: 'S5'; reg : NR_X21), + (name: 'S6'; reg : NR_X22), + (name: 'S7'; reg : NR_X23), + (name: 'S8'; reg : NR_X24), + (name: 'S9'; reg : NR_X25), + (name: 'S10';reg : NR_X26), + (name: 'S11';reg : NR_X27), + (name: 'T3'; reg : NR_X28), + (name: 'T4'; reg : NR_X29), + (name: 'T5'; reg : NR_X30), + (name: 'T6'; reg : NR_X31) + ); + + var + i : longint; + + begin + result:=inherited is_register(s); + { reg found? + possible aliases are always 2 char + } + if result or (not (length(s) in [2,3])) then + exit; + for i:=low(extraregs) to high(extraregs) do + begin + if s=extraregs[i].name then + begin + actasmregister:=extraregs[i].reg; + result:=true; + actasmtoken:=AS_REGISTER; + exit; + end; + end; + end; + + + function trvgasreader.is_asmopcode(const s: string):boolean; + var + cond : tasmcond; + hs, postfix : string; + l: longint; + Begin + { making s a value parameter would break other assembler readers } + hs:=s; + is_asmopcode:=false; + + { clear op code } + actopcode:=A_None; + { clear condition } + fillchar(actcondition,sizeof(actcondition),0); + + { check for direction hint } + actopcode := tasmop(ptruint(iasmops.find(hs))); + if actopcode <> A_NONE then + begin + actasmtoken:=AS_OPCODE; + is_asmopcode:=true; + exit; + end; + { not found, check branch instructions } + if hs[1]='B' then + begin + { we can search here without an extra table which is sorted by string length + because we take the whole remaining string without the leading B } + actopcode := A_Bxx; + for cond:=low(TAsmCond) to high(TAsmCond) do + if copy(hs,2,length(s)-1)=uppercond2str[cond] then + begin + actcondition:=cond; + actasmtoken:=AS_OPCODE; + is_asmopcode:=true; + exit; + end; + end; + + { check atomic instructions } + if (pos('AMO',hs)=1) or + (pos('LR', hs)=1) or + (pos('SC', hs)=1) then + begin + l := length(hs)-1; + while l>1 do + begin + actopcode := tasmop(ptruint(iasmops.find(copy(hs,1,l)))); + if actopcode <> A_None then + begin + postfix := copy(hs,l+1,length(hs)-l); + + if postfix='.AQRL' then actmemoryordering:=[moAq,moRl] + else if postfix='.RL' then actmemoryordering:=[moRl] + else if postfix='.AQ' then actmemoryordering:=[moAq] + else + exit; + + actasmtoken:=AS_OPCODE; + is_asmopcode:=true; + exit; + end; + dec(l); + end; + end; + end; + + + procedure trvgasreader.handleopcode; + var + instr : trvinstruction; + begin + instr:=trvinstruction.Create(trvoperand); + BuildOpcode(instr); + instr.condition := actcondition; + { + instr.AddReferenceSizes; + instr.SetInstructionOpsize; + instr.CheckOperandSizes; + } + instr.ConcatInstruction(curlist); + instr.Free; + actmemoryordering:=[]; + end; + + +{***************************************************************************** + Initialize +*****************************************************************************} + + const + asmmode_rv64_standard_info : tasmmodeinfo = + ( + id : asmmode_standard; + idtxt : 'STANDARD'; + casmreader : trvgasreader; + ); + + asmmode_rv32_standard_info : tasmmodeinfo = + ( + id : asmmode_standard; + idtxt : 'STANDARD'; + casmreader : trvgasreader; + ); + +initialization +{$ifdef RISCV32} + RegisterAsmMode(asmmode_rv32_standard_info); +{$endif RISCV32} +{$ifdef RISCV64} + RegisterAsmMode(asmmode_rv64_standard_info); +{$endif RISCV32} end. diff --git a/compiler/riscv32/cputarg.pas b/compiler/riscv32/cputarg.pas index 0643083eee..4c5643fc43 100644 --- a/compiler/riscv32/cputarg.pas +++ b/compiler/riscv32/cputarg.pas @@ -55,7 +55,7 @@ implementation **************************************} {$ifndef NoRaRVGas} - ,rarv32gas + ,rarvgas {$endif NoRaRVGas} {************************************** diff --git a/compiler/riscv32/rarv32.pas b/compiler/riscv32/rarv32.pas deleted file mode 100644 index 8d7d3effad..0000000000 --- a/compiler/riscv32/rarv32.pas +++ /dev/null @@ -1,41 +0,0 @@ -{ - Copyright (c) 1998-2003 by Carl Eric Codere and Peter Vreman - - Handles the common Risc-V32 assembler reader routines - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - **************************************************************************** -} -unit rarv32; - -{$i fpcdefs.inc} - - interface - - uses - aasmbase,aasmtai,aasmdata,aasmcpu, - cpubase,rautils,cclasses; - - type - TRVOperand=class(TOperand) - end; - - TRVInstruction=class(TInstruction) - end; - - implementation - -end. diff --git a/compiler/riscv32/rarv32gas.pas b/compiler/riscv32/rarv32gas.pas deleted file mode 100644 index dc8c0fbd4d..0000000000 --- a/compiler/riscv32/rarv32gas.pas +++ /dev/null @@ -1,780 +0,0 @@ -{ - Copyright (c) 1998-2002 by Carl Eric Codere and Peter Vreman - - Does the parsing for the Risc-V32 GNU AS styled inline assembler. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - **************************************************************************** -} -Unit rarv32gas; - -{$i fpcdefs.inc} - - Interface - - uses - raatt,rarv32,rarvgas; - - type - trv32attreader = class(trvattreader) - function is_register(const s: string): boolean; override; - function is_asmopcode(const s: string):boolean;override; - procedure handleopcode;override; - procedure BuildReference(oper : trvoperand); - procedure BuildOperand(oper : trvoperand); - procedure BuildOpCode(instr : trvinstruction); - procedure ReadAt(oper : trvoperand); - procedure ReadSym(oper : trvoperand); - end; - - - Implementation - - uses - { helpers } - cutils, - { global } - globtype,globals,verbose, - systems, - { aasm } - cpubase,aasmbase,aasmtai,aasmdata,aasmcpu, - { symtable } - symconst,symdef,symsym, - { parser } - procinfo, - rabase,rautils, - cgbase,cgobj,cgrv - ; - - procedure trv32attreader.ReadSym(oper : trvoperand); - var - tempstr, mangledname : string; - l,k,typesize : tcgint; - begin - tempstr:=actasmpattern; - Consume(AS_ID); - { typecasting? } - if (actasmtoken=AS_LPAREN) and - SearchType(tempstr,typesize) then - begin - oper.hastype:=true; - Consume(AS_LPAREN); - BuildOperand(oper); - Consume(AS_RPAREN); - if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then - oper.SetSize(typesize,true); - end - else - if not oper.SetupVar(tempstr,false) then - Message1(sym_e_unknown_id,tempstr); - { record.field ? } - if actasmtoken=AS_DOT then - begin - BuildRecordOffsetSize(tempstr,l,k,mangledname,false); - if (mangledname<>'') then - Message(asmr_e_invalid_reference_syntax); - inc(oper.opr.ref.offset,l); - end; - end; - - - procedure trv32attreader.ReadAt(oper : trvoperand); - begin - { check for ...@ } - if actasmtoken=AS_AT then - begin - if (oper.opr.ref.symbol=nil) and - (oper.opr.ref.offset = 0) then - Message(asmr_e_invalid_reference_syntax); - Consume(AS_AT); - if actasmtoken=AS_ID then - begin - {if upper(actasmpattern)='L' then - oper.opr.ref.refaddr:=addr_low - else if upper(actasmpattern)='HI' then - oper.opr.ref.refaddr:=addr_high - else if upper(actasmpattern)='HA' then - oper.opr.ref.refaddr:=addr_higha - else} - Message(asmr_e_invalid_reference_syntax); - Consume(AS_ID); - end - else - Message(asmr_e_invalid_reference_syntax); - end; - end; - - - Procedure trv32attreader.BuildReference(oper : trvoperand); - - procedure Consume_RParen; - begin - if actasmtoken <> AS_RPAREN then - Begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(true); - end - else - begin - Consume(AS_RPAREN); - if not (actasmtoken in [AS_COMMA,AS_SEPARATOR,AS_END]) then - Begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(true); - end; - end; - end; - - var - l : tcgint; - relsym: string; - asmsymtyp: tasmsymtype; - isflags: tindsymflags; - - begin - Consume(AS_LPAREN); - Case actasmtoken of - AS_INTNUM, - AS_MINUS, - AS_PLUS: - Begin - { offset(offset) is invalid } - If oper.opr.Ref.Offset <> 0 Then - Begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(true); - End - Else - Begin - oper.opr.Ref.Offset:=BuildConstExpression(false,true); - Consume(AS_RPAREN); - if actasmtoken=AS_AT then - ReadAt(oper); - end; - exit; - End; - AS_REGISTER: { (reg ... } - Begin - if ((oper.opr.typ=OPR_REFERENCE) and (oper.opr.ref.base<>NR_NO)) or - ((oper.opr.typ=OPR_LOCAL) and (oper.opr.localsym.localloc.loc<>LOC_REGISTER)) then - message(asmr_e_cannot_index_relative_var); - oper.opr.ref.base:=actasmregister; - Consume(AS_REGISTER); - Consume_RParen; - end; {end case } - AS_ID: - Begin - ReadSym(oper); - case actasmtoken of - AS_PLUS: - begin - { add a constant expression? } - l:=BuildConstExpression(true,true); - case oper.opr.typ of - OPR_CONSTANT : - inc(oper.opr.val,l); - OPR_LOCAL : - inc(oper.opr.localsymofs,l); - OPR_REFERENCE : - inc(oper.opr.ref.offset,l); - else - internalerror(2003092008); - end; - end; - AS_MINUS: - begin - Consume(AS_MINUS); - BuildConstSymbolExpression(false,true,false,l,relsym,asmsymtyp); - if (relsym<>'') then - begin - if (oper.opr.typ = OPR_REFERENCE) then - oper.opr.ref.relsymbol:=current_asmdata.RefAsmSymbol(relsym,AT_DATA) - else - begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end - end - else - begin - case oper.opr.typ of - OPR_CONSTANT : - dec(oper.opr.val,l); - OPR_LOCAL : - dec(oper.opr.localsymofs,l); - OPR_REFERENCE : - dec(oper.opr.ref.offset,l); - else - internalerror(2007092601); - end; - end; - end; - else - ; - end; - Consume(AS_RPAREN); - if actasmtoken=AS_AT then - ReadAt(oper); - End; - AS_COMMA: { (, ... can either be scaling, or index } - Begin - Consume(AS_COMMA); - { Index } - if (actasmtoken=AS_REGISTER) then - Begin - oper.opr.ref.index:=actasmregister; - Consume(AS_REGISTER); - { check for scaling ... } - Consume_RParen; - end - else - begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end; - end; - else - Begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end; - end; - end; - - - Procedure trv32attreader.BuildOperand(oper : trvoperand); - var - expr : string; - typesize,l : tcgint; - - - procedure AddLabelOperand(hl:tasmlabel); - begin - if not(actasmtoken in [AS_PLUS,AS_MINUS,AS_LPAREN]) and - is_calljmp(actopcode) then - begin - oper.opr.typ:=OPR_SYMBOL; - oper.opr.symbol:=hl; - end - else - begin - oper.InitRef; - oper.opr.ref.symbol:=hl; - end; - end; - - - procedure MaybeRecordOffset; - var - mangledname: string; - hasdot : boolean; - l, - toffset, - tsize : tcgint; - begin - if not(actasmtoken in [AS_DOT,AS_PLUS,AS_MINUS]) then - exit; - l:=0; - hasdot:=(actasmtoken=AS_DOT); - if hasdot then - begin - if expr<>'' then - begin - BuildRecordOffsetSize(expr,toffset,tsize,mangledname,false); - if (oper.opr.typ<>OPR_CONSTANT) and - (mangledname<>'') then - Message(asmr_e_wrong_sym_type); - inc(l,toffset); - oper.SetSize(tsize,true); - end; - end; - if actasmtoken in [AS_PLUS,AS_MINUS] then - inc(l,BuildConstExpression(true,false)); - case oper.opr.typ of - OPR_LOCAL : - begin - { don't allow direct access to fields of parameters, because that - will generate buggy code. Allow it only for explicit typecasting } - if hasdot and - (not oper.hastype) and - (tabstractvarsym(oper.opr.localsym).owner.symtabletype=parasymtable) and - (current_procinfo.procdef.proccalloption<>pocall_register) then - Message(asmr_e_cannot_access_field_directly_for_parameters); - inc(oper.opr.localsymofs,l) - end; - OPR_CONSTANT : - if (mangledname<>'') then - begin - if (oper.opr.val<>0) then - Message(asmr_e_wrong_sym_type); - oper.opr.typ:=OPR_SYMBOL; - oper.opr.symbol:=current_asmdata.DefineAsmSymbol(mangledname,AB_EXTERNAL,AT_FUNCTION,voidcodepointertype); - end - else - inc(oper.opr.val,l); - OPR_REFERENCE : - inc(oper.opr.ref.offset,l); - OPR_SYMBOL: - Message(asmr_e_invalid_symbol_ref); - else - internalerror(200309221); - end; - end; - - - function MaybeBuildReference:boolean; - { Try to create a reference, if not a reference is found then false - is returned } - begin - MaybeBuildReference:=true; - case actasmtoken of - AS_INTNUM, - AS_MINUS, - AS_PLUS: - Begin - oper.opr.ref.offset:=BuildConstExpression(True,False); - if actasmtoken<>AS_LPAREN then - Message(asmr_e_invalid_reference_syntax) - else - BuildReference(oper); - end; - AS_LPAREN: - BuildReference(oper); - AS_ID: { only a variable is allowed ... } - Begin - ReadSym(oper); - case actasmtoken of - AS_END, - AS_SEPARATOR, - AS_COMMA: ; - AS_LPAREN: - BuildReference(oper); - else - Begin - Message(asmr_e_invalid_reference_syntax); - Consume(actasmtoken); - end; - end; {end case } - end; - else - MaybeBuildReference:=false; - end; { end case } - end; - - - var - tempreg : tregister; - hl : tasmlabel; - ofs : aint; - refaddr: trefaddr; - entered_paren: Boolean; - Begin - expr:=''; - entered_paren:=false; - - refaddr:=addr_full; - if actasmtoken=AS_MOD then - begin - consume(AS_MOD); - - if actasmtoken<>AS_ID then - begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end - else - begin - if lower(actasmpattern)='pcrel_hi' then - refaddr:=addr_pcrel_hi20 - else if lower(actasmpattern)='pcrel_lo' then - refaddr:=addr_pcrel_lo12 - else if lower(actasmpattern)='hi' then - refaddr:=addr_hi20 - else if lower(actasmpattern)='lo' then - refaddr:=addr_lo12 - else - begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end; - - consume(AS_ID); - consume(AS_LPAREN); - entered_paren:=true; - end; - end; - - case actasmtoken of - AS_LPAREN: { Memory reference or constant expression } - Begin - oper.InitRef; - BuildReference(oper); - end; - - AS_INTNUM, - AS_MINUS, - AS_PLUS: - Begin - { Constant memory offset } - { This must absolutely be followed by ( } - oper.InitRef; - oper.opr.ref.offset:=BuildConstExpression(True,False); - if actasmtoken<>AS_LPAREN then - begin - ofs:=oper.opr.ref.offset; - BuildConstantOperand(oper); - inc(oper.opr.val,ofs); - end - else - BuildReference(oper); - end; - - AS_ID: { A constant expression, or a Variable ref. } - Begin - { Local Label ? } - if is_locallabel(actasmpattern) then - begin - CreateLocalLabel(actasmpattern,hl,false); - Consume(AS_ID); - AddLabelOperand(hl); - end - else - { Check for label } - if SearchLabel(actasmpattern,hl,false) then - begin - Consume(AS_ID); - AddLabelOperand(hl); - end - else - { probably a variable or normal expression } - { or a procedure (such as in CALL ID) } - Begin - { is it a constant ? } - if SearchIConstant(actasmpattern,l) then - Begin - if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then - Message(asmr_e_invalid_operand_type); - BuildConstantOperand(oper); - end - else - begin - expr:=actasmpattern; - Consume(AS_ID); - { typecasting? } - if (actasmtoken=AS_LPAREN) and - SearchType(expr,typesize) then - begin - oper.hastype:=true; - Consume(AS_LPAREN); - BuildOperand(oper); - Consume(AS_RPAREN); - if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then - oper.SetSize(typesize,true); - end - else - begin - if oper.SetupVar(expr,false) then - ReadAt(oper) - else - Begin - { look for special symbols ... } - if expr= '__HIGH' then - begin - consume(AS_LPAREN); - if not oper.setupvar('high'+actasmpattern,false) then - Message1(sym_e_unknown_id,'high'+actasmpattern); - consume(AS_ID); - consume(AS_RPAREN); - end - else - if expr = '__RESULT' then - oper.SetUpResult - else - if expr = '__SELF' then - oper.SetupSelf - else - if expr = '__OLDEBP' then - oper.SetupOldEBP - else - Message1(sym_e_unknown_id,expr); - end; - end; - end; - if actasmtoken=AS_DOT then - MaybeRecordOffset; - { add a constant expression? } - if (actasmtoken=AS_PLUS) then - begin - l:=BuildConstExpression(true,entered_paren); - case oper.opr.typ of - OPR_CONSTANT : - inc(oper.opr.val,l); - OPR_LOCAL : - inc(oper.opr.localsymofs,l); - OPR_REFERENCE : - inc(oper.opr.ref.offset,l); - else - internalerror(2003092009); - end; - end - end; - { Do we have a indexing reference, then parse it also } - if actasmtoken=AS_LPAREN then - BuildReference(oper); - end; - - AS_REGISTER: { Register, a variable reference or a constant reference } - Begin - { save the type of register used. } - tempreg:=actasmregister; - Consume(AS_REGISTER); - if (actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) then - begin - if not (oper.opr.typ in [OPR_NONE,OPR_REGISTER]) then - Message(asmr_e_invalid_operand_type); - oper.opr.typ:=OPR_REGISTER; - oper.opr.reg:=tempreg; - end - else - Message(asmr_e_syn_operand); - end; - AS_END, - AS_SEPARATOR, - AS_COMMA: ; - else - Begin - Message(asmr_e_syn_operand); - Consume(actasmtoken); - end; - end; { end case } - - if refaddr<>addr_full then - begin - if oper.opr.typ<>OPR_REFERENCE then - oper.InitRef; - - oper.opr.ref.refaddr:=refaddr; - Consume(AS_RPAREN); - end - else if (oper.opr.typ=OPR_REFERENCE) and - (oper.opr.ref.refaddr=addr_no) and - assigned(oper.opr.ref.symbol) then - oper.opr.ref.refaddr:=addr_full; - end; - - -{***************************************************************************** - trv32attreader -*****************************************************************************} - - procedure trv32attreader.BuildOpCode(instr : trvinstruction); - var - operandnum : longint; - Begin - { opcode } - if (actasmtoken<>AS_OPCODE) then - Begin - Message(asmr_e_invalid_or_missing_opcode); - RecoverConsume(true); - exit; - end; - { Fill the instr object with the current state } - with instr do - begin - Opcode:=ActOpcode; - condition:=ActCondition; - end; - - { We are reading operands, so opcode will be an AS_ID } - operandnum:=1; - Consume(AS_OPCODE); - { Zero operand opcode ? } - if actasmtoken in [AS_SEPARATOR,AS_END] then - begin - operandnum:=0; - exit; - end; - { Read the operands } - repeat - case actasmtoken of - AS_COMMA: { Operand delimiter } - Begin - if operandnum>Max_Operands then - Message(asmr_e_too_many_operands) - else - begin - { condition operands doesn't set the operand but write to the - condition field of the instruction - } - if instr.Operands[operandnum].opr.typ<>OPR_NONE then - Inc(operandnum); - end; - Consume(AS_COMMA); - end; - AS_SEPARATOR, - AS_END : { End of asm operands for this opcode } - begin - break; - end; - else - BuildOperand(instr.Operands[operandnum] as trvoperand); - end; { end case } - until false; - if (operandnum=1) and (instr.Operands[operandnum].opr.typ=OPR_NONE) then - dec(operandnum); - instr.Ops:=operandnum; - end; - - - function trv32attreader.is_register(const s: string): boolean; - type - treg2str = record - name : string[3]; - reg : tregister; - end; - - const - extraregs : array[0..31] of treg2str = ( - (name: 'A0'; reg : NR_X10), - (name: 'A1'; reg : NR_X11), - (name: 'A2'; reg : NR_X12), - (name: 'A3'; reg : NR_X13), - (name: 'A4'; reg : NR_X14), - (name: 'A5'; reg : NR_X15), - (name: 'A6'; reg : NR_X16), - (name: 'A7'; reg : NR_X17), - (name: 'RA'; reg : NR_X1), - (name: 'SP'; reg : NR_X2), - (name: 'GP'; reg : NR_X3), - (name: 'TP'; reg : NR_X4), - (name: 'T0'; reg : NR_X5), - (name: 'T1'; reg : NR_X6), - (name: 'T2'; reg : NR_X7), - (name: 'S0'; reg : NR_X8), - (name: 'FP'; reg : NR_X8), - (name: 'S1'; reg : NR_X9), - (name: 'S2'; reg : NR_X18), - (name: 'S3'; reg : NR_X19), - (name: 'S4'; reg : NR_X20), - (name: 'S5'; reg : NR_X21), - (name: 'S6'; reg : NR_X22), - (name: 'S7'; reg : NR_X23), - (name: 'S8'; reg : NR_X24), - (name: 'S9'; reg : NR_X25), - (name: 'S10';reg : NR_X26), - (name: 'S11';reg : NR_X27), - (name: 'T3'; reg : NR_X28), - (name: 'T4'; reg : NR_X29), - (name: 'T5'; reg : NR_X30), - (name: 'T6'; reg : NR_X31) - ); - - var - i : longint; - - begin - result:=inherited is_register(s); - { reg found? - possible aliases are always 2 char - } - if result or (not (length(s) in [2,3])) then - exit; - for i:=low(extraregs) to high(extraregs) do - begin - if s=extraregs[i].name then - begin - actasmregister:=extraregs[i].reg; - result:=true; - actasmtoken:=AS_REGISTER; - exit; - end; - end; - end; - - - function trv32attreader.is_asmopcode(const s: string):boolean; - var - cond : tasmcond; - hs : string; - - Begin - { making s a value parameter would break other assembler readers } - hs:=s; - is_asmopcode:=false; - - { clear op code } - actopcode:=A_None; - { clear condition } - fillchar(actcondition,sizeof(actcondition),0); - - { check for direction hint } - actopcode := tasmop(ptruint(iasmops.find(hs))); - if actopcode <> A_NONE then - begin - actasmtoken:=AS_OPCODE; - is_asmopcode:=true; - exit; - end; - { not found, check branch instructions } - if hs[1]='B' then - begin - { we can search here without an extra table which is sorted by string length - because we take the whole remaining string without the leading B } - actopcode := A_Bxx; - for cond:=low(TAsmCond) to high(TAsmCond) do - if copy(hs,2,length(s)-1)=uppercond2str[cond] then - begin - actcondition:=cond; - actasmtoken:=AS_OPCODE; - is_asmopcode:=true; - exit; - end; - end; - end; - - - procedure trv32attreader.handleopcode; - var - instr : trvinstruction; - begin - instr:=trvinstruction.Create(trvoperand); - BuildOpcode(instr); - instr.condition := actcondition; - { - instr.AddReferenceSizes; - instr.SetInstructionOpsize; - instr.CheckOperandSizes; - } - instr.ConcatInstruction(curlist); - instr.Free; - end; - - -{***************************************************************************** - Initialize -*****************************************************************************} - -const - asmmode_rv32_standard_info : tasmmodeinfo = - ( - id : asmmode_standard; - idtxt : 'STANDARD'; - casmreader : trv32attreader; - ); - -initialization - RegisterAsmMode(asmmode_rv32_standard_info); -end. diff --git a/compiler/riscv64/cputarg.pas b/compiler/riscv64/cputarg.pas index 6986b1f2b6..2fe842893d 100644 --- a/compiler/riscv64/cputarg.pas +++ b/compiler/riscv64/cputarg.pas @@ -55,7 +55,7 @@ implementation **************************************} {$ifndef NoRaRVGas} - ,rarv64gas + ,rarvgas {$endif NoRaRVGas} {************************************** diff --git a/compiler/riscv64/rarv64gas.pas b/compiler/riscv64/rarv64gas.pas deleted file mode 100644 index 5eebf0d591..0000000000 --- a/compiler/riscv64/rarv64gas.pas +++ /dev/null @@ -1,850 +0,0 @@ -{ - Copyright (c) 2016 by Jeppe Johansen - - Does the parsing for the RiscV64 GNU AS styled inline assembler. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - **************************************************************************** -} -unit rarv64gas; - -{$I fpcdefs.inc} - - interface - - uses - raatt, rarvgas, rarv, - cpubase; - - type - trv64attreader = class(trvattreader) - actmemoryordering: TMemoryOrdering; - function is_register(const s: string): boolean; override; - function is_asmopcode(const s: string):boolean;override; - procedure handleopcode;override; - procedure BuildReference(oper : trvoperand); - procedure BuildOperand(oper : trvoperand); - procedure BuildOpCode(instr : trvinstruction); - procedure ReadAt(oper : trvoperand); - procedure ReadSym(oper : trvoperand); - end; - - implementation - - uses - { helpers } - cutils, - { global } - globtype,globals,verbose, - systems, - { aasm } - aasmbase,aasmtai,aasmdata,aasmcpu, - { symtable } - symconst,symsym,symdef, - { parser } - procinfo, - rabase,rautils, - cgbase,cgobj,cgrv - ; - - procedure trv64attreader.ReadSym(oper : trvoperand); - var - tempstr, mangledname : string; - typesize,l,k : aint; - begin - tempstr:=actasmpattern; - Consume(AS_ID); - { typecasting? } - if (actasmtoken=AS_LPAREN) and - SearchType(tempstr,typesize) then - begin - oper.hastype:=true; - Consume(AS_LPAREN); - BuildOperand(oper); - Consume(AS_RPAREN); - if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then - oper.SetSize(typesize,true); - end - else - if not oper.SetupVar(tempstr,false) then - Message1(sym_e_unknown_id,tempstr); - { record.field ? } - if actasmtoken=AS_DOT then - begin - BuildRecordOffsetSize(tempstr,l,k,mangledname,false); - if (mangledname<>'') then - Message(asmr_e_invalid_reference_syntax); - inc(oper.opr.ref.offset,l); - end; - end; - - - procedure trv64attreader.ReadAt(oper : trvoperand); - begin - { check for ...@ } - if actasmtoken=AS_AT then - begin - if (oper.opr.ref.symbol=nil) and - (oper.opr.ref.offset = 0) then - Message(asmr_e_invalid_reference_syntax); - Consume(AS_AT); - if actasmtoken=AS_ID then - begin - {if upper(actasmpattern)='L' then - oper.opr.ref.refaddr:=addr_low - else if upper(actasmpattern)='HI' then - oper.opr.ref.refaddr:=addr_high - else if upper(actasmpattern)='HA' then - oper.opr.ref.refaddr:=addr_higha - else} - Message(asmr_e_invalid_reference_syntax); - Consume(AS_ID); - end - else - Message(asmr_e_invalid_reference_syntax); - end; - end; - - - procedure trv64attreader.BuildReference(oper: trvoperand); - - procedure Consume_RParen; - begin - if actasmtoken <> AS_RPAREN then - Begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(true); - end - else - begin - Consume(AS_RPAREN); - if not (actasmtoken in [AS_COMMA,AS_SEPARATOR,AS_END]) then - Begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(true); - end; - end; - end; - - var - l : aint; - relsym: string; - asmsymtyp: tasmsymtype; - isflags: tindsymflags; - - begin - Consume(AS_LPAREN); - Case actasmtoken of - AS_INTNUM, - AS_MINUS, - AS_PLUS: - Begin - { offset(offset) is invalid } - If oper.opr.Ref.Offset <> 0 Then - Begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(true); - End - Else - Begin - oper.opr.Ref.Offset:=BuildConstExpression(false,true); - Consume(AS_RPAREN); - if actasmtoken=AS_AT then - ReadAt(oper); - end; - exit; - End; - AS_REGISTER: { (reg ... } - Begin - if ((oper.opr.typ=OPR_REFERENCE) and (oper.opr.ref.base<>NR_NO)) or - ((oper.opr.typ=OPR_LOCAL) and (oper.opr.localsym.localloc.loc<>LOC_REGISTER)) then - message(asmr_e_cannot_index_relative_var); - oper.opr.ref.base:=actasmregister; - Consume(AS_REGISTER); - Consume_RParen; - end; {end case } - AS_ID: - Begin - ReadSym(oper); - case actasmtoken of - AS_PLUS: - begin - { add a constant expression? } - l:=BuildConstExpression(true,true); - case oper.opr.typ of - OPR_CONSTANT : - inc(oper.opr.val,l); - OPR_LOCAL : - inc(oper.opr.localsymofs,l); - OPR_REFERENCE : - inc(oper.opr.ref.offset,l); - else - internalerror(2003092016); - end; - end; - AS_MINUS: - begin - Consume(AS_MINUS); - BuildConstSymbolExpression(false,true,false,l,relsym,asmsymtyp); - if (relsym<>'') then - begin - if (oper.opr.typ = OPR_REFERENCE) then - oper.opr.ref.relsymbol:=current_asmdata.RefAsmSymbol(relsym,AT_DATA) - else - begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end - end - else - begin - case oper.opr.typ of - OPR_CONSTANT : - dec(oper.opr.val,l); - OPR_LOCAL : - dec(oper.opr.localsymofs,l); - OPR_REFERENCE : - dec(oper.opr.ref.offset,l); - else - internalerror(2007092601); - end; - end; - end; - else - ; - end; - Consume(AS_RPAREN); - if actasmtoken=AS_AT then - ReadAt(oper); - End; - AS_COMMA: { (, ... can either be scaling, or index } - Begin - Consume(AS_COMMA); - { Index } - if (actasmtoken=AS_REGISTER) then - Begin - oper.opr.ref.index:=actasmregister; - Consume(AS_REGISTER); - { check for scaling ... } - Consume_RParen; - end - else - begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end; - end; - else - Begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end; - end; - end; - - - procedure trv64attreader.BuildOperand(oper: trvoperand); - var - expr : string; - typesize,l : aint; - - - procedure AddLabelOperand(hl:tasmlabel); - begin - if not(actasmtoken in [AS_PLUS,AS_MINUS,AS_LPAREN]) and - is_calljmp(actopcode) then - begin - oper.opr.typ:=OPR_SYMBOL; - oper.opr.symbol:=hl; - end - else - begin - oper.InitRef; - oper.opr.ref.symbol:=hl; - end; - end; - - - procedure MaybeRecordOffset; - var - mangledname: string; - hasdot : boolean; - l, - toffset, - tsize : aint; - begin - if not(actasmtoken in [AS_DOT,AS_PLUS,AS_MINUS]) then - exit; - l:=0; - hasdot:=(actasmtoken=AS_DOT); - if hasdot then - begin - if expr<>'' then - begin - BuildRecordOffsetSize(expr,toffset,tsize,mangledname,false); - if (oper.opr.typ<>OPR_CONSTANT) and - (mangledname<>'') then - Message(asmr_e_wrong_sym_type); - inc(l,toffset); - oper.SetSize(tsize,true); - end; - end; - if actasmtoken in [AS_PLUS,AS_MINUS] then - inc(l,BuildConstExpression(true,false)); - case oper.opr.typ of - OPR_LOCAL : - begin - { don't allow direct access to fields of parameters, because that - will generate buggy code. Allow it only for explicit typecasting } - if hasdot and - (not oper.hastype) and - (tabstractvarsym(oper.opr.localsym).owner.symtabletype=parasymtable) and - (current_procinfo.procdef.proccalloption<>pocall_register) then - Message(asmr_e_cannot_access_field_directly_for_parameters); - inc(oper.opr.localsymofs,l) - end; - OPR_CONSTANT : - if (mangledname<>'') then - begin - if (oper.opr.val<>0) then - Message(asmr_e_wrong_sym_type); - oper.opr.typ:=OPR_SYMBOL; - oper.opr.symbol:=current_asmdata.DefineAsmSymbol(mangledname,AB_EXTERNAL,AT_FUNCTION,voidcodepointertype); - end - else - inc(oper.opr.val,l); - OPR_REFERENCE : - inc(oper.opr.ref.offset,l); - OPR_SYMBOL: - Message(asmr_e_invalid_symbol_ref); - else - internalerror(200309221); - end; - end; - - - function MaybeBuildReference:boolean; - { Try to create a reference, if not a reference is found then false - is returned } - begin - MaybeBuildReference:=true; - case actasmtoken of - AS_INTNUM, - AS_MINUS, - AS_PLUS: - Begin - oper.opr.ref.offset:=BuildConstExpression(True,False); - if actasmtoken<>AS_LPAREN then - Message(asmr_e_invalid_reference_syntax) - else - BuildReference(oper); - end; - AS_LPAREN: - BuildReference(oper); - AS_ID: { only a variable is allowed ... } - Begin - ReadSym(oper); - case actasmtoken of - AS_END, - AS_SEPARATOR, - AS_COMMA: ; - AS_LPAREN: - BuildReference(oper); - else - Begin - Message(asmr_e_invalid_reference_syntax); - Consume(actasmtoken); - end; - end; {end case } - end; - else - MaybeBuildReference:=false; - end; { end case } - end; - - - function is_fenceflag(hs : string): boolean; - var - i: longint; - flags: TFenceFlags; - begin - is_fenceflag := false; - - flags:=[]; - hs:=lower(hs); - - if (actopcode in [A_FENCE]) and (length(hs) >= 1) then - begin - for i:=1 to length(hs) do - begin - case hs[i] of - 'i': - Include(flags,ffi); - 'o': - Include(flags,ffo); - 'r': - Include(flags,ffr); - 'w': - Include(flags,ffw); - else - exit; - end; - end; - oper.opr.typ := OPR_FENCEFLAGS; - oper.opr.fenceflags := flags; - exit(true); - end; - end; - - - var - tempreg : tregister; - hl : tasmlabel; - ofs : aint; - refaddr: trefaddr; - entered_paren: Boolean; - Begin - expr:=''; - entered_paren:=false; - - refaddr:=addr_full; - if actasmtoken=AS_MOD then - begin - consume(AS_MOD); - - if actasmtoken<>AS_ID then - begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end - else - begin - if lower(actasmpattern)='pcrel_hi' then - refaddr:=addr_pcrel_hi20 - else if lower(actasmpattern)='pcrel_lo' then - refaddr:=addr_pcrel_lo12 - else if lower(actasmpattern)='hi' then - refaddr:=addr_hi20 - else if lower(actasmpattern)='lo' then - refaddr:=addr_lo12 - else - begin - Message(asmr_e_invalid_reference_syntax); - RecoverConsume(false); - end; - - consume(AS_ID); - consume(AS_LPAREN); - entered_paren:=true; - end; - end; - - case actasmtoken of - AS_LPAREN: { Memory reference or constant expression } - Begin - oper.InitRef; - BuildReference(oper); - end; - - AS_INTNUM, - AS_MINUS, - AS_PLUS: - Begin - { Constant memory offset } - { This must absolutely be followed by ( } - oper.InitRef; - oper.opr.ref.offset:=BuildConstExpression(True,False); - if actasmtoken<>AS_LPAREN then - begin - ofs:=oper.opr.ref.offset; - BuildConstantOperand(oper); - inc(oper.opr.val,ofs); - end - else - BuildReference(oper); - end; - - AS_DOT, - AS_ID: { A constant expression, or a Variable ref. } - Begin - if is_fenceflag(actasmpattern) then - begin - consume(AS_ID); - end - else - { Local Label ? } - if is_locallabel(actasmpattern) then - begin - CreateLocalLabel(actasmpattern,hl,false); - Consume(AS_ID); - AddLabelOperand(hl); - end - else - { Check for label } - if SearchLabel(actasmpattern,hl,false) then - begin - Consume(AS_ID); - AddLabelOperand(hl); - end - else - { probably a variable or normal expression } - { or a procedure (such as in CALL ID) } - Begin - { is it a constant ? } - if SearchIConstant(actasmpattern,l) then - Begin - if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then - Message(asmr_e_invalid_operand_type); - BuildConstantOperand(oper); - end - else - begin - expr:=actasmpattern; - Consume(AS_ID); - { typecasting? } - if (actasmtoken=AS_LPAREN) and - SearchType(expr,typesize) then - begin - oper.hastype:=true; - Consume(AS_LPAREN); - BuildOperand(oper); - Consume(AS_RPAREN); - if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then - oper.SetSize(typesize,true); - end - else - begin - if oper.SetupVar(expr,false) then - ReadAt(oper) - else - Begin - { look for special symbols ... } - if expr= '__HIGH' then - begin - consume(AS_LPAREN); - if not oper.setupvar('high'+actasmpattern,false) then - Message1(sym_e_unknown_id,'high'+actasmpattern); - consume(AS_ID); - consume(AS_RPAREN); - end - else - if expr = '__RESULT' then - oper.SetUpResult - else - if expr = '__SELF' then - oper.SetupSelf - else - if expr = '__OLDEBP' then - oper.SetupOldEBP - else - Message1(sym_e_unknown_id,expr); - end; - end; - end; - if actasmtoken=AS_DOT then - MaybeRecordOffset; - { add a constant expression? } - if (actasmtoken=AS_PLUS) then - begin - l:=BuildConstExpression(true,entered_paren); - case oper.opr.typ of - OPR_CONSTANT : - inc(oper.opr.val,l); - OPR_LOCAL : - inc(oper.opr.localsymofs,l); - OPR_REFERENCE : - inc(oper.opr.ref.offset,l); - else - internalerror(2003092017); - end; - end - end; - { Do we have a indexing reference, then parse it also } - if actasmtoken=AS_LPAREN then - BuildReference(oper); - end; - - AS_REGISTER: { Register, a variable reference or a constant reference } - Begin - { save the type of register used. } - tempreg:=actasmregister; - Consume(AS_REGISTER); - if (actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) then - begin - if not (oper.opr.typ in [OPR_NONE,OPR_REGISTER]) then - Message(asmr_e_invalid_operand_type); - oper.opr.typ:=OPR_REGISTER; - oper.opr.reg:=tempreg; - end - else - Message(asmr_e_syn_operand); - end; - AS_END, - AS_SEPARATOR, - AS_COMMA: ; - else - Begin - Message(asmr_e_syn_operand); - Consume(actasmtoken); - end; - end; { end case } - - if refaddr<>addr_full then - begin - if oper.opr.typ<>OPR_REFERENCE then - oper.InitRef; - - oper.opr.ref.refaddr:=refaddr; - Consume(AS_RPAREN); - end - else if (oper.opr.typ=OPR_REFERENCE) and - (oper.opr.ref.refaddr=addr_no) and - assigned(oper.opr.ref.symbol) then - oper.opr.ref.refaddr:=addr_full; - end; - - -{***************************************************************************** - trv64attreader -*****************************************************************************} - - procedure trv64attreader.BuildOpCode(instr : trvinstruction); - var - operandnum : longint; - Begin - { opcode } - if (actasmtoken<>AS_OPCODE) then - Begin - Message(asmr_e_invalid_or_missing_opcode); - RecoverConsume(true); - exit; - end; - { Fill the instr object with the current state } - with instr do - begin - Opcode:=ActOpcode; - condition:=ActCondition; - ordering:=actmemoryordering; - end; - - { We are reading operands, so opcode will be an AS_ID } - operandnum:=1; - Consume(AS_OPCODE); - { Zero operand opcode ? } - if actasmtoken in [AS_SEPARATOR,AS_END] then - begin - operandnum:=0; - exit; - end; - { Read the operands } - repeat - case actasmtoken of - AS_COMMA: { Operand delimiter } - Begin - if operandnum>Max_Operands then - Message(asmr_e_too_many_operands) - else - begin - { condition operands doesn't set the operand but write to the - condition field of the instruction - } - if instr.Operands[operandnum].opr.typ<>OPR_NONE then - Inc(operandnum); - end; - Consume(AS_COMMA); - end; - AS_SEPARATOR, - AS_END : { End of asm operands for this opcode } - begin - break; - end; - else - BuildOperand(instr.Operands[operandnum] as trvoperand); - end; { end case } - until false; - if (operandnum=1) and (instr.Operands[operandnum].opr.typ=OPR_NONE) then - dec(operandnum); - instr.Ops:=operandnum; - end; - - function trv64attreader.is_register(const s: string): boolean; - type - treg2str = record - name : string[3]; - reg : tregister; - end; - - const - extraregs : array[0..31] of treg2str = ( - (name: 'A0'; reg : NR_X10), - (name: 'A1'; reg : NR_X11), - (name: 'A2'; reg : NR_X12), - (name: 'A3'; reg : NR_X13), - (name: 'A4'; reg : NR_X14), - (name: 'A5'; reg : NR_X15), - (name: 'A6'; reg : NR_X16), - (name: 'A7'; reg : NR_X17), - (name: 'RA'; reg : NR_X1), - (name: 'SP'; reg : NR_X2), - (name: 'GP'; reg : NR_X3), - (name: 'TP'; reg : NR_X4), - (name: 'T0'; reg : NR_X5), - (name: 'T1'; reg : NR_X6), - (name: 'T2'; reg : NR_X7), - (name: 'S0'; reg : NR_X8), - (name: 'FP'; reg : NR_X8), - (name: 'S1'; reg : NR_X9), - (name: 'S2'; reg : NR_X18), - (name: 'S3'; reg : NR_X19), - (name: 'S4'; reg : NR_X20), - (name: 'S5'; reg : NR_X21), - (name: 'S6'; reg : NR_X22), - (name: 'S7'; reg : NR_X23), - (name: 'S8'; reg : NR_X24), - (name: 'S9'; reg : NR_X25), - (name: 'S10';reg : NR_X26), - (name: 'S11';reg : NR_X27), - (name: 'T3'; reg : NR_X28), - (name: 'T4'; reg : NR_X29), - (name: 'T5'; reg : NR_X30), - (name: 'T6'; reg : NR_X31) - ); - - var - i : longint; - - begin - result:=inherited is_register(s); - { reg found? - possible aliases are always 2 char - } - if result or (not (length(s) in [2,3])) then - exit; - for i:=low(extraregs) to high(extraregs) do - begin - if s=extraregs[i].name then - begin - actasmregister:=extraregs[i].reg; - result:=true; - actasmtoken:=AS_REGISTER; - exit; - end; - end; - end; - - - function trv64attreader.is_asmopcode(const s: string):boolean; - var - cond : tasmcond; - hs, postfix : string; - l: longint; - Begin - { making s a value parameter would break other assembler readers } - hs:=s; - is_asmopcode:=false; - - { clear op code } - actopcode:=A_None; - { clear condition } - fillchar(actcondition,sizeof(actcondition),0); - - { check for direction hint } - actopcode := tasmop(ptruint(iasmops.find(hs))); - if actopcode <> A_NONE then - begin - actasmtoken:=AS_OPCODE; - is_asmopcode:=true; - exit; - end; - { not found, check branch instructions } - if hs[1]='B' then - begin - { we can search here without an extra table which is sorted by string length - because we take the whole remaining string without the leading B } - actopcode := A_Bxx; - for cond:=low(TAsmCond) to high(TAsmCond) do - if copy(hs,2,length(s)-1)=uppercond2str[cond] then - begin - actcondition:=cond; - actasmtoken:=AS_OPCODE; - is_asmopcode:=true; - exit; - end; - end; - - { check atomic instructions } - if (pos('AMO',hs)=1) or - (pos('LR', hs)=1) or - (pos('SC', hs)=1) then - begin - l := length(hs)-1; - while l>1 do - begin - actopcode := tasmop(ptruint(iasmops.find(copy(hs,1,l)))); - if actopcode <> A_None then - begin - postfix := copy(hs,l+1,length(hs)-l); - - if postfix='.AQRL' then actmemoryordering:=[moAq,moRl] - else if postfix='.RL' then actmemoryordering:=[moRl] - else if postfix='.AQ' then actmemoryordering:=[moAq] - else - exit; - - actasmtoken:=AS_OPCODE; - is_asmopcode:=true; - exit; - end; - dec(l); - end; - end; - end; - - - procedure trv64attreader.handleopcode; - var - instr : trvinstruction; - begin - instr:=trvinstruction.Create(trvoperand); - BuildOpcode(instr); - instr.condition := actcondition; - { - instr.AddReferenceSizes; - instr.SetInstructionOpsize; - instr.CheckOperandSizes; - } - instr.ConcatInstruction(curlist); - instr.Free; - actmemoryordering:=[]; - end; - - -{***************************************************************************** - Initialize -*****************************************************************************} - - const - asmmode_rv64_standard_info : tasmmodeinfo = - ( - id : asmmode_standard; - idtxt : 'STANDARD'; - casmreader : trv64attreader; - ); - -initialization - RegisterAsmMode(asmmode_rv64_standard_info); -end. - diff --git a/compiler/x86/aoptx86.pas b/compiler/x86/aoptx86.pas index 646f27d526..c68280130e 100644 --- a/compiler/x86/aoptx86.pas +++ b/compiler/x86/aoptx86.pas @@ -3076,6 +3076,55 @@ unit aoptx86; Result:=true; exit; end; + +{$ifdef x86_64} + { Convert: + movq x(ref),%reg64 + shrq y,%reg64 + To: + movq x+4(ref),%reg32 + shrq y-32,%reg32 (Remove if y = 32) + } + if (taicpu(p).opsize = S_Q) and + (taicpu(p).oper[0]^.typ = top_ref) and { Second operand will be a register } + (taicpu(p).oper[0]^.ref^.offset <= $7FFFFFFB) and + MatchInstruction(hp1, A_SHR, [taicpu(p).opsize]) and + MatchOpType(taicpu(hp1), top_const, top_reg) and + (taicpu(hp1).oper[0]^.val >= 32) and + (taicpu(hp1).oper[1]^.reg = taicpu(p).oper[1]^.reg) then + begin + RegName1 := debug_regname(taicpu(hp1).oper[1]^.reg); + PreMessage := 'movq ' + debug_operstr(taicpu(p).oper[0]^) + ',' + RegName1 + '; ' + + 'shrq $' + debug_tostr(taicpu(hp1).oper[0]^.val) + ',' + RegName1 + ' -> movl '; + + { Convert to 32-bit } + setsubreg(taicpu(p).oper[1]^.reg, R_SUBD); + taicpu(p).opsize := S_L; + + Inc(taicpu(p).oper[0]^.ref^.offset, 4); + + PreMessage := PreMessage + debug_operstr(taicpu(p).oper[0]^) + ',' + debug_regname(taicpu(p).oper[1]^.reg); + if (taicpu(hp1).oper[0]^.val = 32) then + begin + DebugMsg(SPeepholeOptimization + PreMessage + ' (MovShr2Mov)', p); + RemoveInstruction(hp1); + end + else + begin + { This will potentially open up more arithmetic operations since + the peephole optimizer now has a big hint that only the lower + 32 bits are currently in use (and opcodes are smaller in size) } + setsubreg(taicpu(hp1).oper[1]^.reg, R_SUBD); + taicpu(hp1).opsize := S_L; + + Dec(taicpu(hp1).oper[0]^.val, 32); + DebugMsg(SPeepholeOptimization + PreMessage + + '; shrl $' + debug_tostr(taicpu(hp1).oper[0]^.val) + ',' + debug_regname(taicpu(hp1).oper[1]^.reg) + ' (MovShr2MovShr)', p); + end; + Result := True; + Exit; + end; +{$endif x86_64} end; @@ -7076,19 +7125,26 @@ unit aoptx86; movl/q %reg1,%reg2 To: leal/q $-x(%reg1),%reg2 - subl/q $x,%reg1 + subl/q $x,%reg1 (can be removed if %reg1 or the flags are not used afterwards) Breaks the dependency chain and potentially permits the removal of a CMP instruction if one follows. } Result := False; - if not (cs_opt_size in current_settings.optimizerswitches) and - (taicpu(p).opsize in [S_L{$ifdef x86_64}, S_Q{$endif x86_64}]) and + if (taicpu(p).opsize in [S_L{$ifdef x86_64}, S_Q{$endif x86_64}]) and MatchOpType(taicpu(p),top_const,top_reg) and GetNextInstruction(p, hp1) and MatchInstruction(hp1, A_MOV, [taicpu(p).opsize]) and (taicpu(hp1).oper[1]^.typ = top_reg) and - MatchOperand(taicpu(hp1).oper[0]^, taicpu(p).oper[1]^.reg) then + MatchOperand(taicpu(hp1).oper[0]^, taicpu(p).oper[1]^.reg) and + ( + { Don't do SubMov2LeaSub under -Os, but do allow SubMov2Lea } + not (cs_opt_size in current_settings.optimizerswitches) or + ( + not RegUsedAfterInstruction(taicpu(p).oper[1]^.reg, hp1, TmpUsedRegs) and + RegUsedAfterInstruction(NR_DEFAULTFLAGS, hp1, TmpUsedRegs) + ) + ) then begin { Change the MOV instruction to a LEA instruction, and update the first operand } @@ -7100,12 +7156,26 @@ unit aoptx86; taicpu(hp1).opcode := A_LEA; taicpu(hp1).loadref(0, NewRef); - { Move what is now the LEA instruction to before the SUB instruction } - Asml.Remove(hp1); - Asml.InsertBefore(hp1, p); - AllocRegBetween(taicpu(hp1).oper[1]^.reg, hp1, p, UsedRegs); + TransferUsedRegs(TmpUsedRegs); + UpdateUsedRegs(TmpUsedRegs, tai(p.Next)); + if RegUsedAfterInstruction(NewRef.base, hp1, TmpUsedRegs) or + RegUsedAfterInstruction(NR_DEFAULTFLAGS, hp1, TmpUsedRegs) then + begin + { Move what is now the LEA instruction to before the SUB instruction } + Asml.Remove(hp1); + Asml.InsertBefore(hp1, p); + AllocRegBetween(taicpu(hp1).oper[1]^.reg, hp1, p, UsedRegs); + + DebugMsg(SPeepholeOptimization + 'SubMov2LeaSub', p); + p := hp1; + end + else + begin + { Since %reg1 or the flags aren't used afterwards, we can delete p completely } + RemoveCurrentP(p, hp1); + DebugMsg(SPeepholeOptimization + 'SubMov2Lea', p); + end; - DebugMsg(SPeepholeOptimization + 'SubMov2LeaSub', p); Result := True; end; end; diff --git a/compiler/x86/rgx86.pas b/compiler/x86/rgx86.pas index 6285808b2d..27d34fbd5e 100644 --- a/compiler/x86/rgx86.pas +++ b/compiler/x86/rgx86.pas @@ -109,6 +109,14 @@ implementation function avx_opcode_only_op0_may_be_memref(opcode : TAsmOp) : boolean; begin case opcode of + A_VMAXPD, + A_VMAXPS, + A_VMAXSD, + A_VMAXSS, + A_VMINPD, + A_VMINPS, + A_VMINSD, + A_VMINSS, A_VMULSS, A_VMULSD, A_VSUBSS, @@ -350,7 +358,15 @@ implementation A_SHUFPD, A_SHUFPS, A_VCOMISD, - A_VCOMISS: + A_VCOMISS, + A_MINSS, + A_MINSD, + A_MINPS, + A_MINPD, + A_MAXSS, + A_MAXSD, + A_MAXPS, + A_MAXPD: replaceoper:=-1; A_IMUL: |