PNaCl.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //===--- PNaCl.h - Declare PNaCl 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 PNaCl TargetInfo objects.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_PNACL_H
  13. #define LLVM_CLANG_LIB_BASIC_TARGETS_PNACL_H
  14. #include "Mips.h"
  15. #include "clang/Basic/TargetInfo.h"
  16. #include "clang/Basic/TargetOptions.h"
  17. #include "llvm/ADT/Triple.h"
  18. #include "llvm/Support/Compiler.h"
  19. namespace clang {
  20. namespace targets {
  21. class LLVM_LIBRARY_VISIBILITY PNaClTargetInfo : public TargetInfo {
  22. public:
  23. PNaClTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
  24. : TargetInfo(Triple) {
  25. this->LongAlign = 32;
  26. this->LongWidth = 32;
  27. this->PointerAlign = 32;
  28. this->PointerWidth = 32;
  29. this->IntMaxType = TargetInfo::SignedLongLong;
  30. this->Int64Type = TargetInfo::SignedLongLong;
  31. this->DoubleAlign = 64;
  32. this->LongDoubleWidth = 64;
  33. this->LongDoubleAlign = 64;
  34. this->SizeType = TargetInfo::UnsignedInt;
  35. this->PtrDiffType = TargetInfo::SignedInt;
  36. this->IntPtrType = TargetInfo::SignedInt;
  37. this->RegParmMax = 0; // Disallow regparm
  38. }
  39. void getArchDefines(const LangOptions &Opts, MacroBuilder &Builder) const;
  40. void getTargetDefines(const LangOptions &Opts,
  41. MacroBuilder &Builder) const override {
  42. getArchDefines(Opts, Builder);
  43. }
  44. bool hasFeature(StringRef Feature) const override {
  45. return Feature == "pnacl";
  46. }
  47. ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
  48. BuiltinVaListKind getBuiltinVaListKind() const override {
  49. return TargetInfo::PNaClABIBuiltinVaList;
  50. }
  51. ArrayRef<const char *> getGCCRegNames() const override;
  52. ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
  53. bool validateAsmConstraint(const char *&Name,
  54. TargetInfo::ConstraintInfo &Info) const override {
  55. return false;
  56. }
  57. const char *getClobbers() const override { return ""; }
  58. bool hasBitIntType() const override { return true; }
  59. };
  60. // We attempt to use PNaCl (le32) frontend and Mips32EL backend.
  61. class LLVM_LIBRARY_VISIBILITY NaClMips32TargetInfo : public MipsTargetInfo {
  62. public:
  63. NaClMips32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
  64. : MipsTargetInfo(Triple, Opts) {}
  65. BuiltinVaListKind getBuiltinVaListKind() const override {
  66. return TargetInfo::PNaClABIBuiltinVaList;
  67. }
  68. };
  69. } // namespace targets
  70. } // namespace clang
  71. #endif // LLVM_CLANG_LIB_BASIC_TARGETS_PNACL_H