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:
John McCall
2012-01-19 23:29:49 +00:00
parent 883a16710b
commit b85ddcb34a
9 changed files with 391 additions and 28 deletions

View File

@@ -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);
}