MSP430.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //===--- MSP430.h - Declare MSP430 target feature support -------*- C++ -*-===//
  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 declares MSP430 TargetInfo objects.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H
  13. #define LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H
  14. #include "clang/Basic/TargetInfo.h"
  15. #include "clang/Basic/TargetOptions.h"
  16. #include "llvm/ADT/Triple.h"
  17. #include "llvm/Support/Compiler.h"
  18. namespace clang {
  19. namespace targets {
  20. class LLVM_LIBRARY_VISIBILITY MSP430TargetInfo : public TargetInfo {
  21. static const char *const GCCRegNames[];
  22. public:
  23. MSP430TargetInfo(const llvm::Triple &Triple, const TargetOptions &)
  24. : TargetInfo(Triple) {
  25. TLSSupported = false;
  26. IntWidth = 16;
  27. IntAlign = 16;
  28. LongWidth = 32;
  29. LongLongWidth = 64;
  30. LongAlign = LongLongAlign = 16;
  31. FloatWidth = 32;
  32. FloatAlign = 16;
  33. DoubleWidth = LongDoubleWidth = 64;
  34. DoubleAlign = LongDoubleAlign = 16;
  35. PointerWidth = 16;
  36. PointerAlign = 16;
  37. SuitableAlign = 16;
  38. SizeType = UnsignedInt;
  39. IntMaxType = SignedLongLong;
  40. IntPtrType = SignedInt;
  41. PtrDiffType = SignedInt;
  42. SigAtomicType = SignedLong;
  43. resetDataLayout("e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16");
  44. }
  45. void getTargetDefines(const LangOptions &Opts,
  46. MacroBuilder &Builder) const override;
  47. ArrayRef<Builtin::Info> getTargetBuiltins() const override {
  48. // FIXME: Implement.
  49. return None;
  50. }
  51. bool allowsLargerPreferedTypeAlignment() const override { return false; }
  52. bool hasFeature(StringRef Feature) const override {
  53. return Feature == "msp430";
  54. }
  55. ArrayRef<const char *> getGCCRegNames() const override;
  56. ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
  57. // Make r0 - r3 be recognized by llc (f.e., in clobber list)
  58. static const TargetInfo::GCCRegAlias GCCRegAliases[] = {
  59. {{"r0"}, "pc"},
  60. {{"r1"}, "sp"},
  61. {{"r2"}, "sr"},
  62. {{"r3"}, "cg"},
  63. };
  64. return llvm::makeArrayRef(GCCRegAliases);
  65. }
  66. bool validateAsmConstraint(const char *&Name,
  67. TargetInfo::ConstraintInfo &info) const override {
  68. // FIXME: implement
  69. switch (*Name) {
  70. case 'K': // the constant 1
  71. case 'L': // constant -1^20 .. 1^19
  72. case 'M': // constant 1-4:
  73. return true;
  74. }
  75. // No target constraints for now.
  76. return false;
  77. }
  78. const char *getClobbers() const override {
  79. // FIXME: Is this really right?
  80. return "";
  81. }
  82. BuiltinVaListKind getBuiltinVaListKind() const override {
  83. // FIXME: implement
  84. return TargetInfo::CharPtrBuiltinVaList;
  85. }
  86. };
  87. } // namespace targets
  88. } // namespace clang
  89. #endif // LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H