<div>Hi,</div><div>I'm trying to add a target-specific builtin to clang and llvm. I was able to do that for many different "regular" instructions, however I encountered some issues with one specific.</div><div>

The instruction is syscall, which should force the compiler to act the same way as with regular calls (save registers, return address etc), except that this instruction takes just the syscall number as immediate. It returns one int value in a register specified in the ABI for return values.</div>

<div><br></div><div>So I have defined this instruction in InstrInfo.td as follows:</div><div><br></div><div>def SCALL : Instr_Calls<(outs), (ins i32imm:$a),</div><div>            "scall $a", [(int_mt_scall sysnumber:$a)]>;</div>

<div><br></div><div>The problem is with defining the intrinsic. If I define it in Clang (and with similar types in LLVM) as follows:</div><div>BUILTIN(__builtin_mt_scall, "vi", "")</div><div><br></div>

<div>I cannot use the return value in C code:</div><div>if ( __builtin_mt_scall(127) == 0 ) do_something();</div><div><br></div><div>If I set the return value type to int, I'd have to change also instruction's definition in InstrInfo.td and the pattern to something like this:</div>

<div><br></div><div>def SCALL : Instr_Calls<(outs i32imm:$res), (ins i32imm:$a),</div><div>            "scall $a", [(set $res, (int_mt_scall sysnumber:$a)]>;</div><div><br></div><div>but I won't get exactly what I want.</div>

<div><br></div><div>Does anyone have any suggestions how this could be done?</div><div><br></div><div>Thanks in advance,</div><div>Artur</div><div><br></div>