003 File Manager
Current Path:
/usr/src/contrib/llvm-project/clang/lib/Basic/Targets
usr
/
src
/
contrib
/
llvm-project
/
clang
/
lib
/
Basic
/
Targets
/
📁
..
📄
AArch64.cpp
(29.01 KB)
📄
AArch64.h
(6.99 KB)
📄
AMDGPU.cpp
(15.27 KB)
📄
AMDGPU.h
(11.06 KB)
📄
ARC.cpp
(857 B)
📄
ARC.h
(2.44 KB)
📄
ARM.cpp
(42.48 KB)
📄
ARM.h
(8.67 KB)
📄
AVR.cpp
(12.02 KB)
📄
AVR.h
(5.74 KB)
📄
BPF.cpp
(1.75 KB)
📄
BPF.h
(3.11 KB)
📄
Hexagon.cpp
(7.02 KB)
📄
Hexagon.h
(4.49 KB)
📄
Lanai.cpp
(2.31 KB)
📄
Lanai.h
(3.09 KB)
📄
Le64.cpp
(1.38 KB)
📄
Le64.h
(1.99 KB)
📄
MSP430.cpp
(1.14 KB)
📄
MSP430.h
(2.99 KB)
📄
Mips.cpp
(9.62 KB)
📄
Mips.h
(13.84 KB)
📄
NVPTX.cpp
(8.97 KB)
📄
NVPTX.h
(5.28 KB)
📄
OSTargets.cpp
(7.11 KB)
📄
OSTargets.h
(29.36 KB)
📄
PNaCl.cpp
(1001 B)
📄
PNaCl.h
(2.78 KB)
📄
PPC.cpp
(21.1 KB)
📄
PPC.h
(17.89 KB)
📄
RISCV.cpp
(6.88 KB)
📄
RISCV.h
(4.14 KB)
📄
SPIR.cpp
(1.2 KB)
📄
SPIR.h
(4.54 KB)
📄
Sparc.cpp
(9.86 KB)
📄
Sparc.h
(7.06 KB)
📄
SystemZ.cpp
(5.16 KB)
📄
SystemZ.h
(4.88 KB)
📄
TCE.cpp
(1.17 KB)
📄
TCE.h
(3.99 KB)
📄
VE.cpp
(1.43 KB)
📄
VE.h
(5.14 KB)
📄
WebAssembly.cpp
(8.19 KB)
📄
WebAssembly.h
(5.6 KB)
📄
X86.cpp
(48.61 KB)
📄
X86.h
(27.36 KB)
📄
XCore.cpp
(1.42 KB)
📄
XCore.h
(2.61 KB)
Editing: WebAssembly.cpp
//===--- WebAssembly.cpp - Implement WebAssembly target feature support ---===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements WebAssembly TargetInfo objects. // //===----------------------------------------------------------------------===// #include "WebAssembly.h" #include "Targets.h" #include "clang/Basic/Builtins.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/TargetBuiltins.h" #include "llvm/ADT/StringSwitch.h" using namespace clang; using namespace clang::targets; const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = { #define BUILTIN(ID, TYPE, ATTRS) \ {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE}, #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr}, #include "clang/Basic/BuiltinsWebAssembly.def" }; static constexpr llvm::StringLiteral ValidCPUNames[] = { {"mvp"}, {"bleeding-edge"}, {"generic"}}; StringRef WebAssemblyTargetInfo::getABI() const { return ABI; } bool WebAssemblyTargetInfo::setABI(const std::string &Name) { if (Name != "mvp" && Name != "experimental-mv") return false; ABI = Name; return true; } bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const { return llvm::StringSwitch<bool>(Feature) .Case("simd128", SIMDLevel >= SIMD128) .Case("unimplemented-simd128", SIMDLevel >= UnimplementedSIMD128) .Case("nontrapping-fptoint", HasNontrappingFPToInt) .Case("sign-ext", HasSignExt) .Case("exception-handling", HasExceptionHandling) .Case("bulk-memory", HasBulkMemory) .Case("atomics", HasAtomics) .Case("mutable-globals", HasMutableGlobals) .Case("multivalue", HasMultivalue) .Case("tail-call", HasTailCall) .Case("reference-types", HasReferenceTypes) .Default(false); } bool WebAssemblyTargetInfo::isValidCPUName(StringRef Name) const { return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames); } void WebAssemblyTargetInfo::fillValidCPUList( SmallVectorImpl<StringRef> &Values) const { Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames)); } void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { defineCPUMacros(Builder, "wasm", /*Tuning=*/false); if (SIMDLevel >= SIMD128) Builder.defineMacro("__wasm_simd128__"); if (SIMDLevel >= UnimplementedSIMD128) Builder.defineMacro("__wasm_unimplemented_simd128__"); if (HasNontrappingFPToInt) Builder.defineMacro("__wasm_nontrapping_fptoint__"); if (HasSignExt) Builder.defineMacro("__wasm_sign_ext__"); if (HasExceptionHandling) Builder.defineMacro("__wasm_exception_handling__"); if (HasBulkMemory) Builder.defineMacro("__wasm_bulk_memory__"); if (HasAtomics) Builder.defineMacro("__wasm_atomics__"); if (HasMutableGlobals) Builder.defineMacro("__wasm_mutable_globals__"); if (HasMultivalue) Builder.defineMacro("__wasm_multivalue__"); if (HasTailCall) Builder.defineMacro("__wasm_tail_call__"); if (HasReferenceTypes) Builder.defineMacro("__wasm_reference_types__"); } void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features, SIMDEnum Level, bool Enabled) { if (Enabled) { switch (Level) { case UnimplementedSIMD128: Features["unimplemented-simd128"] = true; LLVM_FALLTHROUGH; case SIMD128: Features["simd128"] = true; LLVM_FALLTHROUGH; case NoSIMD: break; } return; } switch (Level) { case NoSIMD: case SIMD128: Features["simd128"] = false; LLVM_FALLTHROUGH; case UnimplementedSIMD128: Features["unimplemented-simd128"] = false; break; } } void WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name, bool Enabled) const { if (Name == "simd128") setSIMDLevel(Features, SIMD128, Enabled); else if (Name == "unimplemented-simd128") setSIMDLevel(Features, UnimplementedSIMD128, Enabled); else Features[Name] = Enabled; } bool WebAssemblyTargetInfo::initFeatureMap( llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector<std::string> &FeaturesVec) const { if (CPU == "bleeding-edge") { Features["nontrapping-fptoint"] = true; Features["sign-ext"] = true; Features["bulk-memory"] = true; Features["atomics"] = true; Features["mutable-globals"] = true; Features["tail-call"] = true; setSIMDLevel(Features, SIMD128, true); } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); } bool WebAssemblyTargetInfo::handleTargetFeatures( std::vector<std::string> &Features, DiagnosticsEngine &Diags) { for (const auto &Feature : Features) { if (Feature == "+simd128") { SIMDLevel = std::max(SIMDLevel, SIMD128); continue; } if (Feature == "-simd128") { SIMDLevel = std::min(SIMDLevel, SIMDEnum(SIMD128 - 1)); continue; } if (Feature == "+unimplemented-simd128") { SIMDLevel = std::max(SIMDLevel, SIMDEnum(UnimplementedSIMD128)); continue; } if (Feature == "-unimplemented-simd128") { SIMDLevel = std::min(SIMDLevel, SIMDEnum(UnimplementedSIMD128 - 1)); continue; } if (Feature == "+nontrapping-fptoint") { HasNontrappingFPToInt = true; continue; } if (Feature == "-nontrapping-fptoint") { HasNontrappingFPToInt = false; continue; } if (Feature == "+sign-ext") { HasSignExt = true; continue; } if (Feature == "-sign-ext") { HasSignExt = false; continue; } if (Feature == "+exception-handling") { HasExceptionHandling = true; continue; } if (Feature == "-exception-handling") { HasExceptionHandling = false; continue; } if (Feature == "+bulk-memory") { HasBulkMemory = true; continue; } if (Feature == "-bulk-memory") { HasBulkMemory = false; continue; } if (Feature == "+atomics") { HasAtomics = true; continue; } if (Feature == "-atomics") { HasAtomics = false; continue; } if (Feature == "+mutable-globals") { HasMutableGlobals = true; continue; } if (Feature == "-mutable-globals") { HasMutableGlobals = false; continue; } if (Feature == "+multivalue") { HasMultivalue = true; continue; } if (Feature == "-multivalue") { HasMultivalue = false; continue; } if (Feature == "+tail-call") { HasTailCall = true; continue; } if (Feature == "-tail-call") { HasTailCall = false; continue; } if (Feature == "+reference-types") { HasReferenceTypes = true; continue; } if (Feature == "-reference-types") { HasReferenceTypes = false; continue; } Diags.Report(diag::err_opt_not_valid_with_opt) << Feature << "-target-feature"; return false; } return true; } ArrayRef<Builtin::Info> WebAssemblyTargetInfo::getTargetBuiltins() const { return llvm::makeArrayRef(BuiltinInfo, clang::WebAssembly::LastTSBuiltin - Builtin::FirstTSBuiltin); } void WebAssembly32TargetInfo::getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { WebAssemblyTargetInfo::getTargetDefines(Opts, Builder); defineCPUMacros(Builder, "wasm32", /*Tuning=*/false); } void WebAssembly64TargetInfo::getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { WebAssemblyTargetInfo::getTargetDefines(Opts, Builder); defineCPUMacros(Builder, "wasm64", /*Tuning=*/false); }
Upload File
Create Folder