Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Target.cpp
Go to the documentation of this file.
1//===- Target.cpp -----------------------------------------------*- 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#include "llvm/TextAPI/Target.h"
10#include "llvm/ADT/StringSwitch.h"
11#include "llvm/ADT/Twine.h"
12#include "llvm/Support/raw_ostream.h"
13
14namespacellvm {
15namespaceMachO {
16
17Expected<Target>Target::create(StringRef TargetValue) {
18auto Result = TargetValue.split('-');
19auto ArchitectureStr = Result.first;
20autoArchitecture =getArchitectureFromName(ArchitectureStr);
21auto PlatformStr = Result.second;
22PlatformTypePlatform;
23Platform =StringSwitch<PlatformType>(PlatformStr)
24#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
25 marketing) \
26 .Case(#tapi_target, PLATFORM_##platform)
27#include "llvm/BinaryFormat/MachO.def"
28 .Default(PLATFORM_UNKNOWN);
29
30if (Platform == PLATFORM_UNKNOWN) {
31if (PlatformStr.starts_with("<") && PlatformStr.ends_with(">")) {
32 PlatformStr = PlatformStr.drop_front().drop_back();
33unsignedlonglong RawValue;
34if (!PlatformStr.getAsInteger(10, RawValue))
35Platform = (PlatformType)RawValue;
36 }
37 }
38
39returnTarget{Architecture,Platform};
40}
41
42Target::operator std::string() const{
43autoVersion = MinDeployment.empty() ?"" : MinDeployment.getAsString();
44
45return (getArchitectureName(Arch) +" (" +getPlatformName(Platform) +
46Version +")")
47 .str();
48}
49
50raw_ostream &operator<<(raw_ostream &OS,constTarget &Target) {
51OS << std::string(Target);
52returnOS;
53}
54
55PlatformVersionSetmapToPlatformVersionSet(ArrayRef<Target> Targets) {
56PlatformVersionSet Result;
57for (constauto &Target : Targets)
58 Result.insert({Target.Platform,Target.MinDeployment});
59return Result;
60}
61
62PlatformSetmapToPlatformSet(ArrayRef<Target> Targets) {
63PlatformSet Result;
64for (constauto &Target : Targets)
65 Result.insert(Target.Platform);
66return Result;
67}
68
69ArchitectureSetmapToArchitectureSet(ArrayRef<Target> Targets) {
70ArchitectureSet Result;
71for (constauto &Target : Targets)
72 Result.set(Target.Arch);
73return Result;
74}
75
76std::stringgetTargetTripleName(constTarget &Targ) {
77autoVersion =
78 Targ.MinDeployment.empty() ?"" : Targ.MinDeployment.getAsString();
79
80return (getArchitectureName(Targ.Arch) +"-apple-" +
81getOSAndEnvironmentName(Targ.Platform,Version))
82 .str();
83}
84
85}// end namespace MachO.
86}// end namespace llvm.
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
StringSwitch.h
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Twine.h
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::Expected
Tagged union holding either a T or a Error.
Definition:Error.h:481
llvm::MachO::ArchitectureSet
Definition:ArchitectureSet.h:29
llvm::MachO::Target
Definition:Target.h:28
llvm::MachO::Target::Platform
PlatformType Platform
Definition:Target.h:43
llvm::MachO::Target::create
static llvm::Expected< Target > create(StringRef Target)
Definition:Target.cpp:17
llvm::MachO::Target::Arch
Architecture Arch
Definition:Target.h:42
llvm::MachO::Target::MinDeployment
VersionTuple MinDeployment
Definition:Target.h:44
llvm::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition:SmallSet.h:132
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::split
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition:StringRef.h:700
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition:StringSwitch.h:44
llvm::StringSwitch::Default
R Default(T Value)
Definition:StringSwitch.h:182
llvm::VersionTuple::getAsString
std::string getAsString() const
Retrieve a string representation of the version number.
Definition:VersionTuple.cpp:21
llvm::VersionTuple::empty
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
Definition:VersionTuple.h:66
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
Target.h
llvm::MachO::getTargetTripleName
std::string getTargetTripleName(const Target &Targ)
Definition:Target.cpp:76
llvm::MachO::getArchitectureFromName
Architecture getArchitectureFromName(StringRef Name)
Convert a name to an architecture slice.
Definition:Architecture.cpp:34
llvm::MachO::getArchitectureName
StringRef getArchitectureName(Architecture Arch)
Convert an architecture slice to a string.
Definition:Architecture.cpp:42
llvm::MachO::getOSAndEnvironmentName
std::string getOSAndEnvironmentName(PlatformType Platform, std::string Version="")
Definition:Platform.cpp:90
llvm::MachO::PlatformType
PlatformType
Definition:MachO.h:500
llvm::MachO::mapToPlatformSet
PlatformSet mapToPlatformSet(ArrayRef< Triple > Targets)
Definition:Platform.cpp:62
llvm::MachO::Architecture
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
Definition:Architecture.h:27
llvm::MachO::mapToPlatformVersionSet
PlatformVersionSet mapToPlatformVersionSet(ArrayRef< Target > Targets)
Definition:Target.cpp:55
llvm::MachO::getPlatformName
StringRef getPlatformName(PlatformType Platform)
Definition:Platform.cpp:69
llvm::MachO::operator<<
raw_ostream & operator<<(raw_ostream &OS, Architecture Arch)
Definition:Architecture.cpp:92
llvm::MachO::mapToArchitectureSet
ArchitectureSet mapToArchitectureSet(ArrayRef< Target > Targets)
Definition:Target.cpp:69
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::Version
@ Version
Definition:PGOCtxProfWriter.h:22
raw_ostream.h

Generated on Fri Jul 18 2025 14:42:53 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp