ARMBaseInfo.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //===-- ARMBaseInfo.cpp - ARM Base encoding information------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file provides basic encoding and assembly information for ARM.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "ARMBaseInfo.h"
  13. #include "llvm/ADT/ArrayRef.h"
  14. #include "llvm/ADT/SmallVector.h"
  15. using namespace llvm;
  16. namespace llvm {
  17. ARM::PredBlockMask expandPredBlockMask(ARM::PredBlockMask BlockMask,
  18. ARMVCC::VPTCodes Kind) {
  19. using PredBlockMask = ARM::PredBlockMask;
  20. assert(Kind != ARMVCC::None && "Cannot expand a mask with None!");
  21. assert(countTrailingZeros((unsigned)BlockMask) != 0 &&
  22. "Mask is already full");
  23. auto ChooseMask = [&](PredBlockMask AddedThen, PredBlockMask AddedElse) {
  24. return Kind == ARMVCC::Then ? AddedThen : AddedElse;
  25. };
  26. switch (BlockMask) {
  27. case PredBlockMask::T:
  28. return ChooseMask(PredBlockMask::TT, PredBlockMask::TE);
  29. case PredBlockMask::TT:
  30. return ChooseMask(PredBlockMask::TTT, PredBlockMask::TTE);
  31. case PredBlockMask::TE:
  32. return ChooseMask(PredBlockMask::TET, PredBlockMask::TEE);
  33. case PredBlockMask::TTT:
  34. return ChooseMask(PredBlockMask::TTTT, PredBlockMask::TTTE);
  35. case PredBlockMask::TTE:
  36. return ChooseMask(PredBlockMask::TTET, PredBlockMask::TTEE);
  37. case PredBlockMask::TET:
  38. return ChooseMask(PredBlockMask::TETT, PredBlockMask::TETE);
  39. case PredBlockMask::TEE:
  40. return ChooseMask(PredBlockMask::TEET, PredBlockMask::TEEE);
  41. default:
  42. llvm_unreachable("Unknown Mask");
  43. }
  44. }
  45. namespace ARMSysReg {
  46. // lookup system register using 12-bit SYSm value.
  47. // Note: the search is uniqued using M1 mask
  48. const MClassSysReg *lookupMClassSysRegBy12bitSYSmValue(unsigned SYSm) {
  49. return lookupMClassSysRegByM1Encoding12(SYSm);
  50. }
  51. // returns APSR with _<bits> qualifier.
  52. // Note: ARMv7-M deprecates using MSR APSR without a _<bits> qualifier
  53. const MClassSysReg *lookupMClassSysRegAPSRNonDeprecated(unsigned SYSm) {
  54. return lookupMClassSysRegByM2M3Encoding8((1<<9)|(SYSm & 0xFF));
  55. }
  56. // lookup system registers using 8-bit SYSm value
  57. const MClassSysReg *lookupMClassSysRegBy8bitSYSmValue(unsigned SYSm) {
  58. return ARMSysReg::lookupMClassSysRegByM2M3Encoding8((1<<8)|(SYSm & 0xFF));
  59. }
  60. #define GET_MCLASSSYSREG_IMPL
  61. #include "ARMGenSystemRegister.inc"
  62. } // end namespace ARMSysReg
  63. namespace ARMBankedReg {
  64. #define GET_BANKEDREG_IMPL
  65. #include "ARMGenSystemRegister.inc"
  66. } // end namespce ARMSysReg
  67. } // end namespace llvm