mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL: add APIs to set and get the alignment of a pointer_to_address instruction.
Also add a getter for the `isInvariant` property.
This commit is contained in:
@@ -720,6 +720,9 @@ struct BridgedInstruction {
|
||||
BRIDGED_INLINE IntrinsicID BuiltinInst_getIntrinsicID() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap BuiltinInst_getSubstitutionMap() const;
|
||||
BRIDGED_INLINE bool PointerToAddressInst_isStrict() const;
|
||||
BRIDGED_INLINE bool PointerToAddressInst_isInvariant() const;
|
||||
BRIDGED_INLINE uint64_t PointerToAddressInst_getAlignment() const;
|
||||
BRIDGED_INLINE void PointerToAddressInst_setAlignment(uint64_t alignment) const;
|
||||
BRIDGED_INLINE bool AddressToPointerInst_needsStackProtection() const;
|
||||
BRIDGED_INLINE bool IndexAddrInst_needsStackProtection() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedConformanceArray InitExistentialRefInst_getConformances() const;
|
||||
|
||||
@@ -1140,6 +1140,23 @@ bool BridgedInstruction::PointerToAddressInst_isStrict() const {
|
||||
return getAs<swift::PointerToAddressInst>()->isStrict();
|
||||
}
|
||||
|
||||
bool BridgedInstruction::PointerToAddressInst_isInvariant() const {
|
||||
return getAs<swift::PointerToAddressInst>()->isInvariant();
|
||||
}
|
||||
|
||||
uint64_t BridgedInstruction::PointerToAddressInst_getAlignment() const {
|
||||
auto maybeAlign = getAs<swift::PointerToAddressInst>()->alignment();
|
||||
if (maybeAlign.has_value()) {
|
||||
assert(maybeAlign->value() != 0);
|
||||
return maybeAlign->value();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BridgedInstruction::PointerToAddressInst_setAlignment(uint64_t alignment) const {
|
||||
getAs<swift::PointerToAddressInst>()->setAlignment(llvm::MaybeAlign(alignment));
|
||||
}
|
||||
|
||||
bool BridgedInstruction::AddressToPointerInst_needsStackProtection() const {
|
||||
return getAs<swift::AddressToPointerInst>()->needsStackProtection();
|
||||
}
|
||||
|
||||
@@ -6074,10 +6074,7 @@ class PointerToAddressInst
|
||||
: UnaryInstructionBase(DebugLoc, Operand, Ty) {
|
||||
sharedUInt8().PointerToAddressInst.isStrict = IsStrict;
|
||||
sharedUInt8().PointerToAddressInst.isInvariant = IsInvariant;
|
||||
unsigned encodedAlignment = llvm::encode(Alignment);
|
||||
sharedUInt32().PointerToAddressInst.alignment = encodedAlignment;
|
||||
assert(sharedUInt32().PointerToAddressInst.alignment == encodedAlignment
|
||||
&& "pointer_to_address alignment overflow");
|
||||
setAlignment(Alignment);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -6100,6 +6097,13 @@ public:
|
||||
llvm::MaybeAlign alignment() const {
|
||||
return llvm::decodeMaybeAlign(sharedUInt32().PointerToAddressInst.alignment);
|
||||
}
|
||||
|
||||
void setAlignment(llvm::MaybeAlign Alignment) {
|
||||
unsigned encodedAlignment = llvm::encode(Alignment);
|
||||
sharedUInt32().PointerToAddressInst.alignment = encodedAlignment;
|
||||
assert(sharedUInt32().PointerToAddressInst.alignment == encodedAlignment
|
||||
&& "pointer_to_address alignment overflow");
|
||||
}
|
||||
};
|
||||
|
||||
/// Convert a heap object reference to a different type without any runtime
|
||||
|
||||
Reference in New Issue
Block a user