Home | History | Annotate | Download | only in aarch32
      1 // Copyright 2015, VIXL authors
      2 // All rights reserved.
      3 //
      4 // Redistribution and use in source and binary forms, with or without
      5 // modification, are permitted provided that the following conditions are met:
      6 //
      7 //   * Redistributions of source code must retain the above copyright notice,
      8 //     this list of conditions and the following disclaimer.
      9 //   * Redistributions in binary form must reproduce the above copyright
     10 //     notice, this list of conditions and the following disclaimer in the
     11 //     documentation and/or other materials provided with the distribution.
     12 //   * Neither the name of ARM Limited nor the names of its contributors may
     13 //     be used to endorse or promote products derived from this software
     14 //     without specific prior written permission.
     15 //
     16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
     17 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     20 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26 // POSSIBILITY OF SUCH DAMAGE.
     27 
     28 #ifndef VIXL_CONSTANTS_AARCH32_H_
     29 #define VIXL_CONSTANTS_AARCH32_H_
     30 
     31 extern "C" {
     32 #include <stdint.h>
     33 }
     34 
     35 #include "globals-vixl.h"
     36 
     37 
     38 namespace vixl {
     39 namespace aarch32 {
     40 
     41 enum InstructionSet { A32, T32 };
     42 #ifdef VIXL_INCLUDE_TARGET_T32_ONLY
     43 const InstructionSet kDefaultISA = T32;
     44 #else
     45 const InstructionSet kDefaultISA = A32;
     46 #endif
     47 
     48 const unsigned kRegSizeInBits = 32;
     49 const unsigned kRegSizeInBytes = kRegSizeInBits / 8;
     50 const unsigned kSRegSizeInBits = 32;
     51 const unsigned kSRegSizeInBytes = kSRegSizeInBits / 8;
     52 const unsigned kDRegSizeInBits = 64;
     53 const unsigned kDRegSizeInBytes = kDRegSizeInBits / 8;
     54 const unsigned kQRegSizeInBits = 128;
     55 const unsigned kQRegSizeInBytes = kQRegSizeInBits / 8;
     56 
     57 const unsigned kNumberOfRegisters = 16;
     58 const unsigned kNumberOfSRegisters = 32;
     59 const unsigned kMaxNumberOfDRegisters = 32;
     60 const unsigned kNumberOfQRegisters = 16;
     61 const unsigned kNumberOfT32LowRegisters = 8;
     62 
     63 const unsigned kIpCode = 12;
     64 const unsigned kSpCode = 13;
     65 const unsigned kLrCode = 14;
     66 const unsigned kPcCode = 15;
     67 
     68 const unsigned kT32PcDelta = 4;
     69 const unsigned kA32PcDelta = 8;
     70 
     71 const unsigned kRRXEncodedValue = 3;
     72 
     73 const unsigned kCoprocMask = 0xe;
     74 const unsigned kInvalidCoprocMask = 0xa;
     75 
     76 const unsigned kLowestT32_32Opcode = 0xe8000000;
     77 
     78 const uint32_t kUnknownValue = 0xdeadbeef;
     79 
     80 const uint32_t kMaxInstructionSizeInBytes = 4;
     81 const uint32_t kA32InstructionSizeInBytes = 4;
     82 const uint32_t k32BitT32InstructionSizeInBytes = 4;
     83 const uint32_t k16BitT32InstructionSizeInBytes = 2;
     84 
     85 // Maximum size emitted by a single T32 unconditional macro-instruction.
     86 const uint32_t kMaxT32MacroInstructionSizeInBytes = 32;
     87 
     88 const uint32_t kCallerSavedRegistersMask = 0x500f;
     89 
     90 const uint16_t k16BitT32NopOpcode = 0xbf00;
     91 const uint16_t kCbzCbnzMask = 0xf500;
     92 const uint16_t kCbzCbnzValue = 0xb100;
     93 
     94 const int32_t kCbzCbnzRange = 126;
     95 const int32_t kBConditionalNarrowRange = 254;
     96 const int32_t kBNarrowRange = 2046;
     97 const int32_t kNearLabelRange = kBNarrowRange;
     98 
     99 enum SystemFunctionsOpcodes { kPrintfCode };
    100 
    101 enum BranchHint { kNear, kFar, kBranchWithoutHint };
    102 
    103 // Start of generated code.
    104 enum InstructionAttribute {
    105   kNoAttribute = 0,
    106   kArithmetic = 0x1,
    107   kBitwise = 0x2,
    108   kShift = 0x4,
    109   kAddress = 0x8,
    110   kBranch = 0x10,
    111   kSystem = 0x20,
    112   kFpNeon = 0x40,
    113   kLoadStore = 0x80,
    114   kLoadStoreMultiple = 0x100
    115 };
    116 
    117 enum InstructionType {
    118   kUndefInstructionType,
    119   kAdc,
    120   kAdcs,
    121   kAdd,
    122   kAdds,
    123   kAddw,
    124   kAdr,
    125   kAnd,
    126   kAnds,
    127   kAsr,
    128   kAsrs,
    129   kB,
    130   kBfc,
    131   kBfi,
    132   kBic,
    133   kBics,
    134   kBkpt,
    135   kBl,
    136   kBlx,
    137   kBx,
    138   kBxj,
    139   kCbnz,
    140   kCbz,
    141   kClrex,
    142   kClz,
    143   kCmn,
    144   kCmp,
    145   kCrc32b,
    146   kCrc32cb,
    147   kCrc32ch,
    148   kCrc32cw,
    149   kCrc32h,
    150   kCrc32w,
    151   kDmb,
    152   kDsb,
    153   kEor,
    154   kEors,
    155   kFldmdbx,
    156   kFldmiax,
    157   kFstmdbx,
    158   kFstmiax,
    159   kHlt,
    160   kHvc,
    161   kIsb,
    162   kIt,
    163   kLda,
    164   kLdab,
    165   kLdaex,
    166   kLdaexb,
    167   kLdaexd,
    168   kLdaexh,
    169   kLdah,
    170   kLdm,
    171   kLdmda,
    172   kLdmdb,
    173   kLdmea,
    174   kLdmed,
    175   kLdmfa,
    176   kLdmfd,
    177   kLdmib,
    178   kLdr,
    179   kLdrb,
    180   kLdrd,
    181   kLdrex,
    182   kLdrexb,
    183   kLdrexd,
    184   kLdrexh,
    185   kLdrh,
    186   kLdrsb,
    187   kLdrsh,
    188   kLsl,
    189   kLsls,
    190   kLsr,
    191   kLsrs,
    192   kMla,
    193   kMlas,
    194   kMls,
    195   kMov,
    196   kMovs,
    197   kMovt,
    198   kMovw,
    199   kMrs,
    200   kMsr,
    201   kMul,
    202   kMuls,
    203   kMvn,
    204   kMvns,
    205   kNop,
    206   kOrn,
    207   kOrns,
    208   kOrr,
    209   kOrrs,
    210   kPkhbt,
    211   kPkhtb,
    212   kPld,
    213   kPldw,
    214   kPli,
    215   kPop,
    216   kPush,
    217   kQadd,
    218   kQadd16,
    219   kQadd8,
    220   kQasx,
    221   kQdadd,
    222   kQdsub,
    223   kQsax,
    224   kQsub,
    225   kQsub16,
    226   kQsub8,
    227   kRbit,
    228   kRev,
    229   kRev16,
    230   kRevsh,
    231   kRor,
    232   kRors,
    233   kRrx,
    234   kRrxs,
    235   kRsb,
    236   kRsbs,
    237   kRsc,
    238   kRscs,
    239   kSadd16,
    240   kSadd8,
    241   kSasx,
    242   kSbc,
    243   kSbcs,
    244   kSbfx,
    245   kSdiv,
    246   kSel,
    247   kShadd16,
    248   kShadd8,
    249   kShasx,
    250   kShsax,
    251   kShsub16,
    252   kShsub8,
    253   kSmlabb,
    254   kSmlabt,
    255   kSmlad,
    256   kSmladx,
    257   kSmlal,
    258   kSmlalbb,
    259   kSmlalbt,
    260   kSmlald,
    261   kSmlaldx,
    262   kSmlals,
    263   kSmlaltb,
    264   kSmlaltt,
    265   kSmlatb,
    266   kSmlatt,
    267   kSmlawb,
    268   kSmlawt,
    269   kSmlsd,
    270   kSmlsdx,
    271   kSmlsld,
    272   kSmlsldx,
    273   kSmmla,
    274   kSmmlar,
    275   kSmmls,
    276   kSmmlsr,
    277   kSmmul,
    278   kSmmulr,
    279   kSmuad,
    280   kSmuadx,
    281   kSmulbb,
    282   kSmulbt,
    283   kSmull,
    284   kSmulls,
    285   kSmultb,
    286   kSmultt,
    287   kSmulwb,
    288   kSmulwt,
    289   kSmusd,
    290   kSmusdx,
    291   kSsat,
    292   kSsat16,
    293   kSsax,
    294   kSsub16,
    295   kSsub8,
    296   kStl,
    297   kStlb,
    298   kStlex,
    299   kStlexb,
    300   kStlexd,
    301   kStlexh,
    302   kStlh,
    303   kStm,
    304   kStmda,
    305   kStmdb,
    306   kStmea,
    307   kStmed,
    308   kStmfa,
    309   kStmfd,
    310   kStmib,
    311   kStr,
    312   kStrb,
    313   kStrd,
    314   kStrex,
    315   kStrexb,
    316   kStrexd,
    317   kStrexh,
    318   kStrh,
    319   kSub,
    320   kSubs,
    321   kSubw,
    322   kSvc,
    323   kSxtab,
    324   kSxtab16,
    325   kSxtah,
    326   kSxtb,
    327   kSxtb16,
    328   kSxth,
    329   kTbb,
    330   kTbh,
    331   kTeq,
    332   kTst,
    333   kUadd16,
    334   kUadd8,
    335   kUasx,
    336   kUbfx,
    337   kUdf,
    338   kUdiv,
    339   kUhadd16,
    340   kUhadd8,
    341   kUhasx,
    342   kUhsax,
    343   kUhsub16,
    344   kUhsub8,
    345   kUmaal,
    346   kUmlal,
    347   kUmlals,
    348   kUmull,
    349   kUmulls,
    350   kUqadd16,
    351   kUqadd8,
    352   kUqasx,
    353   kUqsax,
    354   kUqsub16,
    355   kUqsub8,
    356   kUsad8,
    357   kUsada8,
    358   kUsat,
    359   kUsat16,
    360   kUsax,
    361   kUsub16,
    362   kUsub8,
    363   kUxtab,
    364   kUxtab16,
    365   kUxtah,
    366   kUxtb,
    367   kUxtb16,
    368   kUxth,
    369   kVaba,
    370   kVabal,
    371   kVabd,
    372   kVabdl,
    373   kVabs,
    374   kVacge,
    375   kVacgt,
    376   kVacle,
    377   kVaclt,
    378   kVadd,
    379   kVaddhn,
    380   kVaddl,
    381   kVaddw,
    382   kVand,
    383   kVbic,
    384   kVbif,
    385   kVbit,
    386   kVbsl,
    387   kVceq,
    388   kVcge,
    389   kVcgt,
    390   kVcle,
    391   kVcls,
    392   kVclt,
    393   kVclz,
    394   kVcmp,
    395   kVcmpe,
    396   kVcnt,
    397   kVcvt,
    398   kVcvta,
    399   kVcvtb,
    400   kVcvtm,
    401   kVcvtn,
    402   kVcvtp,
    403   kVcvtr,
    404   kVcvtt,
    405   kVdiv,
    406   kVdup,
    407   kVeor,
    408   kVext,
    409   kVfma,
    410   kVfms,
    411   kVfnma,
    412   kVfnms,
    413   kVhadd,
    414   kVhsub,
    415   kVld1,
    416   kVld2,
    417   kVld3,
    418   kVld4,
    419   kVldm,
    420   kVldmdb,
    421   kVldmia,
    422   kVldr,
    423   kVmax,
    424   kVmaxnm,
    425   kVmin,
    426   kVminnm,
    427   kVmla,
    428   kVmlal,
    429   kVmls,
    430   kVmlsl,
    431   kVmov,
    432   kVmovl,
    433   kVmovn,
    434   kVmrs,
    435   kVmsr,
    436   kVmul,
    437   kVmull,
    438   kVmvn,
    439   kVneg,
    440   kVnmla,
    441   kVnmls,
    442   kVnmul,
    443   kVorn,
    444   kVorr,
    445   kVpadal,
    446   kVpadd,
    447   kVpaddl,
    448   kVpmax,
    449   kVpmin,
    450   kVpop,
    451   kVpush,
    452   kVqabs,
    453   kVqadd,
    454   kVqdmlal,
    455   kVqdmlsl,
    456   kVqdmulh,
    457   kVqdmull,
    458   kVqmovn,
    459   kVqmovun,
    460   kVqneg,
    461   kVqrdmulh,
    462   kVqrshl,
    463   kVqrshrn,
    464   kVqrshrun,
    465   kVqshl,
    466   kVqshlu,
    467   kVqshrn,
    468   kVqshrun,
    469   kVqsub,
    470   kVraddhn,
    471   kVrecpe,
    472   kVrecps,
    473   kVrev16,
    474   kVrev32,
    475   kVrev64,
    476   kVrhadd,
    477   kVrinta,
    478   kVrintm,
    479   kVrintn,
    480   kVrintp,
    481   kVrintr,
    482   kVrintx,
    483   kVrintz,
    484   kVrshl,
    485   kVrshr,
    486   kVrshrn,
    487   kVrsqrte,
    488   kVrsqrts,
    489   kVrsra,
    490   kVrsubhn,
    491   kVseleq,
    492   kVselge,
    493   kVselgt,
    494   kVselvs,
    495   kVshl,
    496   kVshll,
    497   kVshr,
    498   kVshrn,
    499   kVsli,
    500   kVsqrt,
    501   kVsra,
    502   kVsri,
    503   kVst1,
    504   kVst2,
    505   kVst3,
    506   kVst4,
    507   kVstm,
    508   kVstmdb,
    509   kVstmia,
    510   kVstr,
    511   kVsub,
    512   kVsubhn,
    513   kVsubl,
    514   kVsubw,
    515   kVswp,
    516   kVtbl,
    517   kVtbx,
    518   kVtrn,
    519   kVtst,
    520   kVuzp,
    521   kVzip,
    522   kYield
    523 };
    524 
    525 const char* ToCString(InstructionType type);
    526 // End of generated code.
    527 
    528 inline InstructionAttribute operator|(InstructionAttribute left,
    529                                       InstructionAttribute right) {
    530   return static_cast<InstructionAttribute>(static_cast<uint32_t>(left) |
    531                                            static_cast<uint32_t>(right));
    532 }
    533 
    534 }  // namespace aarch32
    535 }  // namespace vixl
    536 
    537 #endif  // VIXL_CONSTANTS_AARCH32_H_
    538