Skip to content

Commit 2f4b347

Browse files
shepmasterdylanmckay
authored andcommitted
[AVR] Add AVR platform support
1 parent 46f5aa9 commit 2f4b347

File tree

21 files changed

+158
-2
lines changed

21 files changed

+158
-2
lines changed

config.toml.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
# the same format as above, but since these targets are experimental, they are
7070
# not built by default and the experimental Rust compilation targets that depend
7171
# on them will not work unless the user opts in to building them.
72-
#experimental-targets = ""
72+
#experimental-targets = "AVR"
7373

7474
# Cap the number of parallel linker invocations when compiling LLVM.
7575
# This can be useful when building LLVM with debug info, which significantly

src/bootstrap/native.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Step for Llvm {
123123

124124
let llvm_exp_targets = match builder.config.llvm_experimental_targets {
125125
Some(ref s) => s,
126-
None => "",
126+
None => "AVR",
127127
};
128128

129129
let assertions = if builder.config.llvm_assertions { "ON" } else { "OFF" };

src/librustc/ty/layout.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,8 @@ where
25102510
Msp430Interrupt => Conv::Msp430Intr,
25112511
X86Interrupt => Conv::X86Intr,
25122512
AmdGpuKernel => Conv::AmdGpuKernel,
2513+
AvrInterrupt => Conv::AvrInterrupt,
2514+
AvrNonBlockingInterrupt => Conv::AvrNonBlockingInterrupt,
25132515

25142516
// These API constants ought to be more specific...
25152517
Cdecl => Conv::C,

src/librustc_ast_passes/feature_gate.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ impl<'a> PostExpansionVisitor<'a> {
121121
"amdgpu-kernel ABI is experimental and subject to change"
122122
);
123123
}
124+
"avr-interrupt" | "avr-non-blocking-interrupt" => {
125+
gate_feature_post!(
126+
&self,
127+
abi_avr_interrupt,
128+
span,
129+
"avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change"
130+
);
131+
}
124132
"efiapi" => {
125133
gate_feature_post!(
126134
&self,

src/librustc_codegen_llvm/abi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
377377
match self.conv {
378378
Conv::C | Conv::Rust => llvm::CCallConv,
379379
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
380+
Conv::AvrInterrupt => llvm::AvrInterrupt,
381+
Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt,
380382
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
381383
Conv::Msp430Intr => llvm::Msp430Intr,
382384
Conv::PtxKernel => llvm::PtxKernel,

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ pub enum CallConv {
4545
X86_64_Win64 = 79,
4646
X86_VectorCall = 80,
4747
X86_Intr = 83,
48+
AvrNonBlockingInterrupt = 84,
49+
AvrInterrupt = 85,
4850
AmdGpuKernel = 91,
4951
}
5052

src/librustc_feature/active.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ declare_features! (
342342
/// Allows `extern "msp430-interrupt" fn()`.
343343
(active, abi_msp430_interrupt, "1.16.0", Some(38487), None),
344344

345+
/// Allows `extern "avr-interrupt" fn()` and `extern "avr-non-blocking-interrupt" fn()`.
346+
(active, abi_avr_interrupt, "1.41.0", None, None),
347+
345348
/// Allows declarative macros 2.0 (`macro`).
346349
(active, decl_macro, "1.17.0", Some(39412), None),
347350

src/librustc_llvm/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn main() {
6868
"arm",
6969
"aarch64",
7070
"amdgpu",
71+
"avr",
7172
"mips",
7273
"powerpc",
7374
"systemz",

src/librustc_llvm/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ pub fn initialize_available_targets() {
7676
LLVMInitializeAMDGPUAsmPrinter,
7777
LLVMInitializeAMDGPUAsmParser
7878
);
79+
init_target!(
80+
llvm_component = "avr",
81+
LLVMInitializeAVRTargetInfo,
82+
LLVMInitializeAVRTarget,
83+
LLVMInitializeAVRTargetMC,
84+
LLVMInitializeAVRAsmPrinter,
85+
LLVMInitializeAVRAsmParser
86+
);
7987
init_target!(
8088
llvm_component = "mips",
8189
LLVMInitializeMipsTargetInfo,

src/librustc_span/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ symbols! {
120120
abi_unadjusted,
121121
abi_vectorcall,
122122
abi_x86_interrupt,
123+
abi_avr_interrupt,
123124
aborts,
124125
address,
125126
add_with_overflow,

0 commit comments

Comments
 (0)