From 561cac3461c67eba85ab757af47891caa661e994 Mon Sep 17 00:00:00 2001 From: laksen Date: Sun, 14 Apr 2019 20:51:29 +0000 Subject: - Add support for .option directive in riscv assembler. - Use addiw when adjusting U32 to S32 git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@41870 3ad0048d-3df7-0310-abae-a5850022a9f2 --- compiler/riscv64/cgcpu.pas | 2 ++ compiler/riscv64/rarv64gas.pas | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'compiler/riscv64') diff --git a/compiler/riscv64/cgcpu.pas b/compiler/riscv64/cgcpu.pas index f8b3888ae9..4b889b3c4d 100644 --- a/compiler/riscv64/cgcpu.pas +++ b/compiler/riscv64/cgcpu.pas @@ -104,6 +104,8 @@ implementation list.Concat(taicpu.op_reg_reg_const(A_ADDIW,reg2,reg1,0)) else if (tosize=OS_S32) and (tcgsize2unsigned[fromsize]=OS_64) then list.Concat(taicpu.op_reg_reg_const(A_ADDIW,reg2,reg1,0)) + else if (tosize=OS_S32) and (fromsize=OS_32) then + list.Concat(taicpu.op_reg_reg_const(A_ADDIW,reg2,reg1,0)) else if (tcgsize2unsigned[tosize]=OS_64) and (fromsize=OS_8) then list.Concat(taicpu.op_reg_reg_const(A_ANDI,reg2,reg1,$FF)) else if (tcgsize2size[fromsize] > tcgsize2size[tosize]) or diff --git a/compiler/riscv64/rarv64gas.pas b/compiler/riscv64/rarv64gas.pas index 2c727846d8..bf92dffc1e 100644 --- a/compiler/riscv64/rarv64gas.pas +++ b/compiler/riscv64/rarv64gas.pas @@ -26,11 +26,11 @@ unit rarv64gas; interface uses - raatt, rarv, + raatt, rarvgas, rarv, cpubase; type - trv64attreader = class(tattreader) + trv64attreader = class(trvattreader) actmemoryordering: TMemoryOrdering; function is_register(const s: string): boolean; override; function is_asmopcode(const s: string):boolean;override; @@ -413,8 +413,10 @@ unit rarv64gas; hl : tasmlabel; ofs : aint; refaddr: trefaddr; + entered_paren: Boolean; Begin expr:=''; + entered_paren:=false; refaddr:=addr_full; if actasmtoken=AS_MOD then @@ -444,6 +446,7 @@ unit rarv64gas; consume(AS_ID); consume(AS_LPAREN); + entered_paren:=true; end; end; @@ -472,6 +475,7 @@ unit rarv64gas; BuildReference(oper); end; + AS_DOT, AS_ID: { A constant expression, or a Variable ref. } Begin if is_fenceflag(actasmpattern) then @@ -553,7 +557,7 @@ unit rarv64gas; { add a constant expression? } if (actasmtoken=AS_PLUS) then begin - l:=BuildConstExpression(true,false); + l:=BuildConstExpression(true,entered_paren); case oper.opr.typ of OPR_CONSTANT : inc(oper.opr.val,l); -- cgit v1.2.1