本文整理汇总了C++中CodeGenContext::makeFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenContext::makeFunction方法的具体用法?C++ CodeGenContext::makeFunction怎么用?C++ CodeGenContext::makeFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenContext
的用法示例。
在下文中一共展示了CodeGenContext::makeFunction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateWriteAccessor
void CVariableDeclaration::CreateWriteAccessor(CodeGenContext& context, BitVariable& var, const std::string& moduleName, const std::string& name, bool impedance)
{
std::vector<llvm::Type*> argTypes;
argTypes.push_back(context.getIntType(var.size));
llvm::FunctionType *ftype = llvm::FunctionType::get(context.getVoidType(), argTypes, false);
llvm::Function* function;
if (context.isRoot)
{
function = context.makeFunction(ftype, llvm::GlobalValue::ExternalLinkage, context.moduleName + context.getSymbolPrefix() + "PinSet" + id.name);
}
else
{
function = context.makeFunction(ftype, llvm::GlobalValue::PrivateLinkage, context.moduleName + context.getSymbolPrefix() + "PinSet" + id.name);
}
function->onlyReadsMemory(); // Mark input read only
context.StartFunctionDebugInfo(function, declarationLoc);
llvm::BasicBlock *bblock = context.makeBasicBlock("entry", function);
context.pushBlock(bblock, declarationLoc);
llvm::Function::arg_iterator args = function->arg_begin();
llvm::Value* setVal = &*args;
setVal->setName("InputVal");
llvm::LoadInst* load = new llvm::LoadInst(var.value, "", false, bblock);
if (impedance)
{
llvm::LoadInst* loadImp = new llvm::LoadInst(var.impedance, "", false, bblock);
llvm::CmpInst* check = llvm::CmpInst::Create(llvm::Instruction::ICmp, llvm::ICmpInst::ICMP_NE, loadImp, context.getConstantZero(var.size.getLimitedValue()), "impedance", bblock);
setVal = llvm::SelectInst::Create(check, setVal, load, "impOrReal", bblock);
}
llvm::Value* stor = CAssignment::generateAssignmentActual(var, id/*moduleName, name*/, setVal, context, false); // we shouldn't clear impedance on write via pin (instead should ignore write if impedance is set)
var.priorValue = load;
var.writeInput = setVal;
var.writeAccessor = &writeAccessor;
writeAccessor = context.makeReturn(bblock);
context.popBlock(declarationLoc);
context.EndFunctionDebugInfo();
}
示例2: CreateReadAccessor
void CVariableDeclaration::CreateReadAccessor(CodeGenContext& context, BitVariable& var, bool impedance)
{
std::vector<llvm::Type*> argTypes;
llvm::FunctionType *ftype = llvm::FunctionType::get(context.getIntType(var.size), argTypes, false);
llvm::Function* function;
if (context.isRoot)
{
function = context.makeFunction(ftype, llvm::GlobalValue::ExternalLinkage, context.moduleName + context.getSymbolPrefix() + "PinGet" + id.name);
}
else
{
function = context.makeFunction(ftype, llvm::GlobalValue::PrivateLinkage, context.moduleName + context.getSymbolPrefix() + "PinGet" + id.name);
}
function->setOnlyReadsMemory();
context.StartFunctionDebugInfo(function, declarationLoc);
llvm::BasicBlock *bblock = context.makeBasicBlock("entry", function);
context.pushBlock(bblock, declarationLoc);
llvm::Value* load = new llvm::LoadInst(var.value, "", false, bblock);
if (impedance)
{
llvm::LoadInst* loadImp = new llvm::LoadInst(var.impedance, "", false, bblock);
llvm::CmpInst* check = llvm::CmpInst::Create(llvm::Instruction::ICmp, llvm::ICmpInst::ICMP_EQ, loadImp, context.getConstantZero(var.size.getLimitedValue()), "impedance", bblock);
load = llvm::SelectInst::Create(check, load, loadImp, "impOrReal", bblock);
}
context.makeReturnValue(load, bblock);
context.popBlock(declarationLoc);
context.EndFunctionDebugInfo();
}