19 #include "llvm/ADT/StringSwitch.h" 21 using namespace clang;
25 #define BUILTIN(ID, TYPE, ATTRS) \ 26 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 27 #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ 28 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE}, 29 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ 30 {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr}, 31 #include "clang/Basic/BuiltinsWebAssembly.def" 35 {
"mvp"}, {
"bleeding-edge"}, {
"generic"}};
37 bool WebAssemblyTargetInfo::hasFeature(StringRef Feature)
const {
38 return llvm::StringSwitch<bool>(Feature)
39 .Case(
"simd128", SIMDLevel >= SIMD128)
40 .Case(
"unimplemented-simd128", SIMDLevel >= UnimplementedSIMD128)
41 .Case(
"nontrapping-fptoint", HasNontrappingFPToInt)
42 .Case(
"sign-ext", HasSignExt)
43 .Case(
"exception-handling", HasExceptionHandling)
47 bool WebAssemblyTargetInfo::isValidCPUName(StringRef Name)
const {
51 void WebAssemblyTargetInfo::fillValidCPUList(
59 if (SIMDLevel >= SIMD128)
61 if (SIMDLevel >= UnimplementedSIMD128)
62 Builder.
defineMacro(
"__wasm_unimplemented_simd128__");
65 void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features,
68 case UnimplementedSIMD128:
69 Features[
"unimplemented-simd128"] =
true;
72 Features[
"simd128"] =
true;
79 bool WebAssemblyTargetInfo::initFeatureMap(
81 const std::vector<std::string> &FeaturesVec)
const {
82 if (CPU ==
"bleeding-edge") {
83 Features[
"nontrapping-fptoint"] =
true;
84 Features[
"sign-ext"] =
true;
85 setSIMDLevel(Features, SIMD128);
90 setSIMDLevel(Features, SIMDLevel);
91 if (HasNontrappingFPToInt)
92 Features[
"nontrapping-fptoint"] =
true;
94 Features[
"sign-ext"] =
true;
95 if (HasExceptionHandling)
96 Features[
"exception-handling"] =
true;
101 bool WebAssemblyTargetInfo::handleTargetFeatures(
103 for (
const auto &Feature : Features) {
104 if (Feature ==
"+simd128") {
105 SIMDLevel =
std::max(SIMDLevel, SIMD128);
108 if (Feature ==
"-simd128") {
109 SIMDLevel =
std::min(SIMDLevel, SIMDEnum(SIMD128 - 1));
112 if (Feature ==
"+unimplemented-simd128") {
113 SIMDLevel =
std::max(SIMDLevel, SIMDEnum(UnimplementedSIMD128));
116 if (Feature ==
"-unimplemented-simd128") {
117 SIMDLevel =
std::min(SIMDLevel, SIMDEnum(UnimplementedSIMD128 - 1));
120 if (Feature ==
"+nontrapping-fptoint") {
121 HasNontrappingFPToInt =
true;
124 if (Feature ==
"-nontrapping-fptoint") {
125 HasNontrappingFPToInt =
false;
128 if (Feature ==
"+sign-ext") {
132 if (Feature ==
"-sign-ext") {
136 if (Feature ==
"+exception-handling") {
137 HasExceptionHandling =
true;
140 if (Feature ==
"-exception-handling") {
141 HasExceptionHandling =
false;
145 Diags.
Report(diag::err_opt_not_valid_with_opt)
146 << Feature <<
"-target-feature";
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Concrete class used by the front-end to report problems and issues.
Defines the Diagnostic-related interfaces.
virtual bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeatureVec) const
Initialize the map with the default set of target features for the CPU this should include all legal ...
Enumerates target-specific builtins in their own namespaces within namespace clang.
Dataflow Directional Tag Classes.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
static constexpr llvm::StringLiteral ValidCPUNames[]
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
__DEVICE__ int max(int __a, int __b)
void defineCPUMacros(MacroBuilder &Builder, StringRef CPUName, bool Tuning)
__DEVICE__ int min(int __a, int __b)
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".
Defines enum values for all the target-independent builtin functions.