mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
IRGen uses a typedef, SpareBitVector, for its principal
purpose of tracking spare bits. Other uses should not
use this typedef, and I've tried to follow that, but I
did this rewrite mostly with sed and may have missed
some fixups.
This should be almost completely NFC. There may be
some subtle changes in spare bits for witness tables
and other off-beat pointer types. I also fixed a bug
where IRGen thought that thin functions were two
pointers wide, but this wouldn't have affected anything
because we never store thin functions anyway, since
they're not a valid AST type.
This commit repplies r24305 with two fixes:
- It fixes the computation of spare bits for unusual
integer types to use the already-agreed-upon type
size instead of recomputing it. This fixes the
i386 stdlib build. Joe and I agreed that we should
also change the size to use the LLVM alloc size
instead of the next power of 2, but this patch
does not do that yet.
- It changes the spare bits in function types back
to the empty set. I'll be changing this in a
follow-up, but it needs to be tied to runtime
changes. This fixes the regression test failures.
Swift SVN r24324
98 lines
3.3 KiB
C++
98 lines
3.3 KiB
C++
//===--- SwiftTargetInfo.h --------------------------------------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file declares the SwiftTargetInfo abstract base class. This class
|
|
// provides an interface to target-dependent attributes of interest to Swift.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef __SWIFT_IRGEN_TARGET_INFO_H__
|
|
#define __SWIFT_IRGEN_TARGET_INFO_H__
|
|
|
|
#include "swift/Basic/ClusteredBitVector.h"
|
|
#include "llvm/ADT/Triple.h"
|
|
#include "IRGen.h"
|
|
|
|
namespace swift {
|
|
namespace irgen {
|
|
class IRGenModule;
|
|
|
|
class SwiftTargetInfo {
|
|
explicit SwiftTargetInfo(llvm::Triple::ObjectFormatType outputObjectFormat,
|
|
unsigned numPointerBits);
|
|
|
|
public:
|
|
|
|
/// Produces a SwiftTargetInfo object appropriate to the target.
|
|
static SwiftTargetInfo get(IRGenModule &IGM);
|
|
|
|
/// True if the ObjC runtime for the chosen platform supports tagged pointers.
|
|
bool hasObjCTaggedPointers() const;
|
|
|
|
/// True if the ObjC runtime for the chosen platform requires ISA masking.
|
|
bool hasISAMasking() const {
|
|
return ObjCUseISAMask;
|
|
}
|
|
|
|
/// The target's object format type.
|
|
llvm::Triple::ObjectFormatType OutputObjectFormat;
|
|
|
|
/// The spare bit mask for pointers. Bits set in this mask are unused by
|
|
/// pointers of any alignment.
|
|
SpareBitVector PointerSpareBits;
|
|
|
|
/// The spare bit mask for (ordinary C) thin function pointers.
|
|
SpareBitVector FunctionPointerSpareBits;
|
|
|
|
/// The reserved bit mask for Objective-C pointers. Pointer values with
|
|
/// bits from this mask set are reserved by the ObjC runtime and cannot be
|
|
/// used for Swift value layout when a reference type may reference ObjC
|
|
/// objects.
|
|
SpareBitVector ObjCPointerReservedBits;
|
|
|
|
/// The alignment of heap objects. By default, assume pointer alignment.
|
|
Alignment HeapObjectAlignment;
|
|
|
|
/// The least integer value that can theoretically form a valid pointer.
|
|
/// By default, assume that there's an entire page free.
|
|
///
|
|
/// This excludes addresses in the null page(s) guaranteed to be
|
|
/// unmapped by the platform.
|
|
///
|
|
/// Changes to this must be kept in sync with swift/Runtime/Metadata.h.
|
|
uint64_t LeastValidPointerValue;
|
|
|
|
/// The maximum number of scalars that we allow to be returned directly.
|
|
/// FIXME Until rdar://14679857, this must be set such that
|
|
/// NSRect and NSPoint structs are returned correctly.
|
|
unsigned MaxScalarsForDirectResult = 3;
|
|
|
|
/// Inline assembly to mark a call to objc_retainAutoreleasedReturnValue.
|
|
llvm::StringRef ObjCRetainAutoreleasedReturnValueMarker;
|
|
|
|
/// The integer size of ObjC's BOOL type, i8 or i1.
|
|
unsigned ObjCBoolTypeSize = 8;
|
|
|
|
/// Some architectures have specialized objc_msgSend variants.
|
|
bool ObjCUseStret = true;
|
|
bool ObjCUseFPRet = false;
|
|
bool ObjCUseFP2Ret = false;
|
|
bool ObjCUseNullForEmptyVTable = false;
|
|
bool ObjCUseISAMask = false;
|
|
};
|
|
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|