Add ELF TLS support in new x64 backend.
This follows the implementation in the legacy x86 backend, including hardcoded sequence that is compatible with what the linker expects. We could potentially do better here, but it is likely not necessary. Thanks to @bjorn3 for a bugfix to an earlier version of this.
This commit is contained in:
@@ -12,7 +12,7 @@ use crate::isa::{x64::X64Backend, CallConv};
|
||||
use crate::machinst::lower::*;
|
||||
use crate::machinst::*;
|
||||
use crate::result::CodegenResult;
|
||||
use crate::settings::Flags;
|
||||
use crate::settings::{Flags, TlsModel};
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec::Vec;
|
||||
use cranelift_codegen_shared::condcodes::CondCode;
|
||||
@@ -5324,6 +5324,22 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
|
||||
ctx.emit(Inst::gen_move(dst_hi, src.regs()[1], types::I64));
|
||||
}
|
||||
|
||||
Opcode::TlsValue => match flags.tls_model() {
|
||||
TlsModel::ElfGd => {
|
||||
let dst = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
|
||||
let (name, _, _) = ctx.symbol_value(insn).unwrap();
|
||||
let symbol = name.clone();
|
||||
ctx.emit(Inst::ElfTlsGetAddr { symbol });
|
||||
ctx.emit(Inst::gen_move(dst, regs::rax(), types::I64));
|
||||
}
|
||||
_ => {
|
||||
todo!(
|
||||
"Unimplemented TLS model in x64 backend: {:?}",
|
||||
flags.tls_model()
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
Opcode::IaddImm
|
||||
| Opcode::ImulImm
|
||||
| Opcode::UdivImm
|
||||
|
||||
Reference in New Issue
Block a user