View Issue Details

IDProjectCategoryView StatusLast Update
0036697FPCCompilerpublic2020-02-13 18:00
ReporterChristo CrauseAssigned ToFlorian 
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0036697: AVR [patch] Combine code paths for avr1 and avrtiny when converting lds/sts to in/out
DescriptionAttached please find a patch that changes the lds/sts to in/out conversions for avr1 and avrtiny into a slightly more compact form. No functionality should be modified by this.
TagsNo tags attached.
Fixed in Revision44163
FPCOldBugId
FPCTarget-
Attached Files
  • lds-sts.patch (5,154 bytes)
    diff --git a/compiler/avr/aasmcpu.pas b/compiler/avr/aasmcpu.pas
    index 2989ac4b44..f427a8e365 100644
    --- a/compiler/avr/aasmcpu.pas
    +++ b/compiler/avr/aasmcpu.pas
    @@ -509,61 +509,33 @@ implementation
                               end;
                             A_STS:
                               begin
    -                            { certain cpu types do not support some instructions, so replace them }
    -                            case current_settings.cputype of
    -                              cpu_avr1:
    -                                begin
    -                                  with taicpu(curtai).oper[0]^ do
    -                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
    -                                      begin
    -                                        taicpu(curtai).opcode:=A_OUT;
    -                                        taicpu(curtai).loadconst(0,ref^.offset);
    -                                      end
    -                                    else
    -                                      begin
    -                                        remove_instruction;
    -                                        result:=false;
    -                                      end;
    -                                end;
    -                              cpu_avrtiny:
    -                                begin
    -                                  with taicpu(curtai).oper[0]^ do
    -                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
    -                                      begin
    -                                        taicpu(curtai).opcode:=A_OUT;
    -                                        taicpu(curtai).loadconst(0,ref^.offset);
    -                                      end;
    -                                end;
    -                            end;
    +                            if current_settings.cputype in [cpu_avrtiny, cpu_avr1] then
    +                              with taicpu(curtai).oper[0]^ do
    +                                if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
    +                                  begin
    +                                    taicpu(curtai).opcode:=A_OUT;
    +                                    taicpu(curtai).loadconst(0,ref^.offset);
    +                                  end
    +                                else if current_settings.cputype=cpu_avr1 then
    +                                  begin
    +                                    remove_instruction;
    +                                    result:=false;
    +                                  end;
                               end;
                             A_LDS:
                               begin
    -                            { certain cpu types do not support some instructions, so replace them }
    -                            case current_settings.cputype of
    -                              cpu_avr1:
    -                                begin
    -                                  with taicpu(curtai).oper[1]^ do
    -                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
    -                                      begin
    -                                        taicpu(curtai).opcode:=A_IN;
    -                                        taicpu(curtai).loadconst(1,ref^.offset)
    -                                      end
    -                                    else
    -                                      begin
    -                                        remove_instruction;
    -                                        result:=false;
    -                                      end;
    -                                end;
    -                              cpu_avrtiny:
    -                                begin
    -                                  with taicpu(curtai).oper[1]^ do
    -                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
    -                                      begin
    -                                        taicpu(curtai).opcode:=A_IN;
    -                                        taicpu(curtai).loadconst(1,ref^.offset)
    -                                      end;
    -                                end;
    -                            end;
    +                            if current_settings.cputype in [cpu_avrtiny, cpu_avr1] then
    +                              with taicpu(curtai).oper[1]^ do
    +                                if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
    +                                  begin
    +                                    taicpu(curtai).opcode:=A_IN;
    +                                    taicpu(curtai).loadconst(1,ref^.offset)
    +                                  end
    +                                else if current_settings.cputype=cpu_avr1 then
    +                                  begin
    +                                    remove_instruction;
    +                                    result:=false;
    +                                  end;
                               end;
                             A_SBIW,
                             A_MULS,
    
    lds-sts.patch (5,154 bytes)

Activities

Christo Crause

2020-02-12 20:04

reporter  

lds-sts.patch (5,154 bytes)
diff --git a/compiler/avr/aasmcpu.pas b/compiler/avr/aasmcpu.pas
index 2989ac4b44..f427a8e365 100644
--- a/compiler/avr/aasmcpu.pas
+++ b/compiler/avr/aasmcpu.pas
@@ -509,61 +509,33 @@ implementation
                           end;
                         A_STS:
                           begin
-                            { certain cpu types do not support some instructions, so replace them }
-                            case current_settings.cputype of
-                              cpu_avr1:
-                                begin
-                                  with taicpu(curtai).oper[0]^ do
-                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
-                                      begin
-                                        taicpu(curtai).opcode:=A_OUT;
-                                        taicpu(curtai).loadconst(0,ref^.offset);
-                                      end
-                                    else
-                                      begin
-                                        remove_instruction;
-                                        result:=false;
-                                      end;
-                                end;
-                              cpu_avrtiny:
-                                begin
-                                  with taicpu(curtai).oper[0]^ do
-                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
-                                      begin
-                                        taicpu(curtai).opcode:=A_OUT;
-                                        taicpu(curtai).loadconst(0,ref^.offset);
-                                      end;
-                                end;
-                            end;
+                            if current_settings.cputype in [cpu_avrtiny, cpu_avr1] then
+                              with taicpu(curtai).oper[0]^ do
+                                if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
+                                  begin
+                                    taicpu(curtai).opcode:=A_OUT;
+                                    taicpu(curtai).loadconst(0,ref^.offset);
+                                  end
+                                else if current_settings.cputype=cpu_avr1 then
+                                  begin
+                                    remove_instruction;
+                                    result:=false;
+                                  end;
                           end;
                         A_LDS:
                           begin
-                            { certain cpu types do not support some instructions, so replace them }
-                            case current_settings.cputype of
-                              cpu_avr1:
-                                begin
-                                  with taicpu(curtai).oper[1]^ do
-                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
-                                      begin
-                                        taicpu(curtai).opcode:=A_IN;
-                                        taicpu(curtai).loadconst(1,ref^.offset)
-                                      end
-                                    else
-                                      begin
-                                        remove_instruction;
-                                        result:=false;
-                                      end;
-                                end;
-                              cpu_avrtiny:
-                                begin
-                                  with taicpu(curtai).oper[1]^ do
-                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
-                                      begin
-                                        taicpu(curtai).opcode:=A_IN;
-                                        taicpu(curtai).loadconst(1,ref^.offset)
-                                      end;
-                                end;
-                            end;
+                            if current_settings.cputype in [cpu_avrtiny, cpu_avr1] then
+                              with taicpu(curtai).oper[1]^ do
+                                if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
+                                  begin
+                                    taicpu(curtai).opcode:=A_IN;
+                                    taicpu(curtai).loadconst(1,ref^.offset)
+                                  end
+                                else if current_settings.cputype=cpu_avr1 then
+                                  begin
+                                    remove_instruction;
+                                    result:=false;
+                                  end;
                           end;
                         A_SBIW,
                         A_MULS,
lds-sts.patch (5,154 bytes)

Florian

2020-02-12 21:43

administrator   ~0121060

Thanks, applied.

Christo Crause

2020-02-13 18:00

reporter   ~0121085

Thank you.

Issue History

Date Modified Username Field Change
2020-02-12 20:04 Christo Crause New Issue
2020-02-12 20:04 Christo Crause File Added: lds-sts.patch
2020-02-12 21:43 Florian Assigned To => Florian
2020-02-12 21:43 Florian Status new => resolved
2020-02-12 21:43 Florian Resolution open => fixed
2020-02-12 21:43 Florian Fixed in Version => 3.3.1
2020-02-12 21:43 Florian Fixed in Revision => 44163
2020-02-12 21:43 Florian FPCTarget => -
2020-02-12 21:43 Florian Note Added: 0121060
2020-02-13 18:00 Christo Crause Status resolved => closed
2020-02-13 18:00 Christo Crause Note Added: 0121085