mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Revert "[ABI/IRGen] Add custom function parameter flags representation for metadata use"
This reverts commit f6b0d2d2cf.
This commit is contained in:
@@ -325,29 +325,24 @@ public:
|
||||
struct Key {
|
||||
const FunctionTypeFlags Flags;
|
||||
|
||||
const Metadata *const *Parameters;
|
||||
const uint32_t *ParameterFlags;
|
||||
const Metadata *Result;
|
||||
const Metadata **const Parameters;
|
||||
const uint32_t *const ParameterFlags;
|
||||
const Metadata *const Result;
|
||||
|
||||
Key(FunctionTypeFlags flags,
|
||||
const Metadata *const *params,
|
||||
const Metadata **params,
|
||||
const uint32_t *paramFlags,
|
||||
const Metadata *result)
|
||||
: Flags(flags), Parameters(params), ParameterFlags(paramFlags),
|
||||
Result(result) {}
|
||||
|
||||
FunctionTypeFlags getFlags() const { return Flags; }
|
||||
const Metadata *const *getParameters() const { return Parameters; }
|
||||
const Metadata **getParameters() const { return Parameters; }
|
||||
const Metadata *getResult() const { return Result; }
|
||||
|
||||
const uint32_t *getParameterFlags() const {
|
||||
return ParameterFlags;
|
||||
}
|
||||
|
||||
::ParameterFlags getParameterFlags(unsigned index) const {
|
||||
uint32_t getParameterFlags(unsigned index) const {
|
||||
assert(index < Flags.getNumArguments());
|
||||
auto flags = Flags.hasParameterFlags() ? ParameterFlags[index] : 0;
|
||||
return ParameterFlags::fromIntValue(flags);
|
||||
return Flags.hasParameterFlags() ? ParameterFlags[index] : 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -371,30 +366,20 @@ public:
|
||||
Data.getArguments()[i]))
|
||||
return result;
|
||||
|
||||
if (auto result =
|
||||
compareIntegers(key.getParameterFlags(i).getIntValue(),
|
||||
Data.getParameterFlags(i).getIntValue()))
|
||||
if (auto result = compareIntegers(key.getParameterFlags(i),
|
||||
Data.getParameterFlags(i)))
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static size_t getExtraAllocationSize(Key key) {
|
||||
return getExtraAllocationSize(key.Flags);
|
||||
return key.getFlags().getNumArguments()
|
||||
* (sizeof(FunctionTypeMetadata::Argument) + sizeof(uint32_t));
|
||||
}
|
||||
|
||||
size_t getExtraAllocationSize() const {
|
||||
return getExtraAllocationSize(Data.Flags);
|
||||
}
|
||||
|
||||
static size_t getExtraAllocationSize(const FunctionTypeFlags flags) {
|
||||
const auto numParams = flags.getNumArguments();
|
||||
auto size = numParams * sizeof(FunctionTypeMetadata::Argument);
|
||||
if (flags.hasParameterFlags())
|
||||
size += numParams * sizeof(uint32_t);
|
||||
|
||||
const auto alignment = sizeof(void *);
|
||||
return (size + alignment - 1) & ~(alignment - 1);
|
||||
return Data.getNumArguments() *
|
||||
(sizeof(FunctionTypeMetadata::Argument) + sizeof(uint32_t));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -416,12 +401,12 @@ swift::swift_getFunctionTypeMetadata1(FunctionTypeFlags flags,
|
||||
const FunctionTypeMetadata *
|
||||
swift::swift_getFunctionTypeMetadata1WithFlags(FunctionTypeFlags flags,
|
||||
const Metadata *arg0,
|
||||
ParameterFlags flags0,
|
||||
const uint32_t flags0,
|
||||
const Metadata *result) {
|
||||
assert(flags.getNumArguments() == 1
|
||||
&& "wrong number of arguments in function metadata flags?!");
|
||||
const Metadata *parameters[] = { arg0 };
|
||||
const uint32_t parameterFlags[] = { flags0.getIntValue() };
|
||||
const uint32_t parameterFlags[] = { flags0 };
|
||||
return swift_getFunctionTypeMetadata(flags,
|
||||
parameters,
|
||||
parameterFlags,
|
||||
@@ -442,17 +427,14 @@ swift::swift_getFunctionTypeMetadata2(FunctionTypeFlags flags,
|
||||
const FunctionTypeMetadata *
|
||||
swift::swift_getFunctionTypeMetadata2WithFlags(FunctionTypeFlags flags,
|
||||
const Metadata *arg0,
|
||||
ParameterFlags flags0,
|
||||
const uint32_t flags0,
|
||||
const Metadata *arg1,
|
||||
ParameterFlags flags1,
|
||||
const uint32_t flags1,
|
||||
const Metadata *result) {
|
||||
assert(flags.getNumArguments() == 2
|
||||
&& "wrong number of arguments in function metadata flags?!");
|
||||
const Metadata *parameters[] = { arg0, arg1 };
|
||||
const uint32_t parameterFlags[] = {
|
||||
flags0.getIntValue(),
|
||||
flags1.getIntValue()
|
||||
};
|
||||
const uint32_t parameterFlags[] = { flags0, flags1 };
|
||||
return swift_getFunctionTypeMetadata(flags,
|
||||
parameters,
|
||||
parameterFlags,
|
||||
@@ -474,20 +456,16 @@ swift::swift_getFunctionTypeMetadata3(FunctionTypeFlags flags,
|
||||
const FunctionTypeMetadata *
|
||||
swift::swift_getFunctionTypeMetadata3WithFlags(FunctionTypeFlags flags,
|
||||
const Metadata *arg0,
|
||||
ParameterFlags flags0,
|
||||
const uint32_t flags0,
|
||||
const Metadata *arg1,
|
||||
ParameterFlags flags1,
|
||||
const uint32_t flags1,
|
||||
const Metadata *arg2,
|
||||
ParameterFlags flags2,
|
||||
const uint32_t flags2,
|
||||
const Metadata *result) {
|
||||
assert(flags.getNumArguments() == 3
|
||||
&& "wrong number of arguments in function metadata flags?!");
|
||||
const Metadata *parameters[] = { arg0, arg1, arg2 };
|
||||
const uint32_t parameterFlags[] = {
|
||||
flags0.getIntValue(),
|
||||
flags1.getIntValue(),
|
||||
flags2.getIntValue()
|
||||
};
|
||||
const uint32_t parameterFlags[] = { flags0, flags1, flags2 };
|
||||
return swift_getFunctionTypeMetadata(flags,
|
||||
parameters,
|
||||
parameterFlags,
|
||||
@@ -496,7 +474,7 @@ swift::swift_getFunctionTypeMetadata3WithFlags(FunctionTypeFlags flags,
|
||||
|
||||
const FunctionTypeMetadata *
|
||||
swift::swift_getFunctionTypeMetadata(FunctionTypeFlags flags,
|
||||
const Metadata *const *parameters,
|
||||
const Metadata **parameters,
|
||||
const uint32_t *parameterFlags,
|
||||
const Metadata *result) {
|
||||
FunctionCacheEntry::Key key = { flags, parameters, parameterFlags, result };
|
||||
@@ -536,10 +514,10 @@ FunctionCacheEntry::FunctionCacheEntry(Key key) {
|
||||
Data.Flags = flags;
|
||||
Data.ResultType = key.getResult();
|
||||
|
||||
for (unsigned i = 0; i < numArguments; ++i) {
|
||||
for (size_t i = 0; i < numArguments; ++i) {
|
||||
Data.getArguments()[i] = key.getParameters()[i];
|
||||
if (flags.hasParameterFlags())
|
||||
Data.getParameterFlags()[i] = key.getParameterFlags(i).getIntValue();
|
||||
Data.getParameterFlags()[i] = key.getParameterFlags(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user