mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
heap allocations it makes, and switch swift_alloc over to pass that pointer in as well as the alignment. Also, compute whether a type is POD during its generation and cache that in the object, and introduce a method on TypeInfo to destroy an object in memory. Swift SVN r1356
62 lines
2.2 KiB
C++
62 lines
2.2 KiB
C++
//===--- GenMeta.cpp - IR generation for metadata constructs --------------===//
|
|
//
|
|
// 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 implements IR generation for metadata constructs like
|
|
// metatypes and modules. These is presently always trivial, but in
|
|
// the future we will likely have some sort of physical
|
|
// representation for at least some metatypes.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "swift/AST/Types.h"
|
|
#include "llvm/DerivedTypes.h"
|
|
|
|
#include "Address.h"
|
|
#include "GenType.h"
|
|
#include "IRGenModule.h"
|
|
|
|
#include "GenMeta.h"
|
|
|
|
using namespace swift;
|
|
using namespace irgen;
|
|
|
|
namespace {
|
|
struct EmptyTypeInfo : TypeInfo {
|
|
EmptyTypeInfo(llvm::Type *ty)
|
|
: TypeInfo(ty, Size(0), Alignment(1), IsPOD) {}
|
|
unsigned getExplosionSize(ExplosionKind kind) const { return 0; }
|
|
void getSchema(ExplosionSchema &schema) const {}
|
|
void load(IRGenFunction &IGF, Address addr, Explosion &e) const {}
|
|
void assign(IRGenFunction &IGF, Explosion &e, Address addr) const {}
|
|
void initialize(IRGenFunction &IGF, Explosion &e, Address addr) const {}
|
|
void reexplode(IRGenFunction &IGF, Explosion &src, Explosion &dest) const {}
|
|
void manage(IRGenFunction &IGF, Explosion &src, Explosion &dest) const {}
|
|
void destroy(IRGenFunction &IGF, Address addr) const {}
|
|
};
|
|
}
|
|
|
|
const TypeInfo *
|
|
TypeConverter::convertMetaTypeType(IRGenModule &IGM, MetaTypeType *T) {
|
|
return new EmptyTypeInfo(IGM.Int8Ty);
|
|
}
|
|
|
|
const TypeInfo *
|
|
TypeConverter::convertModuleType(IRGenModule &IGM, ModuleType *T) {
|
|
return new EmptyTypeInfo(IGM.Int8Ty);
|
|
}
|
|
|
|
/// Emit a reference to a metatype.
|
|
void swift::irgen::emitMetaTypeRef(IRGenFunction &IGF, Type type,
|
|
Explosion &explosion) {
|
|
// For now, all metatype types are empty.
|
|
}
|