]> git.sur5r.net Git - cc65/blobdiff - src/cc65/codeinfo.c
Improved optimizations
[cc65] / src / cc65 / codeinfo.c
index f968b12d21e2767b2a6a68de81fb199adda75e38..322b471ff0e8109a9bfb0d906d870ff67a7cb614 100644 (file)
@@ -154,8 +154,8 @@ static const FuncInfo FuncInfoTable[] = {
     { "push7",                 REG_NONE,             REG_AXY                        },
     { "pusha",                 REG_A,                REG_Y                          },
     { "pusha0",                REG_A,                REG_XY                         },
-    { "pushax",                REG_AX,               REG_Y                          },
     { "pusha0sp",       REG_NONE,             REG_AY                         },
+    { "pushax",                REG_AX,               REG_Y                          },
     { "pushaysp",       REG_Y,                REG_AY                         },
     { "pushc0",                REG_NONE,             REG_A | REG_Y                  },
     { "pushc1",                REG_NONE,             REG_A | REG_Y                  },
@@ -165,6 +165,9 @@ static const FuncInfo FuncInfoTable[] = {
     { "pushw0sp",              REG_NONE,             REG_AXY                        },
     { "pushwidx",              REG_AXY,              REG_AXY | REG_PTR1             },
     { "pushwysp",              REG_Y,                REG_AXY                        },
+    { "regswap",        REG_AXY,              REG_AXY | REG_TMP1             },
+    { "regswap1",       REG_XY,               REG_A                          },
+    { "regswap2",       REG_XY,               REG_A | REG_Y                  },
     { "shlax1",         REG_AX,                      REG_AX | REG_TMP1              },
     { "shlax2",         REG_AX,                      REG_AX | REG_TMP1              },
     { "shlax3",         REG_AX,                      REG_AX | REG_TMP1              },
@@ -284,8 +287,7 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg)
            FuncDesc* D = E->V.F.Func;
            if ((D->Flags & FD_FASTCALL) != 0 && D->ParamCount > 0) {
                /* Will use registers depending on the last param */
-               SymEntry* LastParam = D->SymTab->SymTail;
-                unsigned LastParamSize = CheckedSizeOf (LastParam->Type);
+                unsigned LastParamSize = CheckedSizeOf (D->LastParam->Type);
                if (LastParamSize == 1) {
                    *Use = REG_A;
                } else if (LastParamSize == 2) {
@@ -614,6 +616,10 @@ unsigned GetKnownReg (unsigned Use, const RegContents* RC)
        return (RC == 0 || RC->RegY >= 0)? REG_Y : REG_NONE;
     } else if ((Use & REG_TMP1) != 0) {
        return (RC == 0 || RC->Tmp1 >= 0)? REG_TMP1 : REG_NONE;
+    } else if ((Use & REG_PTR1_LO) != 0) {
+       return (RC == 0 || RC->Ptr1Lo >= 0)? REG_PTR1_LO : REG_NONE;
+    } else if ((Use & REG_PTR1_HI) != 0) {
+       return (RC == 0 || RC->Ptr1Hi >= 0)? REG_PTR1_HI : REG_NONE;
     } else if ((Use & REG_SREG_LO) != 0) {
        return (RC == 0 || RC->SRegLo >= 0)? REG_SREG_LO : REG_NONE;
     } else if ((Use & REG_SREG_HI) != 0) {
@@ -623,7 +629,7 @@ unsigned GetKnownReg (unsigned Use, const RegContents* RC)
     }
 }
 
-
+                              
 
 static cmp_t FindCmpCond (const char* Code, unsigned CodeLen)
 /* Search for a compare condition by the given code using the given length */