diff options
| author | Arnold Schwaighofer <arnold.schwaighofer@gmail.com> | 2007-10-11 19:40:01 +0000 |
|---|---|---|
| committer | Arnold Schwaighofer <arnold.schwaighofer@gmail.com> | 2007-10-11 19:40:01 +0000 |
| commit | 9ccea99165d2e5cb4fba57b0d02e56651e2ae28c (patch) | |
| tree | b0726d27dcf2a842adb38aef6a374c5e2aee9b9e /llvm/lib/Target/X86/X86InstrX86-64.td | |
| parent | 29cfef59ff083be23222631e4ebbe7f695ef8386 (diff) | |
| download | bcm5719-llvm-9ccea99165d2e5cb4fba57b0d02e56651e2ae28c.tar.gz bcm5719-llvm-9ccea99165d2e5cb4fba57b0d02e56651e2ae28c.zip | |
Added tail call optimization to the x86 back end. It can be
enabled by passing -tailcallopt to llc. The optimization is
performed if the following conditions are satisfied:
* caller/callee are fastcc
* elf/pic is disabled OR
elf/pic enabled + callee is in module + callee has
visibility protected or hidden
llvm-svn: 42870
Diffstat (limited to 'llvm/lib/Target/X86/X86InstrX86-64.td')
| -rw-r--r-- | llvm/lib/Target/X86/X86InstrX86-64.td | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86InstrX86-64.td b/llvm/lib/Target/X86/X86InstrX86-64.td index f6f48a21d47..f501b5ec558 100644 --- a/llvm/lib/Target/X86/X86InstrX86-64.td +++ b/llvm/lib/Target/X86/X86InstrX86-64.td @@ -102,6 +102,23 @@ let isCall = 1 in "call\t{*}$dst", []>; } + + +let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in +def TCRETURNdi64 : I<0, Pseudo, (outs), (ins i64imm:$dst, i32imm:$offset), + "#TC_RETURN $dst $offset", + []>; + +let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in +def TCRETURNri64 : I<0, Pseudo, (outs), (ins GR64:$dst, i32imm:$offset), + "#TC_RETURN $dst $offset", + []>; + + +let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in + def TAILJMPr64 : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst # TAILCALL", + []>; + // Branches let isBranch = 1, isTerminator = 1, isBarrier = 1 in { def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst", @@ -1105,6 +1122,24 @@ def : Pat<(X86tailcall (i64 texternalsym:$dst)), def : Pat<(X86tailcall GR64:$dst), (CALL64r GR64:$dst)>; + +// tailcall stuff +def : Pat<(X86tailcall GR32:$dst), + (TAILCALL)>; +def : Pat<(X86tailcall (i64 tglobaladdr:$dst)), + (TAILCALL)>; +def : Pat<(X86tailcall (i64 texternalsym:$dst)), + (TAILCALL)>; + +def : Pat<(X86tcret GR64:$dst, imm:$off), + (TCRETURNri64 GR64:$dst, imm:$off)>; + +def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off), + (TCRETURNdi64 texternalsym:$dst, imm:$off)>; + +def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off), + (TCRETURNdi64 texternalsym:$dst, imm:$off)>; + // Comparisons. // TEST R,R is smaller than CMP R,0 |

