I am trying to generate llvm-ir from AST.
For displaying the integer output I added,
Constant *CalleeF = TheModule->getOrInsertFunction("printf",FunctionType::get(IntegerType::getInt32Ty(Context), PointerType::get(Type::getInt8Ty(Context), 0), true);`
And while calling print function I wrote,
Value* PrintStmt::codegen(){
Value* V,*val,*to_print;
vector<Value *> ArgsV;
for (unsigned int i = 0, e = outs.size(); i != e; ++i){
to_print = outs[i]->codegen();
if(outs[i]->type=="int"){
val=Builder.CreateGlobalStringPtr("%d");
}
ArgsV.push_back(val);
ArgsV.push_back(to_print);
V = Builder.CreateCall(CalleeF, ArgsV, "printfCall");
}
return V;
}
What similar code should I write for getting input from user, i.e for scanf call?