clang 22.0.0git
Xtensa.h
Go to the documentation of this file.
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
20#include "llvm/ADT/StringSwitch.h"
21#include "llvm/Support/Compiler.h"
22#include "llvm/TargetParser/Triple.h"
23
27
28namespace clang {
29namespace targets {
30
31class LLVM_LIBRARY_VISIBILITY XtensaTargetInfo : public TargetInfo {
32 static const Builtin::Info BuiltinInfo[];
33
34protected:
35 std::string CPU;
36
37public:
38 XtensaTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
39 : TargetInfo(Triple) {
40 // no big-endianess support yet
41 BigEndian = false;
42 NoAsmVariants = true;
43 LongLongAlign = 64;
44 SuitableAlign = 32;
53 resetDataLayout("e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32");
54 }
55
56 void getTargetDefines(const LangOptions &Opts,
57 MacroBuilder &Builder) const override;
58
60 return {};
61 }
62
66
67 std::string_view getClobbers() const override { return ""; }
68
70 static const char *const GCCRegNames[] = {
71 // General register name
72 "a0", "sp", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10",
73 "a11", "a12", "a13", "a14", "a15",
74 // Special register name
75 "sar"};
77 }
78
80 return {};
81 }
82
83 bool validateAsmConstraint(const char *&Name,
84 TargetInfo::ConstraintInfo &Info) const override {
85 switch (*Name) {
86 default:
87 return false;
88 case 'a':
89 Info.setAllowsRegister();
90 return true;
91 }
92 return false;
93 }
94
95 int getEHDataRegisterNumber(unsigned RegNo) const override {
96 return (RegNo < 2) ? RegNo : -1;
97 }
98
99 bool isValidCPUName(StringRef Name) const override {
100 return llvm::StringSwitch<bool>(Name).Case("generic", true).Default(false);
101 }
102
103 bool setCPU(const std::string &Name) override {
104 CPU = Name;
105 return isValidCPUName(Name);
106 }
107};
108
109} // namespace targets
110} // namespace clang
111#endif // LLVM_CLANG_LIB_BASIC_TARGETS_XTENSA_H
Defines enum values for all the target-independent builtin functions.
Defines the clang::MacroBuilder utility class.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Defines the clang::TargetOptions class.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
TargetInfo(const llvm::Triple &T)
void resetDataLayout(StringRef DL, const char *UserLabelPrefix="")
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition TargetInfo.h:330
unsigned char MaxAtomicPromoteWidth
Definition TargetInfo.h:251
unsigned char MaxAtomicInlineWidth
Definition TargetInfo.h:251
Options for controlling the target.
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition Xtensa.h:67
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
Definition Xtensa.h:99
XtensaTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition Xtensa.h:38
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition Xtensa.h:79
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
Definition Xtensa.h:83
ArrayRef< const char * > getGCCRegNames() const override
Definition Xtensa.h:69
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition Xtensa.h:103
llvm::SmallVector< Builtin::InfosShard > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition Xtensa.h:59
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition Xtensa.h:63
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
Definition Xtensa.h:95
Defines the clang::TargetInfo interface.
static const char *const GCCRegNames[]
Definition X86.cpp:73
The JSON file list parser is used to communicate input to InstallAPI.
The info used to represent each builtin.
Definition Builtins.h:78
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
Definition TargetInfo.h:187