Browse Source

* make use of LA pseudo-instruction

florian 7 months ago
parent
commit
64ba751ef1
4 changed files with 20 additions and 2 deletions
  1. 3 0
      compiler/aasmtai.pas
  2. 1 1
      compiler/riscv/aasmcpu.pas
  3. 1 1
      compiler/riscv/agrvgas.pas
  4. 15 0
      compiler/riscv/cgrv.pas

+ 3 - 0
compiler/aasmtai.pas

@@ -2987,6 +2987,9 @@ implementation
 {$ifdef aarch64}
               and not(r.refaddr in [addr_full,addr_gotpageoffset,addr_gotpage])
 {$endif aarch64}
+{$ifdef riscv}
+              and not(opcode=A_LA)
+{$endif riscv}
               then
               internalerror(200502052);
 {$endif not llvm}

+ 1 - 1
compiler/riscv/aasmcpu.pas

@@ -480,7 +480,7 @@ uses cutils, cclasses;
 
           // I type
           A_JALR,
-          A_LB,A_LH,A_LW,A_LBU,A_LHU,
+          A_LA,A_LB,A_LH,A_LW,A_LBU,A_LHU,
           A_ADDI,A_SLTI,A_SLTIU,
           A_XORI,A_ORI,A_ANDI,
           A_SLLI,A_SRLI,A_SRAI,

+ 1 - 1
compiler/riscv/agrvgas.pas

@@ -74,7 +74,7 @@ unit agrvgas;
             else
               begin
                 s :='';
-                if not(refaddr in [addr_no,addr_pic_no_got,addr_plt]) then
+                if not(refaddr in [addr_no,addr_pic_no_got,addr_plt,addr_full]) then
                   s := s+'(';
                 if assigned(symbol) then
                   begin

+ 15 - 0
compiler/riscv/cgrv.pas

@@ -931,6 +931,12 @@ unit cgrv;
 
         if assigned(ref.symbol) then
           begin
+{$ifdef unsed}
+            { keeping the code for reference
+
+              we use the pseudo instruction LA below which is expanded by the assembler, doing
+              so results in more readable assembler and easier optimization of the assembler code
+            }
             if cs_create_pic in current_settings.moduleswitches then
               begin
                 reference_reset_symbol(href,ref.symbol,0,0,[]);
@@ -969,6 +975,15 @@ unit cgrv;
                 href.refaddr:=addr_pcrel_lo12;
                 list.concat(taicpu.op_reg_reg_ref(A_ADDI,tmpreg,tmpreg,href));
               end;
+{$endif unsed}
+
+            reference_reset_symbol(href,ref.symbol,0,0,[]);
+            href.refaddr:=addr_full;
+            ref.symbol:=nil;
+
+            tmpreg:=getintregister(list,OS_ADDR);
+
+            list.concat(taicpu.op_reg_ref(A_LA,tmpreg,href));
 
             if (ref.index<>NR_NO) and
                (ref.base<>NR_NO) then