Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions tslang/include/TypeScript/MLIRLogic/MLIRGenStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,13 @@ struct MethodInfo
bool isCppSlotGap = false;
// `@keeps`, `@borrows`, `@lends` (OWN_DECLARED_KEEPS_ATTR_NAME): argument indices, `this` 0, for
// the declaration an importer re-parses; `@lends` names one, or several for a borrowing record
// (own spec 32), as a mask of argument indices (a vector would push the vtable's SmallVector
// past its inline-size limit)
// (own spec 32), as a mask of argument indices
std::vector<int32_t> ownKeeps;
std::vector<int32_t> ownBorrows;
uint64_t ownLendsMask = 0;
// `@record` (OWN_DECLARED_RECORD_ATTR_NAME): what `@lends` names, the result is a record of
bool ownRecord = false;
// `@immortalizes` (OWN_DECLARED_IMMORTALIZES_ATTR_NAME), as a mask like `@lends`'s, of 32 bits:
// it fits beside `ownRecord`, where a 64-bit one would grow the vtable's SmallVector past its
// inline-size limit
// `@immortalizes` (OWN_DECLARED_IMMORTALIZES_ATTR_NAME), as a mask like `@lends`'s, of 32 bits
uint32_t ownImmortalizesMask = 0;
};

Expand Down Expand Up @@ -406,7 +403,7 @@ struct InterfaceInfo
// yet-to-compile field/method access sites whenever presence of an optional member
// differed between casts (§5) - do not reintroduce that.
mlir::LogicalResult getVirtualTable(
llvm::SmallVector<VirtualMethodOrFieldInfo> &vtable,
llvm::SmallVector<VirtualMethodOrFieldInfo, 1> &vtable,
std::function<std::pair<mlir_ts::FieldInfo, mlir::LogicalResult>(mlir::Attribute, mlir::Type, bool)> resolveField,
std::function<std::pair<MethodInfo &, mlir::LogicalResult>(std::string, mlir_ts::FunctionType, bool, int)> resolveMethod,
bool methodsAsFields = false)
Expand Down Expand Up @@ -925,7 +922,7 @@ struct ClassInfo
return false;
}

void getVirtualTable(llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo> &vtable)
void getVirtualTable(llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo, 1> &vtable)
{
// name -> slot indices built alongside the vtable: override resolution is O(1)
// per method instead of a linear scan of the accumulated table, and keeping
Expand All @@ -937,7 +934,7 @@ struct ClassInfo
getVirtualTable(vtable, methodSlots, interfaceSlots);
}

void getVirtualTable(llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo> &vtable,
void getVirtualTable(llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo, 1> &vtable,
llvm::StringMap<size_t> &methodSlots, llvm::StringMap<size_t> &interfaceSlots)
{
// in static class I don't want to have virtual table
Expand Down
4 changes: 2 additions & 2 deletions tslang/include/TypeScript/MLIRLogic/MLIRTypeHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ class MLIRTypeHelper
mlir::LogicalResult canCastTupleToInterface(mlir::Location location, mlir_ts::TupleType tupleStorageType,
InterfaceInfo::TypePtr newInterfacePtr, bool suppressErrors = false)
{
SmallVector<VirtualMethodOrFieldInfo> virtualTable;
SmallVector<VirtualMethodOrFieldInfo, 1> virtualTable;
return getInterfaceVirtualTableForObject(location, tupleStorageType, newInterfacePtr, virtualTable, suppressErrors);
}

Expand All @@ -1545,7 +1545,7 @@ class MLIRTypeHelper

mlir::LogicalResult getInterfaceVirtualTableForObject(mlir::Location location, mlir_ts::TupleType tupleStorageType,
InterfaceInfo::TypePtr newInterfacePtr,
SmallVector<VirtualMethodOrFieldInfo> &virtualTable,
SmallVector<VirtualMethodOrFieldInfo, 1> &virtualTable,
bool suppressErrors = false)
{

Expand Down
10 changes: 5 additions & 5 deletions tslang/lib/TypeScript/MLIRGenClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ namespace mlirgen
setProcessingState(newClassPtr, ProcessingStages::ProcessingBody, genContext);

// prepare VTable
llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo> virtualTable;
llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo, 1> virtualTable;
newClassPtr->getVirtualTable(virtualTable);

// a @cpp class is never constructed, typed or allocated here: its objects come from C++;
Expand Down Expand Up @@ -314,7 +314,7 @@ namespace mlirgen
// an error (getVirtualTable finds it, here it's reported)
if (newClassPtr->isCppVTable)
{
llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo> cppVirtualTable;
llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo, 1> cppVirtualTable;
newClassPtr->cppSlotConflict.clear();
newClassPtr->getVirtualTable(cppVirtualTable);
if (!newClassPtr->cppSlotConflict.empty())
Expand Down Expand Up @@ -2569,12 +2569,12 @@ genContext);
// TODO: ...
auto classStorageType = mlir::cast<mlir_ts::ClassStorageType>(newClassPtr->classType.getStorageType());

llvm::SmallVector<VirtualMethodOrFieldInfo> virtualTable;
llvm::SmallVector<VirtualMethodOrFieldInfo, 1> virtualTable;
// the fields stored as optional<T> for an interface's `v?: T`: their slots are tagged
llvm::SmallVector<mlir::Attribute> optionalStorageFields;
// the interface's function-typed fields (`fn: () => int`) the class implements with a method
// (`fn(): int`): their slots point at a cell holding the method (see INTERFACE_METHOD_CELL_TAG)
llvm::SmallVector<std::pair<mlir::Attribute, MethodInfo>> methodsForFields;
llvm::SmallVector<std::pair<mlir::Attribute, MethodInfo>, 1> methodsForFields;
// of those, the ones filled by an optional class field (`fn?: () => int`): their cells carry the
// offset of the field's flag, so an access reads the instance's presence
llvm::SmallVector<mlir::Attribute> optionalFieldsForCells;
Expand Down Expand Up @@ -3181,7 +3181,7 @@ genContext);
}

// TODO: ...
llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo> virtualTable;
llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo, 1> virtualTable;
newClassPtr->getVirtualTable(virtualTable);

// TODO: this is pure hack, add ability to clean up created globals while "dummyRun = true"
Expand Down
8 changes: 4 additions & 4 deletions tslang/lib/TypeScript/MLIRGenImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10269,7 +10269,7 @@ class MLIRGenImpl
{
// we need to calculate VTable type
/*
llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo> virtualTable;
llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo, 1> virtualTable;
classInfo->getVirtualTable(virtualTable);
auto virtTuple = getVirtualTableType(virtualTable);

Expand Down Expand Up @@ -13031,7 +13031,7 @@ class MLIRGenImpl

mlir::LogicalResult getInterfaceVirtualTableForObject(mlir::Location location, mlir_ts::TupleType tupleStorageType,
InterfaceInfo::TypePtr newInterfacePtr,
SmallVector<VirtualMethodOrFieldInfo> &virtualTable,
SmallVector<VirtualMethodOrFieldInfo, 1> &virtualTable,
bool suppressErrors = false)
{
return mth.getInterfaceVirtualTableForObject(location, tupleStorageType, newInterfacePtr, virtualTable, suppressErrors);
Expand Down Expand Up @@ -13228,7 +13228,7 @@ class MLIRGenImpl
HeritageClause heritageClause,
const GenContext &genContext);

mlir::Type getVirtualTableType(llvm::SmallVector<VirtualMethodOrFieldInfo> &virtualTable)
mlir::Type getVirtualTableType(llvm::SmallVector<VirtualMethodOrFieldInfo, 1> &virtualTable)
{
llvm::SmallVector<mlir_ts::FieldInfo> fields;
for (auto vtableRecord : virtualTable)
Expand Down Expand Up @@ -13261,7 +13261,7 @@ class MLIRGenImpl
return virtTuple;
}

mlir::Type getVirtualTableType(llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo> &virtualTable)
mlir::Type getVirtualTableType(llvm::SmallVector<VirtualMethodOrInterfaceVTableInfo, 1> &virtualTable)
{
llvm::SmallVector<mlir_ts::FieldInfo> fields;
for (auto vtableRecord : virtualTable)
Expand Down
4 changes: 2 additions & 2 deletions tslang/lib/TypeScript/MLIRGenInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ namespace mlirgen
mlir_ts::FieldInfo emptyFieldInfo;
// the slots' MethodInfo are handed out by reference (getVirtualTable)
std::deque<MethodInfo> stubs;
llvm::SmallVector<VirtualMethodOrFieldInfo> virtualTable;
llvm::SmallVector<VirtualMethodOrFieldInfo, 1> virtualTable;
auto result = newInterfacePtr->getVirtualTable(
virtualTable,
[&](mlir::Attribute id, mlir::Type fieldType, bool isConditional) -> std::pair<mlir_ts::FieldInfo, mlir::LogicalResult> {
Expand Down Expand Up @@ -743,7 +743,7 @@ namespace mlirgen

auto tupleStorageType = mlir::cast<mlir_ts::TupleType>(mth.convertConstTupleTypeToTupleType(storeType));

SmallVector<VirtualMethodOrFieldInfo> virtualTable;
SmallVector<VirtualMethodOrFieldInfo, 1> virtualTable;
auto result = getInterfaceVirtualTableForObject(location, tupleStorageType, newInterfacePtr, virtualTable);
if (mlir::failed(result))
{
Expand Down
Loading