summaryrefslogtreecommitdiff
path: root/asmcomp/amd64
diff options
context:
space:
mode:
Diffstat (limited to 'asmcomp/amd64')
-rw-r--r--asmcomp/amd64/emit.mlp7
-rw-r--r--asmcomp/amd64/proc.ml2
2 files changed, 8 insertions, 1 deletions
diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp
index a5ef1dcdd0..74ce9c24ab 100644
--- a/asmcomp/amd64/emit.mlp
+++ b/asmcomp/amd64/emit.mlp
@@ -534,7 +534,12 @@ let emit_instr fallthrough i =
end
| Lswitch jumptbl ->
let lbl = new_label() in
- ` jmp *{emit_label lbl}(, {emit_reg i.arg.(0)}, 8)\n`;
+ if !pic_code then begin
+ ` leaq {emit_label lbl}(%rip), %r11\n`;
+ ` jmp *(%r11, {emit_reg i.arg.(0)}, 8)\n`
+ end else begin
+ ` jmp *{emit_label lbl}(, {emit_reg i.arg.(0)}, 8)\n`
+ end;
` .section .rodata\n`;
emit_align 8;
`{emit_label lbl}:`;
diff --git a/asmcomp/amd64/proc.ml b/asmcomp/amd64/proc.ml
index 856e4655a6..0e274b4f4e 100644
--- a/asmcomp/amd64/proc.ml
+++ b/asmcomp/amd64/proc.ml
@@ -92,6 +92,7 @@ let phys_reg n =
let rax = phys_reg 0
let rcx = phys_reg 5
let rdx = phys_reg 4
+let r11 = phys_reg 9
let rxmm15 = phys_reg 115
let stack_slot slot ty =
@@ -169,6 +170,7 @@ let destroyed_at_oper = function
| Iop(Istore(Single, _)) -> [| rxmm15 |]
| Iop(Ialloc _ | Iintop(Icomp _) | Iintop_imm((Idiv|Imod|Icomp _), _))
-> [| rax |]
+ | Iswitch(_, _) when !pic_code -> [| r11 |]
| _ -> [||]
let destroyed_at_raise = all_phys_regs