Skip to content

Commit 690bb8a

Browse files
shepmasterdylanmckay
authored andcommitted
[AVR] Add AVR platform support
1 parent 5d39f1f commit 690bb8a

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
@@ -144,7 +144,7 @@ impl Step for Llvm {
144144

145145
let llvm_exp_targets = match builder.config.llvm_experimental_targets {
146146
Some(ref s) => s,
147-
None => "",
147+
None => "AVR",
148148
};
149149

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

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
@@ -375,6 +375,8 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
375375
match self.conv {
376376
Conv::C | Conv::Rust => llvm::CCallConv,
377377
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
378+
Conv::AvrInterrupt => llvm::AvrInterrupt,
379+
Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt,
378380
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
379381
Conv::Msp430Intr => llvm::Msp430Intr,
380382
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
@@ -347,6 +347,9 @@ declare_features! (
347347
/// Allows `extern "msp430-interrupt" fn()`.
348348
(active, abi_msp430_interrupt, "1.16.0", Some(38487), None),
349349

350+
/// Allows `extern "avr-interrupt" fn()` and `extern "avr-non-blocking-interrupt" fn()`.
351+
(active, abi_avr_interrupt, "1.41.0", None, None),
352+
350353
/// Allows declarative macros 2.0 (`macro`).
351354
(active, decl_macro, "1.17.0", Some(39412), None),
352355

src/librustc_llvm/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ fn main() {
7878
"arm",
7979
"aarch64",
8080
"amdgpu",
81+
"avr",
8182
"mips",
8283
"powerpc",
8384
"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_middle/ty/layout.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,6 +2529,8 @@ where
25292529
Msp430Interrupt => Conv::Msp430Intr,
25302530
X86Interrupt => Conv::X86Intr,
25312531
AmdGpuKernel => Conv::AmdGpuKernel,
2532+
AvrInterrupt => Conv::AvrInterrupt,
2533+
AvrNonBlockingInterrupt => Conv::AvrNonBlockingInterrupt,
25322534

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

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
abort,
124125
aborts,
125126
address,

0 commit comments

Comments
 (0)