virtual void EmitBuildVersion(unsigned Platform, unsigned Major,
unsigned Minor, unsigned Update) {}
+ void EmitVersionForTarget(const Triple &Target);
+
/// \brief Note in the output that the specified \p Func is a Thumb mode
/// function (ARM target only).
virtual void EmitThumbFunc(MCSymbol *Func);
// alternative is duplicated code in each of the target asm printers that
// use the directive, where it would need the same conditionalization
// anyway.
- const Triple &TT = TM.getTargetTriple();
- // If there is a version specified, Major will be non-zero.
- if (TT.isOSDarwin() && TT.getOSMajorVersion() != 0) {
- unsigned Major, Minor, Update;
- MCVersionMinType VersionType;
- if (TT.isWatchOS()) {
- VersionType = MCVM_WatchOSVersionMin;
- TT.getWatchOSVersion(Major, Minor, Update);
- } else if (TT.isTvOS()) {
- VersionType = MCVM_TvOSVersionMin;
- TT.getiOSVersion(Major, Minor, Update);
- } else if (TT.isMacOSX()) {
- VersionType = MCVM_OSXVersionMin;
- if (!TT.getMacOSXVersion(Major, Minor, Update))
- Major = 0;
- } else {
- VersionType = MCVM_IOSVersionMin;
- TT.getiOSVersion(Major, Minor, Update);
- }
- if (Major != 0)
- OutStreamer->EmitVersionMin(VersionType, Major, Minor, Update);
- }
+ const Triple &Target = TM.getTargetTriple();
+ OutStreamer->EmitVersionForTarget(Target);
// Allow the target to emit any magic that it wants at the start of the file.
EmitStartOfAsmFile(M);
MCMachOStreamer *S =
new MCMachOStreamer(Context, std::move(MAB), OS, std::move(CE),
DWARFMustBeAtTheEnd, LabelSections);
- const Triple &TT = Context.getObjectFileInfo()->getTargetTriple();
- if (TT.isOSDarwin()) {
- unsigned Major, Minor, Update;
- TT.getOSVersion(Major, Minor, Update);
- // If there is a version specified, Major will be non-zero.
- if (Major) {
- MCVersionMinType VersionType;
- if (TT.isWatchOS())
- VersionType = MCVM_WatchOSVersionMin;
- else if (TT.isTvOS())
- VersionType = MCVM_TvOSVersionMin;
- else if (TT.isMacOSX())
- VersionType = MCVM_OSXVersionMin;
- else {
- assert(TT.isiOS() && "Must only be iOS platform left");
- VersionType = MCVM_IOSVersionMin;
- }
- S->EmitVersionMin(VersionType, Major, Minor, Update);
- }
- }
+ const Triple &Target = Context.getObjectFileInfo()->getTargetTriple();
+ S->EmitVersionForTarget(Target);
if (RelaxAll)
S->getAssembler().setRelaxAll(true);
return S;
EmitLabel(Sym);
return Sym;
}
+
+void MCStreamer::EmitVersionForTarget(const Triple &Target) {
+ if (!Target.isOSBinFormatMachO() || !Target.isOSDarwin())
+ return;
+ // Do we even know the version?
+ if (Target.getOSMajorVersion() == 0)
+ return;
+
+ unsigned Major;
+ unsigned Minor;
+ unsigned Update;
+ MCVersionMinType VersionType;
+ if (Target.isWatchOS()) {
+ VersionType = MCVM_WatchOSVersionMin;
+ Target.getWatchOSVersion(Major, Minor, Update);
+ } else if (Target.isTvOS()) {
+ VersionType = MCVM_TvOSVersionMin;
+ Target.getiOSVersion(Major, Minor, Update);
+ } else if (Target.isMacOSX()) {
+ VersionType = MCVM_OSXVersionMin;
+ if (!Target.getMacOSXVersion(Major, Minor, Update))
+ Major = 0;
+ } else {
+ VersionType = MCVM_IOSVersionMin;
+ Target.getiOSVersion(Major, Minor, Update);
+ }
+ if (Major != 0)
+ EmitVersionMin(VersionType, Major, Minor, Update);
+}
// CHECK-NEXT: MinVersion {
// CHECK-NEXT: Cmd: LC_VERSION_MIN_MACOSX
// CHECK-NEXT: Size: 16
-// CHECK-NEXT: Version: 9.0
+// CHECK-NEXT: Version: 10.5
// CHECK-NEXT: SDK: n/a
// CHECK-NEXT: }