mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
IR generation for curried functions. For now, parameters
are stored in a malloc'ed buffer that gets leaked. Swift SVN r1092
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "GenType.h"
|
||||
#include "IRGenModule.h"
|
||||
#include "Linking.h"
|
||||
|
||||
using namespace swift;
|
||||
using namespace irgen;
|
||||
@@ -47,6 +48,10 @@ IRGenModule::IRGenModule(ASTContext &Context,
|
||||
Int8PtrTy = llvm::Type::getInt8PtrTy(getLLVMContext());
|
||||
SizeTy = TargetData.getIntPtrType(getLLVMContext());
|
||||
MemCpyFn = nullptr;
|
||||
AllocFn = nullptr;
|
||||
|
||||
llvm::Type *elts[] = { Int8PtrTy, Int8PtrTy };
|
||||
Int8PtrPairTy = llvm::StructType::get(LLVMContext, elts, /*packed*/ false);
|
||||
}
|
||||
|
||||
IRGenModule::~IRGenModule() {
|
||||
@@ -62,6 +67,15 @@ llvm::Constant *IRGenModule::getMemCpyFn() {
|
||||
return MemCpyFn;
|
||||
}
|
||||
|
||||
llvm::Constant *IRGenModule::getAllocationFunction() {
|
||||
if (AllocFn) return AllocFn;
|
||||
|
||||
llvm::Type *types[] = { SizeTy };
|
||||
llvm::FunctionType *fnType = llvm::FunctionType::get(Int8PtrTy, types, false);
|
||||
AllocFn = Module.getOrInsertFunction("malloc", fnType);
|
||||
return AllocFn;
|
||||
}
|
||||
|
||||
void IRGenModule::unimplemented(SourceLoc Loc, StringRef Message) {
|
||||
Context.Diags.diagnose(Loc, diag::irgen_unimplemented, Message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user