<div dir="ltr">Hi,<div><br></div><div>I am trying to write a simple interpreter.</div><div><br></div><div>I am trying to generate LLVM IR for assignment operation. The code for the generation part looks like this </div><div>
<br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">llvm::Value* codeGenSymTab(llvm::LLVMContext& context) {<br>
printf("\n CodeGen SymTab \n");<br> Value *num = ConstantInt::get(Type::getInt64Ty(context), aTable.value, true);<br> Value *alloc = new AllocaInst(IntegerType::get(context, 32), aTable.variableName,entry);<br>
StoreInst *ptr = new StoreInst(num,alloc,false,entry);<br>}</blockquote><div><br></div><div>Here goes the SymTab definition:</div><div><br></div><div>struct SymTab {</div><div> char* variableName;</div><div> int value; </div>
<div> llvm::Value* (*codeGen)(llvm::LLVMContext& context); </div><div>}; </div></div><div><br></div><div><br></div><div>When I try to execute the output file,I get the following error:</div><div><br></div><div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Assertion failed: (getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"), function AssertOK, file Instructions.cpp, line 1084.<br>
Abort trap: 6</blockquote><div><br></div><div>Can you help me resolve it ?</div><div><br></div><div>Thanks</div><div>Prakash </div>
</div></div>