Implement CodeGenModule::getMemSetFn method.

llvm-svn: 47346
This commit is contained in:
Lauro Ramos Venancio 2008-02-19 22:01:01 +00:00
parent 9bbd8ebf78
commit 91fdb9ec43
2 changed files with 15 additions and 1 deletions

View File

@ -31,7 +31,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO,
llvm::Module &M, const llvm::TargetData &TD, llvm::Module &M, const llvm::TargetData &TD,
Diagnostic &diags) Diagnostic &diags)
: Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags), : Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags),
Types(C, M, TD), MemCpyFn(0), CFConstantStringClassRef(0) {} Types(C, M, TD), MemCpyFn(0), MemSetFn(0), CFConstantStringClassRef(0) {}
/// WarnUnsupported - Print out a warning that codegen doesn't support the /// WarnUnsupported - Print out a warning that codegen doesn't support the
/// specified stmt yet. /// specified stmt yet.
@ -329,6 +329,18 @@ llvm::Function *CodeGenModule::getMemCpyFn() {
return MemCpyFn = getIntrinsic(IID); return MemCpyFn = getIntrinsic(IID);
} }
llvm::Function *CodeGenModule::getMemSetFn() {
if (MemSetFn) return MemSetFn;
llvm::Intrinsic::ID IID;
uint64_t Size; unsigned Align;
Context.Target.getPointerInfo(Size, Align, FullSourceLoc());
switch (Size) {
default: assert(0 && "Unknown ptr width");
case 32: IID = llvm::Intrinsic::memset_i32; break;
case 64: IID = llvm::Intrinsic::memset_i64; break;
}
return MemSetFn = getIntrinsic(IID);
}
llvm::Constant *CodeGenModule:: llvm::Constant *CodeGenModule::
GetAddrOfConstantCFString(const std::string &str) { GetAddrOfConstantCFString(const std::string &str) {

View File

@ -52,6 +52,7 @@ class CodeGenModule {
CodeGenTypes Types; CodeGenTypes Types;
llvm::Function *MemCpyFn; llvm::Function *MemCpyFn;
llvm::Function *MemSetFn;
llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap; llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
llvm::StringMap<llvm::Constant*> CFConstantStringMap; llvm::StringMap<llvm::Constant*> CFConstantStringMap;
@ -85,6 +86,7 @@ public:
/// array containing the literal. The result is pointer to array type. /// array containing the literal. The result is pointer to array type.
llvm::Constant *GetAddrOfConstantString(const std::string& str); llvm::Constant *GetAddrOfConstantString(const std::string& str);
llvm::Function *getMemCpyFn(); llvm::Function *getMemCpyFn();
llvm::Function *getMemSetFn();
llvm::Function *getIntrinsic(unsigned IID, const llvm::Type **Tys = 0, llvm::Function *getIntrinsic(unsigned IID, const llvm::Type **Tys = 0,
unsigned NumTys = 0); unsigned NumTys = 0);