rustc_llvm: expose FloatABIType target machine parameter
This commit is contained in:
parent
f95c996750
commit
fff026c8e5
4 changed files with 39 additions and 14 deletions
|
@ -25,7 +25,7 @@ impl OwnedTargetMachine {
|
||||||
model: llvm::CodeModel,
|
model: llvm::CodeModel,
|
||||||
reloc: llvm::RelocModel,
|
reloc: llvm::RelocModel,
|
||||||
level: llvm::CodeGenOptLevel,
|
level: llvm::CodeGenOptLevel,
|
||||||
use_soft_fp: bool,
|
float_abi: llvm::FloatAbi,
|
||||||
function_sections: bool,
|
function_sections: bool,
|
||||||
data_sections: bool,
|
data_sections: bool,
|
||||||
unique_section_names: bool,
|
unique_section_names: bool,
|
||||||
|
@ -57,7 +57,7 @@ impl OwnedTargetMachine {
|
||||||
model,
|
model,
|
||||||
reloc,
|
reloc,
|
||||||
level,
|
level,
|
||||||
use_soft_fp,
|
float_abi,
|
||||||
function_sections,
|
function_sections,
|
||||||
data_sections,
|
data_sections,
|
||||||
unique_section_names,
|
unique_section_names,
|
||||||
|
|
|
@ -40,7 +40,7 @@ use crate::errors::{
|
||||||
WithLlvmError, WriteBytecode,
|
WithLlvmError, WriteBytecode,
|
||||||
};
|
};
|
||||||
use crate::llvm::diagnostic::OptimizationDiagnosticKind::*;
|
use crate::llvm::diagnostic::OptimizationDiagnosticKind::*;
|
||||||
use crate::llvm::{self, DiagnosticInfo, PassManager};
|
use crate::llvm::{self, DiagnosticInfo, FloatAbi, PassManager};
|
||||||
use crate::type_::Type;
|
use crate::type_::Type;
|
||||||
use crate::{LlvmCodegenBackend, ModuleLlvm, base, common, llvm_util};
|
use crate::{LlvmCodegenBackend, ModuleLlvm, base, common, llvm_util};
|
||||||
|
|
||||||
|
@ -189,12 +189,12 @@ pub(crate) fn target_machine_factory(
|
||||||
let reloc_model = to_llvm_relocation_model(sess.relocation_model());
|
let reloc_model = to_llvm_relocation_model(sess.relocation_model());
|
||||||
|
|
||||||
let (opt_level, _) = to_llvm_opt_settings(optlvl);
|
let (opt_level, _) = to_llvm_opt_settings(optlvl);
|
||||||
let use_softfp = if sess.target.arch == "arm" {
|
let float_abi = if sess.target.arch == "arm" && sess.opts.cg.soft_float {
|
||||||
sess.opts.cg.soft_float
|
FloatAbi::Soft
|
||||||
} else {
|
} else {
|
||||||
// `validate_commandline_args_with_session_available` has already warned about this being
|
// `validate_commandline_args_with_session_available` has already warned about this being
|
||||||
// ignored. Let's make sure LLVM doesn't suddenly start using this flag on more targets.
|
// ignored. Let's make sure LLVM doesn't suddenly start using this flag on more targets.
|
||||||
false
|
FloatAbi::Default
|
||||||
};
|
};
|
||||||
|
|
||||||
let ffunction_sections =
|
let ffunction_sections =
|
||||||
|
@ -290,7 +290,7 @@ pub(crate) fn target_machine_factory(
|
||||||
code_model,
|
code_model,
|
||||||
reloc_model,
|
reloc_model,
|
||||||
opt_level,
|
opt_level,
|
||||||
use_softfp,
|
float_abi,
|
||||||
ffunction_sections,
|
ffunction_sections,
|
||||||
fdata_sections,
|
fdata_sections,
|
||||||
funique_section_names,
|
funique_section_names,
|
||||||
|
|
|
@ -526,7 +526,7 @@ pub struct SanitizerOptions {
|
||||||
pub sanitize_kernel_address_recover: bool,
|
pub sanitize_kernel_address_recover: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// LLVMRelocMode
|
/// LLVMRustRelocModel
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub enum RelocModel {
|
pub enum RelocModel {
|
||||||
|
@ -538,6 +538,15 @@ pub enum RelocModel {
|
||||||
ROPI_RWPI,
|
ROPI_RWPI,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// LLVMRustFloatABI
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub enum FloatAbi {
|
||||||
|
Default,
|
||||||
|
Soft,
|
||||||
|
Hard,
|
||||||
|
}
|
||||||
|
|
||||||
/// LLVMRustCodeModel
|
/// LLVMRustCodeModel
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -2192,7 +2201,7 @@ unsafe extern "C" {
|
||||||
Model: CodeModel,
|
Model: CodeModel,
|
||||||
Reloc: RelocModel,
|
Reloc: RelocModel,
|
||||||
Level: CodeGenOptLevel,
|
Level: CodeGenOptLevel,
|
||||||
UseSoftFP: bool,
|
FloatABIType: FloatAbi,
|
||||||
FunctionSections: bool,
|
FunctionSections: bool,
|
||||||
DataSections: bool,
|
DataSections: bool,
|
||||||
UniqueSectionNames: bool,
|
UniqueSectionNames: bool,
|
||||||
|
|
|
@ -308,6 +308,24 @@ static Reloc::Model fromRust(LLVMRustRelocModel RustReloc) {
|
||||||
report_fatal_error("Bad RelocModel.");
|
report_fatal_error("Bad RelocModel.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class LLVMRustFloatABI {
|
||||||
|
Default,
|
||||||
|
Soft,
|
||||||
|
Hard,
|
||||||
|
};
|
||||||
|
|
||||||
|
static FloatABI::ABIType fromRust(LLVMRustFloatABI RustFloatAbi) {
|
||||||
|
switch (RustFloatAbi) {
|
||||||
|
case LLVMRustFloatABI::Default:
|
||||||
|
return FloatABI::Default;
|
||||||
|
case LLVMRustFloatABI::Soft:
|
||||||
|
return FloatABI::Soft;
|
||||||
|
case LLVMRustFloatABI::Hard:
|
||||||
|
return FloatABI::Hard;
|
||||||
|
}
|
||||||
|
report_fatal_error("Bad FloatABI.");
|
||||||
|
}
|
||||||
|
|
||||||
/// getLongestEntryLength - Return the length of the longest entry in the table.
|
/// getLongestEntryLength - Return the length of the longest entry in the table.
|
||||||
template <typename KV> static size_t getLongestEntryLength(ArrayRef<KV> Table) {
|
template <typename KV> static size_t getLongestEntryLength(ArrayRef<KV> Table) {
|
||||||
size_t MaxLen = 0;
|
size_t MaxLen = 0;
|
||||||
|
@ -358,7 +376,7 @@ extern "C" const char *LLVMRustGetHostCPUName(size_t *OutLen) {
|
||||||
extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
||||||
const char *TripleStr, const char *CPU, const char *Feature,
|
const char *TripleStr, const char *CPU, const char *Feature,
|
||||||
const char *ABIStr, LLVMRustCodeModel RustCM, LLVMRustRelocModel RustReloc,
|
const char *ABIStr, LLVMRustCodeModel RustCM, LLVMRustRelocModel RustReloc,
|
||||||
LLVMRustCodeGenOptLevel RustOptLevel, bool UseSoftFloat,
|
LLVMRustCodeGenOptLevel RustOptLevel, LLVMRustFloatABI RustFloatABIType,
|
||||||
bool FunctionSections, bool DataSections, bool UniqueSectionNames,
|
bool FunctionSections, bool DataSections, bool UniqueSectionNames,
|
||||||
bool TrapUnreachable, bool Singlethread, bool VerboseAsm,
|
bool TrapUnreachable, bool Singlethread, bool VerboseAsm,
|
||||||
bool EmitStackSizeSection, bool RelaxELFRelocations, bool UseInitArray,
|
bool EmitStackSizeSection, bool RelaxELFRelocations, bool UseInitArray,
|
||||||
|
@ -369,6 +387,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
||||||
auto OptLevel = fromRust(RustOptLevel);
|
auto OptLevel = fromRust(RustOptLevel);
|
||||||
auto RM = fromRust(RustReloc);
|
auto RM = fromRust(RustReloc);
|
||||||
auto CM = fromRust(RustCM);
|
auto CM = fromRust(RustCM);
|
||||||
|
auto FloatABIType = fromRust(RustFloatABIType);
|
||||||
|
|
||||||
std::string Error;
|
std::string Error;
|
||||||
auto Trip = Triple(Triple::normalize(TripleStr));
|
auto Trip = Triple(Triple::normalize(TripleStr));
|
||||||
|
@ -381,10 +400,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
||||||
|
|
||||||
TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(Trip);
|
TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(Trip);
|
||||||
|
|
||||||
Options.FloatABIType = FloatABI::Default;
|
Options.FloatABIType = FloatABIType;
|
||||||
if (UseSoftFloat) {
|
|
||||||
Options.FloatABIType = FloatABI::Soft;
|
|
||||||
}
|
|
||||||
Options.DataSections = DataSections;
|
Options.DataSections = DataSections;
|
||||||
Options.FunctionSections = FunctionSections;
|
Options.FunctionSections = FunctionSections;
|
||||||
Options.UniqueSectionNames = UniqueSectionNames;
|
Options.UniqueSectionNames = UniqueSectionNames;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue