<p dir="ltr">you're not showing enough code. What does accept() do?</p>
<p dir="ltr">Based on your description, I strongly suspect that your alloca and constant are not the same type. Remember that alloca returns a pointer type that you must load to get at the actual variable.</p>
<div class="gmail_quote">On Jan 11, 2013 3:28 AM, "Manuele Conti" <<a href="mailto:manuele.conti@sirius-es.it">manuele.conti@sirius-es.it</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi All,<br>
I'm writing a code generation with my compiler. I read sever example and documentation but I did understand what I make wrong.<br>
What I try to do is a compare a local variable with a constant.<br>
But when I create a ICMP instruction I get that instruction are not of same type.<br>
I'm using llvm by svn repository updated at two week ago.<br>
<br>
The code that I try to generation is something like:<br>
<br>
if varInt = 1 then<br>
varInt := 10;<br>
end_if;<br>
<br>
<br>
This is my code:<br>
<br>
void *visit(integer_c *symbol) {<br>
int64_t value = GET_CVALUE(int64, symbol);<br>
if (typeid(*currentType) == typeid(get_datatype_info_c::<u></u>bool_type_name)) {<br>
std::cout << "Creating integer: " << value << std::endl;<br>
return (void *)ConstantInt::get(Type::<u></u>getInt1Ty(getGlobalContext()), value, false);<br>
}<br>
return (void *)ConstantInt::get(Type::<u></u>getInt16Ty(getGlobalContext())<u></u>, value, false);<br>
}<br>
<br>
void *visit(symbolic_variable_c *symbol) {<br>
std::string varName;<br>
AllocaInst *alloc;<br>
<br>
varName = get_var_name_c::get_name(<u></u>symbol->var_name)->value;<br>
alloc = locals[varName];<br>
<br>
return (void *)alloc;<br>
}<br>
<br>
void *visit(equ_expression_c *symbol) {<br>
Value *lValue;<br>
Value *rValue;<br>
<br>
lValue = (Value *)symbol->l_exp->accept(*this)<u></u>;<br>
rValue = (Value *)symbol->r_exp->accept(*this)<u></u>;<br>
<br>
return Builder.CreateICmpEQ (lValue, rValue, "cond");<br>
<br>
}<br>
<br>
Cheers,<br>
Manuele<br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</blockquote></div>