|
| 1 | +//===--- Xtensa.h - Declare Xtensa target feature support -------*- C++ -*-===// |
| 2 | +// |
| 3 | +// The LLVM Compiler Infrastructure |
| 4 | +// |
| 5 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 6 | +// See https://llvm.org/LICENSE.txt for license information. |
| 7 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 8 | +// |
| 9 | +//===----------------------------------------------------------------------===// |
| 10 | +// |
| 11 | +// This file declares Xtensa TargetInfo objects. |
| 12 | +// |
| 13 | +//===----------------------------------------------------------------------===// |
| 14 | + |
| 15 | +#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_XTENSA_H |
| 16 | +#define LLVM_CLANG_LIB_BASIC_TARGETS_XTENSA_H |
| 17 | + |
| 18 | +#include "clang/Basic/TargetInfo.h" |
| 19 | +#include "clang/Basic/TargetOptions.h" |
| 20 | +#include "llvm/ADT/StringSwitch.h" |
| 21 | +#include "llvm/Support/Compiler.h" |
| 22 | +#include "llvm/TargetParser/Triple.h" |
| 23 | + |
| 24 | +#include "clang/Basic/Builtins.h" |
| 25 | +#include "clang/Basic/MacroBuilder.h" |
| 26 | +#include "clang/Basic/TargetBuiltins.h" |
| 27 | + |
| 28 | +namespace clang { |
| 29 | +namespace targets { |
| 30 | + |
| 31 | +class LLVM_LIBRARY_VISIBILITY XtensaTargetInfo : public TargetInfo { |
| 32 | + static const Builtin::Info BuiltinInfo[]; |
| 33 | + |
| 34 | +protected: |
| 35 | + std::string CPU; |
| 36 | + bool HasFP = false; |
| 37 | + bool HasWindowed = false; |
| 38 | + bool HasBoolean = false; |
| 39 | + bool HasHIFI3 = false; |
| 40 | + bool HasDensity = false; |
| 41 | + bool HasLoop = false; |
| 42 | + bool HasSEXT = false; |
| 43 | + bool HasNSA = false; |
| 44 | + bool HasCLAPMS = false; |
| 45 | + bool HasMINMAX = false; |
| 46 | + bool HasMul16 = false; |
| 47 | + bool HasMul32 = false; |
| 48 | + bool HasMul32High = false; |
| 49 | + bool HasDiv32 = false; |
| 50 | + bool HasMAC16 = false; |
| 51 | + bool HasS32C1I = false; |
| 52 | + bool HasTHREADPTR = false; |
| 53 | + bool HasExtendedL32R = false; |
| 54 | + bool HasATOMCTL = false; |
| 55 | + bool HasMEMCTL = false; |
| 56 | + bool HasDebug = false; |
| 57 | + bool HasException = false; |
| 58 | + bool HasHighPriInterrupts = false; |
| 59 | + bool HasCoprocessor = false; |
| 60 | + bool HasInterrupt = false; |
| 61 | + bool HasRelocatableVector = false; |
| 62 | + bool HasTimerInt = false; |
| 63 | + bool HasPRID = false; |
| 64 | + bool HasRegionProtection = false; |
| 65 | + bool HasMiscSR = false; |
| 66 | + |
| 67 | +public: |
| 68 | + XtensaTargetInfo(const llvm::Triple &Triple, const TargetOptions &) |
| 69 | + : TargetInfo(Triple) { |
| 70 | + BigEndian = false; |
| 71 | + NoAsmVariants = true; |
| 72 | + LongLongAlign = 64; |
| 73 | + SuitableAlign = 32; |
| 74 | + DoubleAlign = LongDoubleAlign = 64; |
| 75 | + SizeType = UnsignedInt; |
| 76 | + PtrDiffType = SignedInt; |
| 77 | + IntPtrType = SignedInt; |
| 78 | + WCharType = SignedInt; |
| 79 | + WIntType = UnsignedInt; |
| 80 | + UseZeroLengthBitfieldAlignment = true; |
| 81 | + MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32; |
| 82 | + resetDataLayout("e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32"); |
| 83 | + } |
| 84 | + |
| 85 | + void getTargetDefines(const LangOptions &Opts, |
| 86 | + MacroBuilder &Builder) const override; |
| 87 | + |
| 88 | + ArrayRef<Builtin::Info> getTargetBuiltins() const override { |
| 89 | + return std::nullopt; |
| 90 | + } |
| 91 | + |
| 92 | + BuiltinVaListKind getBuiltinVaListKind() const override { |
| 93 | + |
| 94 | + return TargetInfo::XtensaABIBuiltinVaList; |
| 95 | + } |
| 96 | + |
| 97 | + std::string_view getClobbers() const override { return ""; } |
| 98 | + |
| 99 | + ArrayRef<const char *> getGCCRegNames() const override { |
| 100 | + static const char *const GCCRegNames[] = { |
| 101 | + // General register name |
| 102 | + "a0", "sp", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", |
| 103 | + "a11", "a12", "a13", "a14", "a15", |
| 104 | + // Special register name |
| 105 | + "sar"}; |
| 106 | + return llvm::ArrayRef(GCCRegNames); |
| 107 | + } |
| 108 | + |
| 109 | + ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { |
| 110 | + return std::nullopt; |
| 111 | + } |
| 112 | + |
| 113 | + bool validateAsmConstraint(const char *&Name, |
| 114 | + TargetInfo::ConstraintInfo &Info) const override { |
| 115 | + switch (*Name) { |
| 116 | + default: |
| 117 | + return false; |
| 118 | + case 'a': |
| 119 | + Info.setAllowsRegister(); |
| 120 | + return true; |
| 121 | + } |
| 122 | + return false; |
| 123 | + } |
| 124 | + |
| 125 | + int getEHDataRegisterNumber(unsigned RegNo) const override { |
| 126 | + return (RegNo < 2) ? RegNo : -1; |
| 127 | + } |
| 128 | + |
| 129 | + bool isValidCPUName(StringRef Name) const override { |
| 130 | + return llvm::StringSwitch<bool>(Name).Case("generic", true).Default(false); |
| 131 | + } |
| 132 | + |
| 133 | + bool setCPU(const std::string &Name) override { |
| 134 | + CPU = Name; |
| 135 | + return isValidCPUName(Name); |
| 136 | + } |
| 137 | +}; |
| 138 | + |
| 139 | +} // namespace targets |
| 140 | +} // namespace clang |
| 141 | +#endif // LLVM_CLANG_LIB_BASIC_TARGETS_XTENSA_H |
0 commit comments