[LLVMdev] Problem with a target-specific builtin definition
pietreka at gmail.com
Fri Sep 10 06:24:31 PDT 2010
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.
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.
So I have defined this instruction in InstrInfo.td as follows:
def SCALL : Instr_Calls<(outs), (ins i32imm:$a),
"scall $a", [(int_mt_scall sysnumber:$a)]>;
The problem is with defining the intrinsic. If I define it in Clang (and
with similar types in LLVM) as follows:
BUILTIN(__builtin_mt_scall, "vi", "")
I cannot use the return value in C code:
if ( __builtin_mt_scall(127) == 0 ) do_something();
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:
def SCALL : Instr_Calls<(outs i32imm:$res), (ins i32imm:$a),
"scall $a", [(set $res, (int_mt_scall sysnumber:$a)]>;
but I won't get exactly what I want.
Does anyone have any suggestions how this could be done?
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev