Browse Source

m68k: add tables to convert from some stub opcodes + condition into real opcodes. Use them in the external assembler writer for now. Later the internal assembler will need these tables too.

Karoly Balogh 2 years ago
parent
commit
c577ac5ce9
2 changed files with 43 additions and 12 deletions
  1. 16 12
      compiler/m68k/ag68kgas.pas
  2. 27 0
      compiler/m68k/cpubase.pas

+ 16 - 12
compiler/m68k/ag68kgas.pas

@@ -275,27 +275,31 @@ interface
       begin
       begin
         op:=taicpu(hp).opcode;
         op:=taicpu(hp).opcode;
         case op of
         case op of
+          { FIX ME: in the opcode tables, we have information about which opcode
+            has a single possible size. Figure out if/how we can include checking
+            against that info instead of this mess. }
+          A_DBRA,
           A_LEA,A_PEA,A_ABCD,A_BCHG,A_BCLR,A_BSET,A_BTST,
           A_LEA,A_PEA,A_ABCD,A_BCHG,A_BCLR,A_BSET,A_BTST,
           A_EXG,A_NBCD,A_SBCD,A_SWAP,A_TAS,A_SCC,A_SCS,
           A_EXG,A_NBCD,A_SBCD,A_SWAP,A_TAS,A_SCC,A_SCS,
           A_SEQ,A_SGE,A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI,
           A_SEQ,A_SGE,A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI,
           A_SNE,A_SPL,A_ST,A_SVC,A_SVS,A_SF:
           A_SNE,A_SPL,A_ST,A_SVC,A_SVS,A_SF:
-            { old versions of GAS don't like PEA.L and LEA.L }
             result:=gas_op2str[op];
             result:=gas_op2str[op];
-          A_SXX, A_FSXX, A_DBXX, A_DBRA:
-            begin
-              { Scc/FScc is always BYTE, DBRA/DBcc is always WORD, doesn't need opsize (KB) }
-              result:=gas_op2str[op];
-              replace(result,'xx',cond2str[taicpu(hp).condition]);
-            end;
-          { fix me: a fugly hack to utilize GNU AS pseudo instructions for more optimal branching }
+          A_SXX:
+            result:=gas_op2str[cond2sxx[taicpu(hp).condition]];
+          A_FSXX:
+            result:=gas_op2str[cond2fsxx[taicpu(hp).condition]];
+          A_DBXX:
+            result:=gas_op2str[cond2dbxx[taicpu(hp).condition]];
+
+          { a bit of a hackery to utilize GNU AS pseudo instructions for more optimal branching }
           A_JSR:
           A_JSR:
-            result:='jbsr';
+            result:=gas_op2str[A_JBSR];
           A_JMP:
           A_JMP:
-            result:='jra';
+            result:=gas_op2str[A_JRA];
           A_BXX:
           A_BXX:
-            result:='j'+cond2str[taicpu(hp).condition]+gas_opsize2str[taicpu(hp).opsize];
+            result:=gas_op2str[cond2jxx[taicpu(hp).condition]]+gas_opsize2str[taicpu(hp).opsize];
           A_FBXX:
           A_FBXX:
-            result:='fj'+{gas_op2str[op]+}cond2str[taicpu(hp).condition]+gas_opsize2str[taicpu(hp).opsize];
+            result:=gas_op2str[cond2fjxx[taicpu(hp).condition]]+gas_opsize2str[taicpu(hp).opsize];
           else
           else
             result:=gas_op2str[op]+gas_opsize2str[taicpu(hp).opsize];
             result:=gas_op2str[op]+gas_opsize2str[taicpu(hp).opsize];
         end;
         end;

+ 27 - 0
compiler/m68k/cpubase.pas

@@ -119,6 +119,33 @@ unit cpubase;
         'ge','pl','gt','t','hi','vc','le','vs'
         'ge','pl','gt','t','hi','vc','le','vs'
       );
       );
 
 
+    const
+      cond2bxx: array[TAsmCond] of tasmop = (A_NONE,
+        A_BCC, A_BLS, A_BCS, A_BLT, A_BEQ, A_BMI, A_NONE, A_BNE,
+        A_BGE, A_BPL, A_BGT, A_NONE, A_BHI, A_BVC, A_BLE, A_BVS
+      );
+      cond2sxx: array[TAsmCond] of tasmop = (A_NONE,
+        A_SCC, A_SLS, A_SCS, A_SLT, A_SEQ, A_SMI, A_SF, A_SNE,
+        A_SGE, A_SPL, A_SGT, A_ST, A_SHI, A_SVC, A_SLE, A_SVS
+      );
+      cond2fsxx: array[TAsmCond] of tasmop = (A_NONE,
+        A_NONE, A_NONE, A_NONE, A_FSLT, A_FSEQ, A_NONE, A_FSF, A_FSNE,
+        A_FSGE, A_NONE, A_FSGT, A_FST, A_NONE, A_NONE, A_FSLE, A_NONE
+      );
+      cond2dbxx: array[TAsmCond] of tasmop = (A_NONE,
+        A_DBCC, A_DBLS, A_DBCS, A_DBLT, A_DBEQ, A_DBMI, A_DBF, A_DBNE,
+        A_DBGE, A_DBPL, A_DBGT, A_DBT, A_DBHI, A_DBVC, A_DBLE, A_DBVS
+      );
+      cond2jxx: array[TAsmCond] of tasmop = (A_NONE,
+        A_JCC, A_JLS, A_JCS, A_JLT, A_JEQ, A_JMI, A_NONE, A_JNE,
+        A_JGE, A_JPL, A_JGT, A_NONE, A_JHI, A_JVC, A_JLE, A_JVS
+      );
+      cond2fjxx: array[TAsmCond] of tasmop = (A_NONE,
+        A_NONE, A_NONE, A_NONE, A_FJLT, A_FJEQ, A_NONE, A_FJF, A_FJNE,
+        A_FJGE, A_NONE, A_FJGT, A_FJT, A_NONE, A_NONE, A_FJLE, A_NONE
+      );
+
+
 {*****************************************************************************
 {*****************************************************************************
                                    Flags
                                    Flags
 *****************************************************************************}
 *****************************************************************************}