mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
Add Hexagon support
This requires an updated LLVM with D31999 and D32000 to build libcore. A basic hello world builds and runs successfully on the hexagon simulator.
This commit is contained in:
parent
0777c757a6
commit
c558a2ae37
@ -94,7 +94,7 @@ fn main() {
|
||||
|
||||
let optional_components =
|
||||
["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz", "jsbackend", "msp430",
|
||||
"sparc", "nvptx"];
|
||||
"sparc", "nvptx", "hexagon"];
|
||||
|
||||
// FIXME: surely we don't need all these components, right? Stuff like mcjit
|
||||
// or interpreter the compiler itself never uses.
|
||||
|
@ -382,6 +382,12 @@ pub fn initialize_available_targets() {
|
||||
LLVMInitializeNVPTXTarget,
|
||||
LLVMInitializeNVPTXTargetMC,
|
||||
LLVMInitializeNVPTXAsmPrinter);
|
||||
init_target!(llvm_component = "hexagon",
|
||||
LLVMInitializeHexagonTargetInfo,
|
||||
LLVMInitializeHexagonTarget,
|
||||
LLVMInitializeHexagonTargetMC,
|
||||
LLVMInitializeHexagonAsmPrinter,
|
||||
LLVMInitializeHexagonAsmParser);
|
||||
}
|
||||
|
||||
pub fn last_error() -> Option<String> {
|
||||
|
@ -29,6 +29,7 @@ use cabi_sparc;
|
||||
use cabi_sparc64;
|
||||
use cabi_nvptx;
|
||||
use cabi_nvptx64;
|
||||
use cabi_hexagon;
|
||||
use machine::llalign_of_min;
|
||||
use type_::Type;
|
||||
use type_of;
|
||||
@ -896,6 +897,7 @@ impl<'a, 'tcx> FnType<'tcx> {
|
||||
"sparc64" => cabi_sparc64::compute_abi_info(ccx, self),
|
||||
"nvptx" => cabi_nvptx::compute_abi_info(ccx, self),
|
||||
"nvptx64" => cabi_nvptx64::compute_abi_info(ccx, self),
|
||||
"hexagon" => cabi_hexagon::compute_abi_info(ccx, self),
|
||||
a => ccx.sess().fatal(&format!("unrecognized arch \"{}\" in target specification", a))
|
||||
}
|
||||
|
||||
|
43
src/librustc_trans/cabi_hexagon.rs
Normal file
43
src/librustc_trans/cabi_hexagon.rs
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use abi::{FnType, ArgType, LayoutExt};
|
||||
use context::CrateContext;
|
||||
|
||||
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
|
||||
if ret.layout.is_aggregate() && ret.layout.size(ccx).bits() > 64 {
|
||||
ret.make_indirect(ccx);
|
||||
} else {
|
||||
ret.extend_integer_width_to(32);
|
||||
}
|
||||
}
|
||||
|
||||
fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
|
||||
if arg.layout.is_aggregate() && arg.layout.size(ccx).bits() > 64 {
|
||||
arg.make_indirect(ccx);
|
||||
} else {
|
||||
arg.extend_integer_width_to(32);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
|
||||
if !fty.ret.is_ignore() {
|
||||
classify_ret_ty(ccx, &mut fty.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fty.args {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
classify_arg_ty(ccx, arg);
|
||||
}
|
||||
}
|
@ -97,6 +97,7 @@ mod builder;
|
||||
mod cabi_aarch64;
|
||||
mod cabi_arm;
|
||||
mod cabi_asmjs;
|
||||
mod cabi_hexagon;
|
||||
mod cabi_mips;
|
||||
mod cabi_mips64;
|
||||
mod cabi_msp430;
|
||||
|
@ -147,6 +147,12 @@ extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
|
||||
#define SUBTARGET_SPARC
|
||||
#endif
|
||||
|
||||
#ifdef LLVM_COMPONENT_HEXAGON
|
||||
#define SUBTARGET_HEXAGON SUBTARGET(Hexagon)
|
||||
#else
|
||||
#define SUBTARGET_HEXAGON
|
||||
#endif
|
||||
|
||||
#define GEN_SUBTARGETS \
|
||||
SUBTARGET_X86 \
|
||||
SUBTARGET_ARM \
|
||||
@ -155,7 +161,8 @@ extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
|
||||
SUBTARGET_PPC \
|
||||
SUBTARGET_SYSTEMZ \
|
||||
SUBTARGET_MSP430 \
|
||||
SUBTARGET_SPARC
|
||||
SUBTARGET_SPARC \
|
||||
SUBTARGET_HEXAGON
|
||||
|
||||
#define SUBTARGET(x) \
|
||||
namespace llvm { \
|
||||
|
Loading…
Reference in New Issue
Block a user