<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman";}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:Arial;
color:windowtext;}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=DE link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=3 face=Arial><span style='font-size:12.0pt;
font-family:Arial'>Hello, LLVMers!<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span style='font-size:12.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'>How can I force a front end to generate VAARG for
accessing varargs parameters?<o:p></o:p></span></font></p>
<p class=MsoNormal><u><font size=3 face=Arial><span lang=EN-US
style='font-size:12.0pt;font-family:Arial'>I compile a simple C-code:<o:p></o:p></span></font></u></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'>#include <stdarg.h><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'>int FnVarArgs(int a, ...)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'>{<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'> int i,tmp=0;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'> va_list ptArgument;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'> va_start(ptArgument,a);<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'> for(i=0;i<9;i++)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'> tmp+= va_arg(ptArgument,int);<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'> return tmp;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'>}<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><u><font size=3 face=Arial><span lang=EN-US
style='font-size:12.0pt;font-family:Arial'>And then have this bytecode:<o:p></o:p></span></font></u></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-US style='font-size:
12.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'>; ModuleID = 'main.bc'<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'>target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'>target triple = "i386-pc-linux-gnu"<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'>define i32 @FnVarArgs(i32 %a, ...) nounwind {<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'>bb2.thread:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %ptArgument
= alloca i8*, align 4 ;
<i8**> [#uses=3]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %ptArgument1
= bitcast i8** %ptArgument to i8* ;
<i8*> [#uses=1]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> call
void @llvm.va_start(i8* %ptArgument1)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> br
label %bb2<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'>bb2: ;
preds = %bb2, %bb2.thread<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %i.0.reg2mem.0
= phi i32 [ 0, %bb2.thread ], [ %indvar.next, %bb2 ] ;
<i32> [#uses=1]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %tmp.0.reg2mem.0
= phi i32 [ 0, %bb2.thread ], [ %4, %bb2 ] ;
<i32> [#uses=1]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %0
= load i8** %ptArgument, align 4 ;
<i8*> [#uses=2]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %1
= getelementptr i8* %0, i32 4 ;
<i8*> [#uses=1]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> store
i8* %1, i8** %ptArgument, align 4<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %2
= bitcast i8* %0 to i32* ;
<i32*> [#uses=1]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %3
= load i32* %2, align 4 ;
<i32> [#uses=1]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %4
= add i32 %3, %tmp.0.reg2mem.0 ;
<i32> [#uses=2]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %indvar.next
= add i32 %i.0.reg2mem.0, 1 ;
<i32> [#uses=2]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> %exitcond
= icmp eq i32 %indvar.next, 9 ;
<i1> [#uses=1]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> br
i1 %exitcond, label %bb3, label %bb2<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'>bb3: ;
preds = %bb2<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'> ret
i32 %4<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'>}<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-US style='font-size:
10.0pt;font-family:Arial'>declare void @llvm.va_start(i8*) nounwind<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin:0cm;margin-bottom:.0001pt'><font size=2
face="Courier New"><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-US
style='font-size:12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><u><font size=3 face=Arial><span lang=EN-US
style='font-size:12.0pt;font-family:Arial'>There is a call of “va_start”
and there isn’t any “va_arg“! But I need it for specifical
lower in back end for my target!<o:p></o:p></span></font></u></p>
<p class=MsoNormal><u><font size=3 face=Arial><span lang=EN-US
style='font-size:12.0pt;font-family:Arial'><o:p><span style='text-decoration:
none'> </span></o:p></span></font></u></p>
<p class=MsoNormal><u><font size=3 face=Arial><span lang=EN-US
style='font-size:12.0pt;font-family:Arial'>Thanks,<o:p></o:p></span></font></u></p>
<p class=MsoNormal><u><font size=3 face=Arial><span lang=EN-US
style='font-size:12.0pt;font-family:Arial'>--Artem<o:p></o:p></span></font></u></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-US
style='font-size:12.0pt'><o:p> </o:p></span></font></p>
</div>
</body>
</html>